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