Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 Eclipse 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());
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);
148 
149  // Determine the type of a given row.
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  int numRows_;
208  // The number columns of the problem.
209  int numCols_;
210  // Indicates whether preprocessing has been done.
212  // Array with the row types of the rows in the model.
214  // The indices of the rows of the initial matrix
215  int* indRows_;
216  // Sense of rows (modified if ranges)
217  char * sense_;
218  // RHS of rows (modified if ranges)
219  double * RHS_;
220  // The number of rows of type ROW_L
221  int numRowL_;
222  // The indices of the rows of type ROW_L
223  int* indRowL_;
224  // The number of rows of type ROW_G
225  int numRowG_;
226  // The indices of the rows of type ROW_G
227  int* indRowG_;
228 };
229 
230 //#############################################################################
237  const std::string mpdDir);
238 
239 
240 #endif
void setDoPreproc(int value)
Set doPreproc.
RowType determineRowType(const OsiSolverInterface &si, const int rowLen, const int *ind, const double *coef, const char sense, const double rhs, const double *colLowerBound, const double *colUpperBound) const
double getEpsilon() const
Get Epsilon.
bool resCapSeparation(const OsiSolverInterface &si, const int rowLen, const int *ind, const double *coef, const double rhs, const double *xlp, const double *colUpperBound, const double *colLowerBound, OsiRowCut &resCapCut) const
int doPreproc_
Controls the preprocessing of the matrix to identify rows suitable for cut generation.
void resCapPreprocess(const OsiSolverInterface &si)
Information about where the cut generator is invoked from.
Definition: CglTreeInfo.hpp:15
Collections of row cuts and column cuts.
Definition: OsiCuts.hpp:19
Residual Capacity Inequalities Cut Generator Class.
row of the type -a_1 c_1 - - a_k c_k + d z_1 + + d z_p &gt;= b, where c_i are continuous variables and z...
virtual void refreshPrep()
This is to refresh preprocessing.
double getTolerance() const
Get Tolerance.
Abstract Base Class for describing an interface to a solver.
friend void CglResidualCapacityUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglResidualCapacity class.
void gutsOfConstruct(const double tolerance)
CglResidualCapacity & operator=(const CglResidualCapacity &rhs)
Assignment operator.
bool getDoPreproc() const
Get doPreproc.
Cut Generator Base Class.
void generateResCapCuts(const OsiSolverInterface &si, const double *xlp, const double *colUpperBound, const double *colLowerBound, const CoinPackedMatrix &matrixByRow, const double *LHS, const double *coefByRow, const int *colInds, const int *rowStarts, const int *rowLengths, OsiCuts &cs) const
equation that can be treated as ROW_L and ROW_G
bool treatAsLessThan(const OsiSolverInterface &si, const int rowLen, const int *ind, const double *coef, const double rhs, const double *colLowerBound, const double *colUpperBound) const
virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo())
Generate Residual Capacity cuts for the model data contained in si.
virtual CglCutGenerator * clone() const
Clone.
Row Cut Class.
Definition: OsiRowCut.hpp:29
Sparse Matrix Base Class.
virtual ~CglResidualCapacity()
Destructor.
void setEpsilon(double value)
Set Epsilon.
void gutsOfCopy(const CglResidualCapacity &rhs)
void CglResidualCapacityUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglResidualCapacity class.
CglResidualCapacity()
Default constructor.
void setTolerance(double value)
Set Tolerance.
double EPSILON_
Tolerance used for numerical purposes, default value: 1.e-6.
row of the type a_1 c_1 + + a_k c_k - d z_1 - - d z_p &lt;= b, where c_i are continuous variables and z_...
double TOLERANCE_
If violation of a cut is greater that this number, the cut is accepted, default value: 1...