40 const std::string mpdDir);
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,
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);
224 bool checkDynamism(
const double* cutElem,
const int* cutIndex,
232 int& cutNz,
double& cutRhs);
242 bool scaleCut(
double* cutElem,
int* cutIndex,
int cutNz,
243 double& cutRhs,
int scalingType);
251 long& numerator,
long& denominator);
257 void printvecINT(
const char *vecstr,
const int *x,
int n)
const;
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 );
const CoinPackedMatrix * byCol
Pointer on matrix of coefficient ordered by columns.
bool checkDynamism(const double *cutElem, const int *cutIndex, int cutNz)
Check the dynamism.
void printOptTab(OsiSolverInterface *solver) const
Print the current simplex tableau.
void setTrackRejection(bool value)
Set/get tracking of the rejection of cutting planes.
CglGMI()
Default constructor.
OsiSolverInterface * solver
Pointer on solver. Reset by each call to generateCuts().
CglGMI & operator=(const CglGMI &rhs)
Assignment operator.
void printvecINT(const char *vecstr, const int *x, int n) const
print a vector of integers
int ncol
Number of structural variables in the current LP.
int * rstat
Current basis status: rows.
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 areEqual(double x, double y, double epsAbs=1e-12, double epsRel=1e-12)
int * cstat
Current basis status: columns.
Information about where the cut generator is invoked from.
Collections of row cuts and column cuts.
void resetRejectionCounters()
Reset counters for cut rejection tracking; see above.
const double * rowUpper
Upper bounds for constraints.
void printvecDBL(const char *vecstr, const double *x, int n) const
print a vector of doubles: dense form
bool nearestRational(double val, double maxdelta, long maxdnom, long &numerator, long &denominator)
Compute the nearest rational number; used by scale_row_integral.
double f0
Fractionality of the cut and related quantities.
Abstract Base Class for describing an interface to a solver.
Class collecting parameters for the GMI cut generator.
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...
const double * rowRhs
Righ hand side for constraints (upper bound for ranged constraints).
virtual bool needsOptimalBasis() const
Return true if needs optimal basis to do cuts (will return true)
Gomory cut generator with several cleaning procedures, used to test the numerical safety of the resul...
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...
Cut Generator Base Class.
friend void CglGMIUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglGMI class.
void packRow(double *row, double *rowElem, int *rowIndex, int &rowNz)
Pack a row of ncol elements.
void relaxRhs(double &rhs)
Adjust the rhs by relaxing by a small amount (relative or absolute)
void setParam(const CglGMIParam &source)
virtual CglCutGenerator * clone() const
Clone.
const CoinPackedMatrix * byRow
Pointer on matrix of coefficient ordered by rows.
double computeCutCoefficient(double rowElem, int index)
Compute the cut coefficient on a given variable.
const double * colLower
Lower bounds for structural variables.
Sparse Matrix Base Class.
bool isIntegerValue(double x, double intEpsAbs=1e-9, double intEpsRel=1e-15)
bool scaleCutIntegral(double *cutElem, int *cutIndex, int cutNz, double &cutRhs)
Scale the cutting plane in order to generate integral coefficients.
const double * rowLower
Lower bounds for constraints.
CglGMIParam getParam() const
bool checkSupport(int cutNz)
Check the support.
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...
This deals with Factorization and Updates.
long computeGcd(long a, long b)
Compute the greatest common divisor.
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...
void CglGMIUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglGMI class.
const double * colUpper
Upper bounds for structural variables.
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.
bool isZero(double x, double epsZero=1e-20)
const double * xlp
Pointer on point to separate. Reset by each call to generateCuts().
virtual ~CglGMI()
Destructor.
bool computeCutFractionality(double varRhs, double &cutRhs)
Compute the fractionalities involved in the cut, and the cut rhs.
int getNumberGeneratedCuts()
Get total number of generated cuts since last resetRejectionCounters()
double aboveInteger(double value) const
Compute the fractional part of value, allowing for small error.
virtual std::string generateCpp(FILE *fp)
Create C++ lines to get to current state.
int nrow
Number of rows ( = number of slack variables) in the current LP.
CglGMIParam param
Object with CglGMIParam members.
int factorize(CoinFactorization &factorization, int *colBasisIndex, int *rowBasisIndex)
Recompute the simplex tableau for want of a better accuracy.
bool * isInteger
Characteristic vectors of structural integer variables or continuous variables currently fixed to int...
int getNumberRejectedCuts(RejectionType reason)
Get number of cuts rejected for given reason; see above.
void flip(double &rowElem, int rowIndex)
Change the sign of the coefficients of the non basic variables at their upper bound.
void unflipSlack(double &rowElem, int rowIndex, double &rowRhs, const double *slack_val)
const double * rowActivity
Pointer on row activity. Reset by each call to generateCuts().
bool removeSmallCoefficients(double *cutElem, int *cutIndex, int &cutNz, double &cutRhs)
Remove small coefficients and adjust the rhs accordingly.