11 #include "CoinFactorization.hpp" 71 #define DGG_isBasic(data,idx) ((data->info[idx])&1) 72 #define DGG_isInteger(data,idx) ((data->info[idx] >> 1)&1) 73 #define DGG_isStructural(data,idx) ((data->info[idx] >> 2)&1) 74 #define DGG_isEqualityConstraint(data,idx) ((data->info[idx] >> 3)&1) 75 #define DGG_isNonBasicAtUB(data,idx) ((data->info[idx] >> 4)&1) 76 #define DGG_isNonBasicAtLB(data,idx) ((data->info[idx] >> 5)&1) 77 #define DGG_isConstraintBoundedAbove(data,idx) ((data->info[idx] >> 6)&1) 78 #define DGG_isConstraintBoundedBelow(data,idx) ((data->info[idx] >> 7)&1) 80 #define DGG_setIsBasic(data,idx) ((data->info[idx]) |= 1) 81 #define DGG_setIsInteger(data,idx) ((data->info[idx]) |= (1<<1)) 82 #define DGG_setIsStructural(data,idx) ((data->info[idx]) |= (1<<2)) 83 #define DGG_setEqualityConstraint(data,idx) ((data->info[idx]) |= (1<<3)) 84 #define DGG_setIsNonBasicAtUB(data,idx) ((data->info[idx]) |= (1<<4)) 85 #define DGG_setIsNonBasicAtLB(data,idx) ((data->info[idx]) |= (1<<5)) 86 #define DGG_setIsConstraintBoundedAbove(data,idx) ((data->info[idx]) |= (1<<6)) 87 #define DGG_setIsConstraintBoundedBelow(data,idx) ((data->info[idx]) |= (1<<7)) 89 class CoinWarmStartBasis;
94 const std::string mpdDir );
107 virtual void generateCuts(
const OsiSolverInterface & si, OsiCuts & cs,
114 void setMirScale (
int tmin,
int tmax) {t_min_ = tmin; t_max_ = tmax;}
121 { do_mir_ = mir; do_2mir_ = twomir; do_tab_ = tab; do_form_ = form;}
152 {
return max_elements_;}
161 {
return originalSolver_;}
167 {
return twomirType_;}
196 CoinThreadRandom randomNumberGenerator_;
199 OsiSolverInterface * originalSolver_;
217 int max_elements_root_;
236 #define DGG_DEBUG_DGG 1 237 #define DGG_TRACE_ERRORS 0 238 #define DGG_DISPLAY 0 239 #define DGG_AUTO_CHECK_CUT_OFF_OPTIMAL 1 243 #define DGG_DEFAULT_METHOD 2 244 #define DGG_DEFAULT_TMIN 1 245 #define DGG_DEFAULT_TMAX 1 246 #define DGG_DEFAULT_TAUMIN 2 247 #define DGG_DEFAULT_TAUMAX 6 248 #define DGG_DEFAULT_MAX_CUTS 500 249 #define DGG_DEFAULT_IMPROVEMENT_THRESH 0.001 250 #define DGG_DEFAULT_NBELOW_THRESH INT_MAX 251 #define DGG_DEFAULT_NROOT_ROUNDS 2 252 #define DGG_DEFAULT_NEGATIVE_SCALED_TWOSTEPS 0 253 #define DGG_DEFAULT_ALPHA_RULE 0 254 #define DGG_DEFAULT_CUT_INC 250 255 #define DGG_DEFAULT_CUT_FORM 0 256 #define DGG_DEFAULT_NICEFY 0 257 #define DGG_DEFAULT_ONLY_DELAYED 0 258 #define DGG_DEFAULT_DELAYED_FREQ 9999999 259 #define DGG_DEFAULT_LPROWS_FREQ 9999999 260 #define DGG_DEFAULT_WHICH_FORMULATION_CUTS 2 269 #define DGG_SOLVER DGG_OSI 272 #define DGG_DEBUG_SOLVER 0 275 #define DGG_SOLVER_SCREEN_FLAG 0 280 #define DGG_TMIR_CUT 1 281 #define DGG_2STEP_CUT 2 284 #define DGG_ALPHA_MIN_SUM 0 285 #define DGG_ALPHA_RANDOM_01 1 286 #define DGG_ALPHA_RANDOM_COEFF 2 287 #define DGG_ALPHA_ALL 3 288 #define DGG_ALPHA_MAX_STEEP 5 293 #define DGG_MIN_STEEPNESS 1.0e-4 294 #define DGG_MAX_L2NORM 1.0e7 297 #define DGG_NORM_CRITERIA 1 300 #define UB_MAX DBL_MAX 305 #define DGG_GOMORY_THRESH 0.005 307 #define DGG_RHS_THRESH 0.005 313 #define DGG_BOUND_THRESH 1.0e-6 317 #define DGG_EQUALITY_THRESH 1.0e-5 321 #define DGG_SHIFT_THRESH 1.0e-6 326 #define DGG_INTEGRALITY_THRESH 1.0e-10 330 #define CBC_CHECK_CUT 331 #ifndef CBC_CHECK_CUT 332 #define DGG_MIN_TABLEAU_COEFFICIENT 1.0e-8 334 #define DGG_MIN_TABLEAU_COEFFICIENT 1.0e-12 339 #define DGG_MIN_RHO 1.0e-7 340 #define DGG_MIN_ALPHA 1.0e-7 343 #define DGG_NULL_SLACK 1.0e-5 346 #define DGG_NICEFY_MIN_ABSVALUE 1.0e-13 347 #define DGG_NICEFY_MIN_FIX 1.0e-7 348 #define DGG_NICEFY_MAX_PADDING 1.0e-6 349 #define DGG_NICEFY_MAX_RATIO 1.0e9 353 #if DGG_TRACE_ERRORS > 0 355 #define __DGG_PRINT_LOC__(F) fprintf(((F==0)?stdout:F), " in %s (%s:%d)\n", __func__, __FILE__, __LINE__) 357 #define DGG_THROW(A,REST...) {\ 358 fprintf(stdout, ##REST); \ 359 __DGG_PRINT_LOC__(stdout); \ 362 #define DGG_IF_EXIT(A,B,REST...) {\ 364 fprintf(stdout, ##REST); \ 365 __DGG_PRINT_LOC__(stdout); \ 368 #define DGG_CHECKRVAL(A,B) {\ 370 __DGG_PRINT_LOC__(stdout); \ 373 #define DGG_CHECKRVAL1(A,B) {\ 375 __DGG_PRINT_LOC__(stdout); \ 376 rval = B; goto CLEANUP; } } 378 #define DGG_WARNING(A, REST...) {\ 380 fprintf(stdout, ##REST); \ 381 __DGG_PRINT_LOC__(stdout); \ 384 #define DGG_TEST(A,B,REST...) {\ 385 if(A) DGG_THROW(B,##REST) } 387 #define DGG_TEST2(A,B,C,REST) {DGG_TEST(A,B,C,REST) } 388 #define DGG_TEST3(A,B,C,D,REST) {DGG_TEST(A,B,C,D,REST) } 392 #define DGG_IF_EXIT(A,B,REST) {if(A) {fprintf(stdout, REST);exit(B);}} 394 #define DGG_THROW(A,B) return(A) 396 #define DGG_CHECKRVAL(A,B) { if(A) return(B); } 397 #define DGG_CHECKRVAL1(A,B){ if(A) { rval = B; goto CLEANUP; } } 399 #define DGG_TEST(A,B,REST) { if(A) return(B);} 400 #define DGG_TEST2(A,B,REST,C) { DGG_TEST(A,B,REST) } 401 #define DGG_TEST3(A,B,REST,C,D) { DGG_TEST(A,B,REST) } 407 #define DGG_MIN(a,b) ( (a<b)?a:b ) 408 #define DGG_MAX(a,b) ( (a>b)?a:b ) 409 #define KREM(vht,alpha,tau) (DGG_MIN( ceil(vht / alpha), tau ) - 1) 410 #define LMIN(vht, d, bht) (DGG_MIN( floor(d*bht/bht), d)) 411 #define ABOV(v) (v - floor(v)) 412 #define QINT(vht,bht,tau) ( (int)floor( (vht*(tau-1))/bht ) ) 413 #define V2I(bht,tau,i) ( ((i+1)*bht / tau) ) 415 int DGG_is_even(
double vht,
double bht,
int tau,
int q);
477 const void *solver_ptr,
482 const void *solver_ptr,
485 const int * colIsBasic,
486 const int * rowIsBasic,
487 CoinFactorization & factorization,
494 const void *solver_ptr );
498 const void *solver_ptr,
500 CoinThreadRandom & generator);
507 const void *solver_ptr,
508 CoinThreadRandom & generator);
513 const void *solver_ptr );
560 const std::string mpdDir);
int getMaxElements() const
virtual std::string generateCpp(FILE *fp)
Create C++ lines to get to current state.
int DGG_getTableauConstraint(int index, const void *solver_ptr, DGG_data_t *data, DGG_constraint_t *tabrow, const int *colIsBasic, const int *rowIsBasic, CoinFactorization &factorization, int mode)
OsiSolverInterface * originalSolver() const
Returns original solver.
void DGG_scaleConstraint(DGG_constraint_t *c, int t)
int DGG_generateTabRowCuts(DGG_list_t *list, DGG_data_t *data, const void *solver_ptr)
CglTwomir()
Default constructor.
void DGG_freeConstraint(DGG_constraint_t *c)
void setAway(double value)
Set away.
void setMirScale(int tmin, int tmax)
Set.
Information about where the cut generator is invoked from.
int getIfFormulation() const
void DGG_list_init(DGG_list_t *l)
int DGG_unTransformConstraint(DGG_data_t *data, DGG_constraint_t *constraint)
int DGG_generateFormulationCuts(DGG_list_t *list, DGG_data_t *data, const void *solver_ptr, int nrows, CoinThreadRandom &generator)
double getAwayAtRoot() const
Get away at root.
DGG_constraint_t * DGG_getSlackExpression(const void *solver_ptr, DGG_data_t *data, int row_index)
int DGG_addMirToList(DGG_constraint_t *base, char *isint, double *x, DGG_list_t *list, DGG_data_t *data, DGG_constraint_t *orig_base)
std::string probname_
Problem name.
int DGG_cutsOffPoint(double *x, DGG_constraint_t *cut)
virtual ~CglTwomir()
Destructor.
int DGG_is2stepValid(double alpha, double bht)
void DGG_list_free(DGG_list_t *l)
Cut Generator Base Class.
int DGG_freeData(DGG_data_t *data)
int DGG_generateCutsFromBase(DGG_constraint_t *base, DGG_list_t *list, DGG_data_t *data, const void *solver_ptr)
CglTwomir & operator=(const CglTwomir &rhs)
Assignment operator.
int DGG_nicefyConstraint(const void *solver_ptr, DGG_data_t *data, DGG_constraint_t *cut)
virtual int maximumLengthOfCutInTree() const
Return maximum length of cut in tree.
void setCutTypes(bool mir, bool twomir, bool tab, bool form)
int DGG_substituteSlacks(const void *solver_ptr, DGG_data_t *data, DGG_constraint_t *cut)
virtual CglCutGenerator * clone() const
Clone.
double frac_part(double value)
int getMaxElementsRoot() const
int DGG_build2step(double alpha, char *isint, DGG_constraint_t *base, DGG_constraint_t **cut_out)
double DGG_cutLHS(DGG_constraint_t *c, double *x)
void setFormulationRows(int n)
void setTwomirType(int type)
Set type - 0 normal, 1 add original matrix one, 2 replace.
int DGG_add2stepToList(DGG_constraint_t *base, char *isint, double *x, double *rc, DGG_list_t *list, DGG_data_t *data, DGG_constraint_t *orig_base)
friend void CglTwomirUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglTwomir class.
int DGG_getFormulaConstraint(int row_idx, const void *solver_ptr, DGG_data_t *data, DGG_constraint_t *row)
double getAway() const
Get away.
Twostep MIR Cut Generator Class.
int DGG_generateFormulationCutsFromBase(DGG_constraint_t *base, double slack, DGG_list_t *list, DGG_data_t *data, const void *solver_ptr, CoinThreadRandom &generator)
int DGG_isCutDesirable(DGG_constraint_t *c, DGG_data_t *d)
DGG_constraint_t * DGG_copyConstraint(DGG_constraint_t *c)
DGG_constraint_t * DGG_newConstraint(int max_arrays)
void setMaxElementsRoot(int n)
int DGG_isConstraintViolated(DGG_data_t *d, DGG_constraint_t *c)
int DGG_isBaseTrivial(DGG_data_t *d, DGG_constraint_t *c)
DGG_data_t * DGG_getData(const void *solver_ptr)
void setMaxElements(int n)
int DGG_is_even(double vht, double bht, int tau, int q)
int DGG_list_addcut(DGG_list_t *l, DGG_constraint_t *cut, int ctype, double alpha)
void DGG_list_delcut(DGG_list_t *l, int i)
void setAwayAtRoot(double value)
Set away at root.
int DGG_buildMir(char *isint, DGG_constraint_t *base, DGG_constraint_t **cut_out)
void setTwomirScale(int qmin, int qmax)
int twomirType() const
Return type.
int DGG_is_a_multiple_of_b(double a, double b)
void passInOriginalSolver(OsiSolverInterface *solver)
Pass in a copy of original solver (clone it)
virtual bool needsOptimalBasis() const
Return true if needs optimal basis to do cuts (will return true)
virtual void refreshSolver(OsiSolverInterface *solver)
This can be used to refresh any inforamtion.
int DGG_transformConstraint(DGG_data_t *data, double **x_out, double **rc_out, char **isint_out, DGG_constraint_t *constraint)
virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo())
Generate Two step MIR cuts either from the tableau rows or from the formulation rows.