Cgl 0.60.9
Loading...
Searching...
No Matches
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
53private:
54 //---------------------------------------------------------------------------
55 // Enumeration constants that describe the various types of rows
72
73
74public:
78 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 //---------------------------------------------------------------------------
104
106
108 CglResidualCapacity ( const double tolerance );
109
112 const CglResidualCapacity &);
113
115 virtual CglCutGenerator * clone() const;
116
120 const CglResidualCapacity& rhs);
121
123 virtual
126 virtual void refreshPrep();
128
129
130
131private:
132 //--------------------------------------------------------------------------
133 // Private member methods
134
135 // Construct
136 void gutsOfConstruct ( const double tolerance);
137
138 // Delete
140
141 // Copy
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.
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 CoinBigIndex* 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
190private:
191 //---------------------------------------------------------------------------
192 // Private member data
194 double EPSILON_;
206 // The number of rows of the problem.
208 // The number columns of the problem.
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
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
222 // The indices of the rows of type ROW_L
224 // The number of rows of type ROW_G
226 // The indices of the rows of type ROW_G
228};
229
230//#############################################################################
236void CglResidualCapacityUnitTest(const OsiSolverInterface * siP,
237 const std::string mpdDir);
238
239
240#endif
void CglResidualCapacityUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglResidualCapacity class.
Cut Generator Base Class.
Residual Capacity Inequalities Cut Generator Class.
int doPreproc_
Controls the preprocessing of the matrix to identify rows suitable for cut generation.
void setEpsilon(double value)
Set Epsilon.
CglResidualCapacity & operator=(const CglResidualCapacity &rhs)
Assignment operator.
void resCapPreprocess(const OsiSolverInterface &si)
double getEpsilon() const
Get Epsilon.
bool getDoPreproc() const
Get doPreproc.
friend void CglResidualCapacityUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglResidualCapacity class.
double TOLERANCE_
If violation of a cut is greater that this number, the cut is accepted, default value: 1....
void setDoPreproc(int value)
Set doPreproc.
CglResidualCapacity(const CglResidualCapacity &)
Copy constructor.
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
void gutsOfConstruct(const double tolerance)
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 CoinBigIndex *rowStarts, const int *rowLengths, OsiCuts &cs) const
@ ROW_G
row of the type -a_1 c_1 - - a_k c_k + d z_1 + + d z_p >= b, where c_i are continuous variables and z...
@ ROW_L
row of the type a_1 c_1 + + a_k c_k - d z_1 - - d z_p <= b, where c_i are continuous variables and z_...
@ ROW_OTHER
Other types of rows.
@ ROW_BOTH
equation that can be treated as ROW_L and ROW_G
CglResidualCapacity(const double tolerance)
Alternate Constructor.
bool treatAsLessThan(const OsiSolverInterface &si, const int rowLen, const int *ind, const double *coef, const double rhs, const double *colLowerBound, const double *colUpperBound) const
void gutsOfCopy(const CglResidualCapacity &rhs)
virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo())
Generate Residual Capacity cuts for the model data contained in si.
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
CglResidualCapacity()
Default constructor.
virtual void refreshPrep()
This is to refresh preprocessing.
void setTolerance(double value)
Set Tolerance.
virtual CglCutGenerator * clone() const
Clone.
double getTolerance() const
Get Tolerance.
double EPSILON_
Tolerance used for numerical purposes, default value: 1.e-6.
virtual ~CglResidualCapacity()
Destructor.
Information about where the cut generator is invoked from.