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,
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 302 #define DGG_GOMORY_THRESH 0.005 304 #define DGG_RHS_THRESH 0.005 310 #define DGG_BOUND_THRESH 1.0e-6 314 #define DGG_EQUALITY_THRESH 1.0e-5 318 #define DGG_SHIFT_THRESH 1.0e-6 323 #define DGG_INTEGRALITY_THRESH 1.0e-10 327 #define CBC_CHECK_CUT 328 #ifndef CBC_CHECK_CUT 329 #define DGG_MIN_TABLEAU_COEFFICIENT 1.0e-8 331 #define DGG_MIN_TABLEAU_COEFFICIENT 1.0e-12 336 #define DGG_MIN_RHO 1.0e-7 337 #define DGG_MIN_ALPHA 1.0e-7 340 #define DGG_NULL_SLACK 1.0e-5 343 #define DGG_NICEFY_MIN_ABSVALUE 1.0e-13 344 #define DGG_NICEFY_MIN_FIX 1.0e-7 345 #define DGG_NICEFY_MAX_PADDING 1.0e-6 346 #define DGG_NICEFY_MAX_RATIO 1.0e9 350 #if DGG_TRACE_ERRORS > 0 352 #define __DGG_PRINT_LOC__(F) fprintf(((F==0)?stdout:F), " in %s (%s:%d)\n", __func__, __FILE__, __LINE__) 354 #define DGG_THROW(A,REST...) {\ 355 fprintf(stdout, ##REST); \ 356 __DGG_PRINT_LOC__(stdout); \ 359 #define DGG_IF_EXIT(A,B,REST...) {\ 361 fprintf(stdout, ##REST); \ 362 __DGG_PRINT_LOC__(stdout); \ 365 #define DGG_CHECKRVAL(A,B) {\ 367 __DGG_PRINT_LOC__(stdout); \ 370 #define DGG_CHECKRVAL1(A,B) {\ 372 __DGG_PRINT_LOC__(stdout); \ 373 rval = B; goto CLEANUP; } } 375 #define DGG_WARNING(A, REST...) {\ 377 fprintf(stdout, ##REST); \ 378 __DGG_PRINT_LOC__(stdout); \ 381 #define DGG_TEST(A,B,REST...) {\ 382 if(A) DGG_THROW(B,##REST) } 384 #define DGG_TEST2(A,B,C,REST) {DGG_TEST(A,B,C,REST) } 385 #define DGG_TEST3(A,B,C,D,REST) {DGG_TEST(A,B,C,D,REST) } 389 #define DGG_IF_EXIT(A,B,REST) {if(A) {fprintf(stdout, REST);exit(B);}} 391 #define DGG_THROW(A,B) return(A) 393 #define DGG_CHECKRVAL(A,B) { if(A) return(B); } 394 #define DGG_CHECKRVAL1(A,B){ if(A) { rval = B; goto CLEANUP; } } 396 #define DGG_TEST(A,B,REST) { if(A) return(B);} 397 #define DGG_TEST2(A,B,REST,C) { DGG_TEST(A,B,REST) } 398 #define DGG_TEST3(A,B,REST,C,D) { DGG_TEST(A,B,REST) } 404 #define DGG_MIN(a,b) ( (a<b)?a:b ) 405 #define DGG_MAX(a,b) ( (a>b)?a:b ) 406 #define KREM(vht,alpha,tau) (DGG_MIN( ceil(vht / alpha), tau ) - 1) 407 #define LMIN(vht, d, bht) (DGG_MIN( floor(d*bht/bht), d)) 408 #define ABOV(v) (v - floor(v)) 409 #define QINT(vht,bht,tau) ( (int)floor( (vht*(tau-1))/bht ) ) 410 #define V2I(bht,tau,i) ( ((i+1)*bht / tau) ) 412 int DGG_is_even(
double vht,
double bht,
int tau,
int q);
474 const void *solver_ptr,
479 const void *solver_ptr,
482 const int * colIsBasic,
483 const int * rowIsBasic,
484 CoinFactorization & factorization,
491 const void *solver_ptr );
495 const void *solver_ptr,
497 CoinThreadRandom & generator);
504 const void *solver_ptr,
505 CoinThreadRandom & generator);
510 const void *solver_ptr );
557 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 a_max_
q_max - last value of t to use for 2-Step tMIR inequalities
int t_max_
t_min - first value of t to use for tMIR inequalities
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
double awayAtRoot_
Only investigate if more than this away from integrality (at root)
void DGG_list_init(DGG_list_t *l)
int DGG_unTransformConstraint(DGG_data_t *data, DGG_constraint_t *constraint)
double away_
Only investigate if more than this away from integrality.
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 max_elements_root_
Maximum number of elements in cut.
int DGG_cutsOffPoint(double *x, DGG_constraint_t *cut)
CoinThreadRandom randomNumberGenerator_
Threadsafe random number generator.
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 q_min_
t_max - last value of t to use for tMIR inequalities
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)
int q_max_
q_min - first value of t to use for 2-Step tMIR inequalities
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 CglTwomirUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglTwomir class.
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 twomirType_
Type - 0 normal, 1 add original matrix one, 2 replace.
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)
int form_nrows_
Maximum number of elements in cut at root.
int max_elements_
a_max - maximum value of bhat/alpha
virtual bool needsOptimalBasis() const
Return true if needs optimal basis to do cuts (will return true)
OsiSolverInterface * originalSolver_
Original solver.
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.