coin-Cgl
CglResidualCapacity.hpp
Go to the documentation of this file.
1 // LAST EDIT:
2 //-----------------------------------------------------------------------------
3 // Implementation of Residual Capacity Inequalities
4 // Francisco Barahona (barahon@us.ibm.com)
5 //
6 // date: May 18, 2006
7 //-----------------------------------------------------------------------------
8 // Copyright (C) 2004, International Business Machines Corporation and others.
9 // All Rights Reserved.
10 // This code is published under the Common Public License.
11 
12 #ifndef CglResidualCapacity_H
13 #define CglResidualCapacity_H
14 
15 #include <iostream>
16 #include <fstream>
17 //#include <vector>
18 
19 #include "CoinError.hpp"
20 
21 #include "CglCutGenerator.hpp"
22 
23 //=============================================================================
24 
25 #ifndef CGL_DEBUG
26 #define CGL_DEBUG 0
27 #endif
28 
29 //=============================================================================
30 
31 
32 
33 
34 //=============================================================================
35 
48 
49  friend void CglResidualCapacityUnitTest(const OsiSolverInterface * siP,
50  const std::string mpdDir );
51 
52 
53 private:
54  //---------------------------------------------------------------------------
55  // Enumeration constants that describe the various types of rows
56  enum RowType {
71  };
72 
73 
74 public:
77  void setEpsilon(double value);
80  double getEpsilon() const;
82  void setTolerance(double value);
84  double getTolerance() const;
86  void setDoPreproc(int value);
88  bool getDoPreproc() const;
90 
97  virtual void generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
98  const CglTreeInfo info = CglTreeInfo()) const;
100 
101  //---------------------------------------------------------------------------
106 
108  CglResidualCapacity ( const double tolerance );
109 
112  const CglResidualCapacity &);
113 
115  virtual CglCutGenerator * clone() const;
116 
119  operator=(
120  const CglResidualCapacity& rhs);
121 
123  virtual
126  virtual void refreshPrep();
128 
129 
130 
131 private:
132  //--------------------------------------------------------------------------
133  // Private member methods
134 
135  // Construct
136  void gutsOfConstruct ( const double tolerance);
137 
138  // Delete
139  void gutsOfDelete();
140 
141  // Copy
142  void gutsOfCopy (const CglResidualCapacity& rhs);
143 
144  // Do preprocessing.
145  // It determines the type of each row.
146  // It may change sense and RHS for ranged rows
147  void resCapPreprocess(const OsiSolverInterface& si) const;
148 
149  // Determine the type of a given row.
150  RowType determineRowType(const OsiSolverInterface& si,
151  const int rowLen, const int* ind,
152  const double* coef, const char sense,
153  const double rhs,
154  const double* colLowerBound,
155  const double* colUpperBound) const;
156  // helps the function above
157  bool treatAsLessThan(const OsiSolverInterface& si,
158  const int rowLen, const int* ind,
159  const double* coef,
160  const double rhs,
161  const double* colLowerBound,
162  const double* colUpperBound) const;
163 
164  // Generate Residual Capacity cuts
165  void generateResCapCuts( const OsiSolverInterface& si,
166  const double* xlp,
167  const double* colUpperBound,
168  const double* colLowerBound,
169  const CoinPackedMatrix& matrixByRow,
170  const double* LHS,
171  const double* coefByRow,
172  const int* colInds,
173  const int* rowStarts,
174  const int* rowLengths,
175  OsiCuts& cs ) const;
176 
177 
178  // Residual Capacity separation
179  bool resCapSeparation(const OsiSolverInterface& si,
180  const int rowLen, const int* ind,
181  const double* coef,
182  const double rhs,
183  const double *xlp,
184  const double* colUpperBound,
185  const double* colLowerBound,
186  OsiRowCut& resCapCut) const;
187 
188 
189 
190 private:
191  //---------------------------------------------------------------------------
192  // Private member data
194  double EPSILON_;
197  double TOLERANCE_;
206  // The number of rows of the problem.
207  mutable int numRows_;
208  // The number columns of the problem.
209  mutable int numCols_;
210  // Indicates whether preprocessing has been done.
211  mutable bool doneInitPre_;
212  // Array with the row types of the rows in the model.
213  mutable RowType* rowTypes_;
214  // The indices of the rows of the initial matrix
215  mutable int* indRows_;
216  // Sense of rows (modified if ranges)
217  mutable char * sense_;
218  // RHS of rows (modified if ranges)
219  mutable double * RHS_;
220  // The number of rows of type ROW_L
221  mutable int numRowL_;
222  // The indices of the rows of type ROW_L
223  mutable int* indRowL_;
224  // The number of rows of type ROW_G
225  mutable int numRowG_;
226  // The indices of the rows of type ROW_G
227  mutable int* indRowG_;
228 };
229 
230 //#############################################################################
236 void CglResidualCapacityUnitTest(const OsiSolverInterface * siP,
237  const std::string mpdDir);
238 
239 
240 #endif