16 #include "CoinWarmStartBasis.hpp"
17 #include "CoinFactorization.hpp"
40 const std::string mpdDir);
73 virtual void generateCuts(
const OsiSolverInterface & si, OsiCuts & cs,
84 double epsAbs = 1e-12,
85 double epsRel = 1e-12) {
86 return (fabs((x) - (y)) <=
87 std::max(epsAbs, epsRel * std::max(fabs(x), fabs(y))));
91 inline bool isZero(
double x,
double epsZero = 1e-20) {
92 return (fabs(x) <= epsZero);
98 double intEpsAbs = 1e-9,
99 double intEpsRel = 1e-15) {
100 return (fabs((x) - floor((x)+0.5)) <=
101 std::max(intEpsAbs, intEpsRel * fabs(x)));
188 double& cutRhs,
const double *elements,
189 const CoinBigIndex *rowStart,
const int *indices,
190 const int *rowLength,
const double *rhs);
194 inline void flip(
double& rowElem,
int rowIndex);
202 const double* slack_val);
205 inline void packRow(
double* row,
double* rowElem,
int* rowIndex,
213 bool cleanCut(
double* cutElem,
int* cutIndex,
int& cutNz,
214 double& cutRhs,
const double* xbar);
221 int cutNz,
double cutrhs,
const double* xbar);
232 int& cutNz,
double& cutRhs);
242 bool scaleCut(
double* cutElem,
int* cutIndex,
int cutNz,
243 double& cutRhs,
int scalingType);
251 long& numerator,
long& denominator);
259 void printvecDBL(
const char *vecstr,
const double *x,
int n)
const;
261 void printvecDBL(
const char *vecstr,
const double *elem,
const int * index,
269 int* colBasisIndex,
int* rowBasisIndex);
337 #if defined(TRACK_REJECT) || defined (TRACK_REJECT_SIMPLE)
348 int numGeneratedCuts;
361 const std::string mpdDir );
void CglGMIUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglGMI class.
Cut Generator Base Class.
Class collecting parameters for the GMI cut generator.
Gomory cut generator with several cleaning procedures, used to test the numerical safety of the resul...
void eliminateSlack(double cutElem, int cutIndex, double *cut, double &cutRhs, const double *elements, const CoinBigIndex *rowStart, const int *indices, const int *rowLength, const double *rhs)
Use multiples of the initial inequalities to cancel out the coefficient on a slack variables.
const double * rowLower
Lower bounds for constraints.
int nrow
Number of rows ( = number of slack variables) in the current LP.
void setParam(const CglGMIParam &source)
void unflipOrig(double &rowElem, int rowIndex, double &rowRhs)
Change the sign of the coefficients of the non basic variables at their upper bound and do the transl...
virtual CglCutGenerator * clone() const
Clone.
void setTrackRejection(bool value)
Set/get tracking of the rejection of cutting planes.
OsiSolverInterface * solver
Pointer on solver. Reset by each call to generateCuts().
void printvecINT(const char *vecstr, const int *x, int n) const
print a vector of integers
bool checkSupport(int cutNz)
Check the support.
bool computeCutFractionality(double varRhs, double &cutRhs)
Compute the fractionalities involved in the cut, and the cut rhs.
const double * colLower
Lower bounds for structural variables.
int getNumberRejectedCuts(RejectionType reason)
Get number of cuts rejected for given reason; see above.
const double * rowUpper
Upper bounds for constraints.
virtual bool needsOptimalBasis() const
Return true if needs optimal basis to do cuts (will return true)
const double * colUpper
Upper bounds for structural variables.
bool isIntegerValue(double x, double intEpsAbs=1e-9, double intEpsRel=1e-15)
void packRow(double *row, double *rowElem, int *rowIndex, int &rowNz)
Pack a row of ncol elements.
bool areEqual(double x, double y, double epsAbs=1e-12, double epsRel=1e-12)
int getNumberGeneratedCuts()
Get total number of generated cuts since last resetRejectionCounters()
bool isZero(double x, double epsZero=1e-20)
void generateCuts(OsiCuts &cs)
CglGMI()
Default constructor.
CglGMI & operator=(const CglGMI &rhs)
Assignment operator.
void printvecDBL(const char *vecstr, const double *elem, const int *index, int nz) const
print a vector of doubles: sparse form
CglGMIParam param
Object with CglGMIParam members.
double aboveInteger(double value) const
Compute the fractional part of value, allowing for small error.
CglGMI(const CglGMI &)
Copy constructor.
double computeCutCoefficient(double rowElem, int index)
Compute the cut coefficient on a given variable.
bool checkDynamism(const double *cutElem, const int *cutIndex, int cutNz)
Check the dynamism.
const double * rowRhs
Righ hand side for constraints (upper bound for ranged constraints).
const double * xlp
Pointer on point to separate. Reset by each call to generateCuts().
friend void CglGMIUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglGMI class.
void flip(double &rowElem, int rowIndex)
Change the sign of the coefficients of the non basic variables at their upper bound.
const CoinPackedMatrix * byCol
Pointer on matrix of coefficient ordered by columns.
long computeGcd(long a, long b)
Compute the greatest common divisor.
int factorize(CoinFactorization &factorization, int *colBasisIndex, int *rowBasisIndex)
Recompute the simplex tableau for want of a better accuracy.
RejectionType
Public enum: all possible reasons for cut rejection.
bool scaleCut(double *cutElem, int *cutIndex, int cutNz, double &cutRhs, int scalingType)
Scale the cutting plane in different ways; scaling_type possible values: 0 : scale to obtain integral...
bool cleanCut(double *cutElem, int *cutIndex, int &cutNz, double &cutRhs, const double *xbar)
Clean the cutting plane; the cleaning procedure does several things like removing small coefficients,...
virtual std::string generateCpp(FILE *fp)
Create C++ lines to get to current state.
bool scaleCutIntegral(double *cutElem, int *cutIndex, int cutNz, double &cutRhs)
Scale the cutting plane in order to generate integral coefficients.
void printvecDBL(const char *vecstr, const double *x, int n) const
print a vector of doubles: dense form
virtual ~CglGMI()
Destructor.
int * rstat
Current basis status: rows.
const double * rowActivity
Pointer on row activity. Reset by each call to generateCuts().
CglGMI(const CglGMIParam ¶m)
Constructor with specified parameters.
bool removeSmallCoefficients(double *cutElem, int *cutIndex, int &cutNz, double &cutRhs)
Remove small coefficients and adjust the rhs accordingly.
bool checkViolation(const double *cutElem, const int *cutIndex, int cutNz, double cutrhs, const double *xbar)
Cut cleaning procedures: return true if successfull, false if cut should be discarded by the caller o...
bool nearestRational(double val, double maxdelta, long maxdnom, long &numerator, long &denominator)
Compute the nearest rational number; used by scale_row_integral.
void unflipSlack(double &rowElem, int rowIndex, double &rowRhs, const double *slack_val)
int * cstat
Current basis status: columns.
const CoinPackedMatrix * byRow
Pointer on matrix of coefficient ordered by rows.
bool * isInteger
Characteristic vectors of structural integer variables or continuous variables currently fixed to int...
void printOptTab(OsiSolverInterface *solver) const
Print the current simplex tableau
void resetRejectionCounters()
Reset counters for cut rejection tracking; see above.
void relaxRhs(double &rhs)
Adjust the rhs by relaxing by a small amount (relative or absolute)
CglGMIParam getParam() const
int ncol
Number of structural variables in the current LP.
double f0
Fractionality of the cut and related quantities.
virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo())
Generate Gomory Mixed-Integer cuts for the model of the solver interface si.
Information about where the cut generator is invoked from.