Gomory Reduce-and-Split Cut Generator Class; See method generateCuts(). More...
#include <CglRedSplit.hpp>
Public Member Functions | |
generateCuts | |
virtual void | generateCuts (const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo()) |
Generate Reduce-and-Split Mixed Integer Gomory cuts for the model of the solver interface si. More... | |
virtual bool | needsOptimalBasis () const |
Return true if needs optimal basis to do cuts (will return true) More... | |
Public Methods | |
void | setParam (const CglRedSplitParam &source) |
Set given_optsol to the given optimal solution given_sol. More... | |
CglRedSplitParam | getParam () const |
Set given_optsol to the given optimal solution given_sol. More... | |
void | compute_is_lub () |
Set given_optsol to the given optimal solution given_sol. More... | |
void | compute_is_integer () |
Set given_optsol to the given optimal solution given_sol. More... | |
void | set_given_optsol (const double *given_sol, const int card_sol) |
Set given_optsol to the given optimal solution given_sol. More... | |
void | print () const |
Print some of the data members. More... | |
void | printOptTab (OsiSolverInterface *solver) const |
Print the current simplex tableau. More... | |
Public Methods (soon to be obsolete) | |
void | setLimit (int limit) |
Set limit, the maximum number of non zero coefficients in generated cut; Default: 50. More... | |
int | getLimit () const |
Get value of limit. More... | |
void | setAway (double value) |
Set away, the minimum distance from being integer used for selecting rows for cut generation; all rows whose pivot variable should be integer but is more than away from integrality will be selected; Default: 0.05. More... | |
double | getAway () const |
Get value of away. More... | |
void | setLUB (double value) |
Set the value of LUB, value considered large for the absolute value of a lower or upper bound on a variable; Default: 1000. More... | |
double | getLUB () const |
Get the value of LUB. More... | |
void | setEPS (double value) |
Set the value of EPS, epsilon for double computations; Default: 1e-7. More... | |
double | getEPS () const |
Get the value of EPS. More... | |
void | setEPS_COEFF (double value) |
Set the value of EPS_COEFF, epsilon for values of coefficients; Default: 1e-8. More... | |
double | getEPS_COEFF () const |
Get the value of EPS_COEFF. More... | |
void | setEPS_COEFF_LUB (double value) |
Set the value of EPS_COEFF_LUB, epsilon for values of coefficients for variables with absolute value of lower or upper bound larger than LUB; Default: 1e-13. More... | |
double | getEPS_COEFF_LUB () const |
Get the value of EPS_COEFF_LUB. More... | |
void | setEPS_RELAX (double value) |
Set the value of EPS_RELAX, value used for relaxing the right hand side of each generated cut; Default: 1e-8. More... | |
double | getEPS_RELAX () const |
Get the value of EPS_RELAX. More... | |
void | setNormIsZero (double value) |
Set the value of normIsZero, the threshold for considering a norm to be 0; Default: 1e-5. More... | |
double | getNormIsZero () const |
Get the value of normIsZero. More... | |
void | setMinReduc (double value) |
Set the value of minReduc, threshold for relative norm improvement for performing a reduction; Default: 0.05. More... | |
double | getMinReduc () const |
Get the value of minReduc. More... | |
void | setMaxTab (double value) |
Set the maximum allowed value for (mTab * mTab * CoinMax(mTab, nTab)) where mTab is the number of rows used in the combinations and nTab is the number of continuous non basic variables. More... | |
double | getMaxTab () const |
Get the value of maxTab. More... | |
Constructors and destructors | |
CglRedSplit () | |
Default constructor. More... | |
CglRedSplit (const CglRedSplitParam &RS_param) | |
Constructor with specified parameters. More... | |
CglRedSplit (const CglRedSplit &) | |
Copy constructor. More... | |
virtual CglCutGenerator * | clone () const |
Clone. More... | |
CglRedSplit & | operator= (const CglRedSplit &rhs) |
Assignment operator. More... | |
virtual | ~CglRedSplit () |
Destructor. More... | |
virtual std::string | generateCpp (FILE *fp) |
Create C++ lines to get to current state. More... | |
![]() | |
CglCutGenerator () | |
Default constructor. More... | |
CglCutGenerator (const CglCutGenerator &) | |
Copy constructor. More... | |
CglCutGenerator & | operator= (const CglCutGenerator &rhs) |
Assignment operator. More... | |
virtual | ~CglCutGenerator () |
Destructor. More... | |
virtual void | refreshSolver (OsiSolverInterface *) |
This can be used to refresh any information. More... | |
int | getAggressiveness () const |
Get Aggressiveness - 0 = neutral, 100 is normal root node. More... | |
void | setAggressiveness (int value) |
Set Aggressiveness - 0 = neutral, 100 is normal root node. More... | |
void | setGlobalCuts (bool trueOrFalse) |
Set whether can do global cuts. More... | |
bool | canDoGlobalCuts () const |
Say whether can do global cuts. More... | |
virtual bool | mayGenerateRowCutsInTree () const |
Returns true if may generate Row cuts in tree (rather than root node). More... | |
virtual int | maximumLengthOfCutInTree () const |
Return maximum length of cut in tree. More... | |
Private Member Functions | |
Private member methods | |
void | generateCuts (OsiCuts &cs) |
Compute the fractional part of value, allowing for small error. More... | |
double | rs_above_integer (double value) |
Compute the fractional part of value, allowing for small error. More... | |
void | update_pi_mat (int r1, int r2, int step) |
Perform row r1 of pi := row r1 of pi - step * row r2 of pi. More... | |
void | update_redTab (int r1, int r2, int step) |
Perform row r1 of tab := row r1 of tab - step * row r2 of tab. More... | |
void | find_step (int r1, int r2, int *step, double *reduc, double *norm) |
Find optimal integer step for changing row r1 by adding to it a multiple of another row r2. More... | |
int | test_pair (int r1, int r2, double *norm) |
Test if an ordered pair of rows yields a reduction. More... | |
void | reduce_contNonBasicTab () |
Reduce rows of contNonBasicTab. More... | |
void | generate_row (int index_row, double *row) |
Generate a row of the current LP tableau. More... | |
int | generate_cgcut (double *row, double *rhs) |
Generate a mixed integer Chvatal-Gomory cut, when all non basic variables are non negative and at their lower bound. More... | |
int | generate_cgcut_2 (int basic_ind, double *row, double *rhs) |
Generate a mixed integer Chvatal-Gomory cut, when all non basic variables are non negative and at their lower bound (different formula) More... | |
void | eliminate_slacks (double *row, const double *elements, const int *start, const int *indices, const int *rowLength, const double *rhs, double *rowrhs) |
Use multiples of the initial inequalities to cancel out the coefficients of the slack variables. More... | |
void | flip (double *row) |
Change the sign of the coefficients of the continuous non basic variables at their upper bound. More... | |
void | unflip (double *row, double *rowrhs, double *slack_val) |
Change the sign of the coefficients of the continuous non basic variables at their upper bound and do the translations restoring the original bounds. More... | |
*double | row_scale_factor (double *row) |
Return the scale factor for the row. More... | |
int | generate_packed_row (const double *xlp, double *row, int *rowind, double *rowelem, int *card_row, double &rhs) |
Generate the packed cut from the row representation. More... | |
void | check_optsol (const int calling_place, const double *xlp, const double *slack_val, const int do_flip) |
Check that the generated cuts do not cut a given optimal solution. More... | |
void | check_optsol (const int calling_place, const double *xlp, const double *slack_val, const double *ck_row, const double ck_rhs, const int cut_number, const int do_flip) |
Check that the generated cuts do not cut a given optimal solution. More... | |
bool | rs_are_different_vectors (const int *vect1, const int *vect2, const int dim) |
Compute the fractional part of value, allowing for small error. More... | |
bool | rs_are_different_vectors (const double *vect1, const double *vect2, const int dim) |
Compute the fractional part of value, allowing for small error. More... | |
bool | rs_are_different_matrices (const CoinPackedMatrix *mat1, const CoinPackedMatrix *mat2, const int nmaj, const int nmin) |
Compute the fractional part of value, allowing for small error. More... | |
Private Attributes | |
Private member data | |
CglRedSplitParam | param |
Object with CglRedSplitParam members. More... | |
int | nrow |
Number of rows ( = number of slack variables) in the current LP. More... | |
int | ncol |
Number of structural variables in the current LP. More... | |
const double * | colLower |
Lower bounds for structural variables. More... | |
const double * | colUpper |
Upper bounds for structural variables. More... | |
const double * | rowLower |
Lower bounds for constraints. More... | |
const double * | rowUpper |
Upper bounds for constraints. More... | |
const double * | rowRhs |
Righ hand side for constraints (upper bound for ranged constraints). More... | |
int | card_intBasicVar_frac |
Number of integer basic structural variables that are fractional in the current lp solution (at least param.away_ from being integer). More... | |
int | card_intNonBasicVar |
Number of integer non basic structural variables in the current lp solution. More... | |
int | card_contNonBasicVar |
Number of continuous non basic variables (structural or slack) in the current lp solution. More... | |
int | card_nonBasicAtUpper |
Number of non basic variables (structural or slack) at their upper bound in the current lp solution. More... | |
int | card_nonBasicAtLower |
Number of non basic variables (structural or slack) at their lower bound in the current lp solution. More... | |
int * | cv_intBasicVar_frac |
Characteristic vector for integer basic structural variables with non integer value in the current lp solution. More... | |
int * | intBasicVar_frac |
List of integer structural basic variables (in order of pivot in selected rows for cut generation). More... | |
int * | intNonBasicVar |
List of integer structural non basic variables. More... | |
int * | contNonBasicVar |
List of continuous non basic variables (structural or slack). More... | |
int * | nonBasicAtUpper |
List of non basic variables (structural or slack) at their upper bound. More... | |
int * | nonBasicAtLower |
List of non basic variables (structural or slack) at their lower bound. More... | |
int | mTab |
Number of rows in the reduced tableau (= card_intBasicVar_frac). More... | |
int | nTab |
Number of columns in the reduced tableau (= card_contNonBasicVar) More... | |
int ** | pi_mat |
Tableau of multipliers used to alter the rows used in generation. More... | |
double ** | contNonBasicTab |
Current tableau for continuous non basic variables (structural or slack). More... | |
double ** | intNonBasicTab |
Current tableau for integer non basic structural variables. More... | |
double * | rhsTab |
Right hand side of the tableau. More... | |
const double * | given_optsol |
Given optimal solution that should not be cut; only for debug. More... | |
int | card_given_optsol |
Number of entries in given_optsol. More... | |
int * | is_integer |
Characteristic vectors of structural integer variables or continuous variables currently fixed to integer values. More... | |
int * | low_is_lub |
Characteristic vector of the structural variables whose lower bound in absolute value is larger than LUB. More... | |
int * | up_is_lub |
Characteristic vector of the structural variables whose upper bound in absolute value is larger than LUB. More... | |
OsiSolverInterface * | solver |
Pointer on solver. Reset by each call to generateCuts(). More... | |
const double * | xlp |
Pointer on point to separate. Reset by each call to generateCuts(). More... | |
const double * | rowActivity |
Pointer on row activity. Reset by each call to generateCuts(). More... | |
const char * | colType |
Pointer on column type. Reset by each call to generateCuts(). More... | |
const CoinPackedMatrix * | byRow |
Pointer on matrix of coefficient ordered by rows. More... | |
Friends | |
void | CglRedSplitUnitTest (const OsiSolverInterface *siP, const std::string mpdDir) |
A function that tests the methods in the CglRedSplit class. More... | |
Additional Inherited Members | |
![]() | |
int | aggressive_ |
Aggressiveness - 0 = neutral, 100 is normal root node. More... | |
bool | canDoGlobalCuts_ |
True if can do global cuts i.e. no general integers. More... | |
Gomory Reduce-and-Split Cut Generator Class; See method generateCuts().
Based on the paper by K. Anderson, G. Cornuejols, Yanjun Li, "Reduce-and-Split Cuts: Improving the Performance of Mixed Integer Gomory Cuts", Management Science 51 (2005).
Definition at line 26 of file CglRedSplit.hpp.
CglRedSplit::CglRedSplit | ( | ) |
Default constructor.
CglRedSplit::CglRedSplit | ( | const CglRedSplitParam & | RS_param | ) |
Constructor with specified parameters.
CglRedSplit::CglRedSplit | ( | const CglRedSplit & | ) |
Copy constructor.
|
virtual |
Destructor.
|
virtual |
Generate Reduce-and-Split Mixed Integer Gomory cuts for the model of the solver interface si.
Insert the generated cuts into OsiCuts cs.
Warning: This generator currently works only with the Lp solvers Clp or Cplex9.0 or higher. It requires access to the optimal tableau and optimal basis inverse and makes assumptions on the way slack variables are added by the solver. The Osi implementations for Clp and Cplex verify these assumptions.
When calling the generator, the solver interface si must contain an optimized problem and information related to the optimal basis must be available through the OsiSolverInterface methods (si->optimalBasisIsAvailable() must return 'true'). It is also essential that the integrality of structural variable i can be obtained using si->isInteger(i).
Reduce-and-Split cuts are variants of Gomory cuts: Starting from the current optimal tableau, linear combinations of the rows of the current optimal simplex tableau are used for generating Gomory cuts. The choice of the linear combinations is driven by the objective of reducing the coefficients of the non basic continuous variables in the resulting row. Note that this generator might not be able to generate cuts for some solutions violating integrality constraints.
Implements CglCutGenerator.
|
virtual |
Return true if needs optimal basis to do cuts (will return true)
Reimplemented from CglCutGenerator.
void CglRedSplit::setParam | ( | const CglRedSplitParam & | source | ) |
Set given_optsol to the given optimal solution given_sol.
If given_optsol is set using this method, the code will stop as soon as a generated cut is violated by the given solution; exclusively for debugging purposes.
|
inline |
Set given_optsol to the given optimal solution given_sol.
If given_optsol is set using this method, the code will stop as soon as a generated cut is violated by the given solution; exclusively for debugging purposes.
Definition at line 75 of file CglRedSplit.hpp.
void CglRedSplit::compute_is_lub | ( | ) |
Set given_optsol to the given optimal solution given_sol.
If given_optsol is set using this method, the code will stop as soon as a generated cut is violated by the given solution; exclusively for debugging purposes.
void CglRedSplit::compute_is_integer | ( | ) |
Set given_optsol to the given optimal solution given_sol.
If given_optsol is set using this method, the code will stop as soon as a generated cut is violated by the given solution; exclusively for debugging purposes.
void CglRedSplit::set_given_optsol | ( | const double * | given_sol, |
const int | card_sol | ||
) |
Set given_optsol to the given optimal solution given_sol.
If given_optsol is set using this method, the code will stop as soon as a generated cut is violated by the given solution; exclusively for debugging purposes.
void CglRedSplit::print | ( | ) | const |
Print some of the data members.
void CglRedSplit::printOptTab | ( | OsiSolverInterface * | solver | ) | const |
Print the current simplex tableau.
void CglRedSplit::setLimit | ( | int | limit | ) |
Set limit, the maximum number of non zero coefficients in generated cut; Default: 50.
int CglRedSplit::getLimit | ( | ) | const |
Get value of limit.
void CglRedSplit::setAway | ( | double | value | ) |
Set away, the minimum distance from being integer used for selecting rows for cut generation; all rows whose pivot variable should be integer but is more than away from integrality will be selected; Default: 0.05.
double CglRedSplit::getAway | ( | ) | const |
Get value of away.
void CglRedSplit::setLUB | ( | double | value | ) |
Set the value of LUB, value considered large for the absolute value of a lower or upper bound on a variable; Default: 1000.
double CglRedSplit::getLUB | ( | ) | const |
Get the value of LUB.
void CglRedSplit::setEPS | ( | double | value | ) |
Set the value of EPS, epsilon for double computations; Default: 1e-7.
double CglRedSplit::getEPS | ( | ) | const |
Get the value of EPS.
void CglRedSplit::setEPS_COEFF | ( | double | value | ) |
Set the value of EPS_COEFF, epsilon for values of coefficients; Default: 1e-8.
double CglRedSplit::getEPS_COEFF | ( | ) | const |
Get the value of EPS_COEFF.
void CglRedSplit::setEPS_COEFF_LUB | ( | double | value | ) |
Set the value of EPS_COEFF_LUB, epsilon for values of coefficients for variables with absolute value of lower or upper bound larger than LUB; Default: 1e-13.
double CglRedSplit::getEPS_COEFF_LUB | ( | ) | const |
Get the value of EPS_COEFF_LUB.
void CglRedSplit::setEPS_RELAX | ( | double | value | ) |
Set the value of EPS_RELAX, value used for relaxing the right hand side of each generated cut; Default: 1e-8.
double CglRedSplit::getEPS_RELAX | ( | ) | const |
Get the value of EPS_RELAX.
void CglRedSplit::setNormIsZero | ( | double | value | ) |
Set the value of normIsZero, the threshold for considering a norm to be 0; Default: 1e-5.
double CglRedSplit::getNormIsZero | ( | ) | const |
Get the value of normIsZero.
void CglRedSplit::setMinReduc | ( | double | value | ) |
Set the value of minReduc, threshold for relative norm improvement for performing a reduction; Default: 0.05.
double CglRedSplit::getMinReduc | ( | ) | const |
Get the value of minReduc.
void CglRedSplit::setMaxTab | ( | double | value | ) |
Set the maximum allowed value for (mTab * mTab * CoinMax(mTab, nTab)) where mTab is the number of rows used in the combinations and nTab is the number of continuous non basic variables.
The work of the generator is proportional to (mTab * mTab * CoinMax(mTab, nTab)). Reducing the value of maxTab makes the generator faster, but weaker. Default: 1e7.
double CglRedSplit::getMaxTab | ( | ) | const |
Get the value of maxTab.
|
virtual |
Clone.
Implements CglCutGenerator.
CglRedSplit& CglRedSplit::operator= | ( | const CglRedSplit & | rhs | ) |
Assignment operator.
|
virtual |
Create C++ lines to get to current state.
Reimplemented from CglCutGenerator.
Compute the fractional part of value, allowing for small error.
|
inlineprivate |
Compute the fractional part of value, allowing for small error.
|
private |
Perform row r1 of pi := row r1 of pi - step * row r2 of pi.
|
private |
Perform row r1 of tab := row r1 of tab - step * row r2 of tab.
|
private |
Find optimal integer step for changing row r1 by adding to it a multiple of another row r2.
|
private |
Test if an ordered pair of rows yields a reduction.
Perform the reduction if it is acceptable.
|
private |
Reduce rows of contNonBasicTab.
|
private |
Generate a row of the current LP tableau.
|
private |
Generate a mixed integer Chvatal-Gomory cut, when all non basic variables are non negative and at their lower bound.
|
private |
Generate a mixed integer Chvatal-Gomory cut, when all non basic variables are non negative and at their lower bound (different formula)
|
private |
Use multiples of the initial inequalities to cancel out the coefficients of the slack variables.
|
private |
Change the sign of the coefficients of the continuous non basic variables at their upper bound.
|
private |
Change the sign of the coefficients of the continuous non basic variables at their upper bound and do the translations restoring the original bounds.
Modify the right hand side accordingly.
|
private |
Return the scale factor for the row.
Compute max_coeff: maximum absolute value of the coefficients. Compute min_coeff: minimum absolute value of the coefficients larger than EPS_COEFF. Return -1 if max_coeff < EPS_COEFF or if max_coeff/min_coeff > MAXDYN or MAXDYN_LUB (depending if the row has a non zero coeff. for a variable with large lower/upper bound)
|
private |
Generate the packed cut from the row representation.
|
private |
Check that the generated cuts do not cut a given optimal solution.
|
private |
Check that the generated cuts do not cut a given optimal solution.
|
private |
Compute the fractional part of value, allowing for small error.
|
private |
Compute the fractional part of value, allowing for small error.
|
private |
Compute the fractional part of value, allowing for small error.
|
friend |
A function that tests the methods in the CglRedSplit class.
The only reason for it not to be a member method is that this way it doesn't have to be compiled into the library. And that's a gain, because the library should be compiled with optimization on, but this method should be compiled with debugging.
|
private |
Object with CglRedSplitParam members.
Definition at line 311 of file CglRedSplit.hpp.
|
private |
Number of rows ( = number of slack variables) in the current LP.
Definition at line 314 of file CglRedSplit.hpp.
|
private |
Number of structural variables in the current LP.
Definition at line 317 of file CglRedSplit.hpp.
|
private |
Lower bounds for structural variables.
Definition at line 320 of file CglRedSplit.hpp.
|
private |
Upper bounds for structural variables.
Definition at line 323 of file CglRedSplit.hpp.
|
private |
Lower bounds for constraints.
Definition at line 326 of file CglRedSplit.hpp.
|
private |
Upper bounds for constraints.
Definition at line 329 of file CglRedSplit.hpp.
|
private |
Righ hand side for constraints (upper bound for ranged constraints).
Definition at line 332 of file CglRedSplit.hpp.
|
private |
Number of integer basic structural variables that are fractional in the current lp solution (at least param.away_ from being integer).
Definition at line 336 of file CglRedSplit.hpp.
|
private |
Number of integer non basic structural variables in the current lp solution.
Definition at line 340 of file CglRedSplit.hpp.
|
private |
Number of continuous non basic variables (structural or slack) in the current lp solution.
Definition at line 344 of file CglRedSplit.hpp.
|
private |
Number of non basic variables (structural or slack) at their upper bound in the current lp solution.
Definition at line 348 of file CglRedSplit.hpp.
|
private |
Number of non basic variables (structural or slack) at their lower bound in the current lp solution.
Definition at line 352 of file CglRedSplit.hpp.
|
private |
Characteristic vector for integer basic structural variables with non integer value in the current lp solution.
Definition at line 356 of file CglRedSplit.hpp.
|
private |
List of integer structural basic variables (in order of pivot in selected rows for cut generation).
Definition at line 360 of file CglRedSplit.hpp.
|
private |
List of integer structural non basic variables.
Definition at line 363 of file CglRedSplit.hpp.
|
private |
List of continuous non basic variables (structural or slack).
Definition at line 367 of file CglRedSplit.hpp.
|
private |
List of non basic variables (structural or slack) at their upper bound.
Definition at line 371 of file CglRedSplit.hpp.
|
private |
List of non basic variables (structural or slack) at their lower bound.
Definition at line 375 of file CglRedSplit.hpp.
|
private |
Number of rows in the reduced tableau (= card_intBasicVar_frac).
Definition at line 378 of file CglRedSplit.hpp.
|
private |
Number of columns in the reduced tableau (= card_contNonBasicVar)
Definition at line 381 of file CglRedSplit.hpp.
|
private |
Tableau of multipliers used to alter the rows used in generation.
Dimensions: mTab by mTab. Initially, pi_mat is the identity matrix.
Definition at line 385 of file CglRedSplit.hpp.
|
private |
Current tableau for continuous non basic variables (structural or slack).
Only rows used for generation. Dimensions: mTab by nTab.
Definition at line 390 of file CglRedSplit.hpp.
|
private |
Current tableau for integer non basic structural variables.
Only rows used for generation.
Definition at line 395 of file CglRedSplit.hpp.
|
private |
Right hand side of the tableau.
Only rows used for generation.
Definition at line 399 of file CglRedSplit.hpp.
|
private |
Given optimal solution that should not be cut; only for debug.
Definition at line 402 of file CglRedSplit.hpp.
|
private |
Number of entries in given_optsol.
Definition at line 405 of file CglRedSplit.hpp.
|
private |
Characteristic vectors of structural integer variables or continuous variables currently fixed to integer values.
Definition at line 409 of file CglRedSplit.hpp.
|
private |
Characteristic vector of the structural variables whose lower bound in absolute value is larger than LUB.
Definition at line 413 of file CglRedSplit.hpp.
|
private |
Characteristic vector of the structural variables whose upper bound in absolute value is larger than LUB.
Definition at line 417 of file CglRedSplit.hpp.
|
private |
Pointer on solver. Reset by each call to generateCuts().
Definition at line 420 of file CglRedSplit.hpp.
|
private |
Pointer on point to separate. Reset by each call to generateCuts().
Definition at line 423 of file CglRedSplit.hpp.
|
private |
Pointer on row activity. Reset by each call to generateCuts().
Definition at line 426 of file CglRedSplit.hpp.
|
private |
Pointer on column type. Reset by each call to generateCuts().
Definition at line 429 of file CglRedSplit.hpp.
|
private |
Pointer on matrix of coefficient ordered by rows.
Reset by each call to generateCuts().
Definition at line 433 of file CglRedSplit.hpp.