Loading...
Searching...
No Matches
score_strong.cpp
Go to the documentation of this file.
34/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
54#define DEFAULT_STRONGTIMELIMIT 30. /**< timelimit for strong decompotition score calculation per partialdec */
55#define DEFAULT_DUALVALRANDOMMETHOD 1 /**< default value for method to dual initialization of dual values for strong decomposition: 1) naive, 2) expected equal, 3) expected overestimation */
56#define DEFAULT_COEFFACTORORIGVSRANDOM 0.5 /**< default value for convex coefficient for orig dual val (1-this coef is factor for random dual value) */
58#define DEFAULT_SCORECOEF_FASTBENEFICIAL 1. /**< coefficient for fast & beneficial in strong decomposition score computation */
59#define DEFAULT_SCORECOEF_MEDIUMBENEFICIAL 0.75 /**< coefficient for not fast but beneficial in strong decomposition score computation */
60#define DEFAULT_SCORECOEF_FASTNOTBENEFICIAL 0.3 /**< coefficient for fast & not beneficial in strong decomposition score computation */
61#define DEFAULT_SCORECOEF_MEDIUMNOTBENEFICIAL 0.1 /**< coefficient for not & not beneficial in strong decomposition score computation */
69 std::vector<SCIP_Real>* dualvalsrandom; /**< vector of random dual values, used for strong detection scores */
70 std::vector<SCIP_Real>* dualvalsoptimaloriglp; /**< vector of dual values of the optimal solved original lp, used for strong detection scores */
71 int strongdetectiondualvalrandommethod; /**< method to dual initialization of dual values for strong decomposition: 1) naive, 2) expected equal, 3) expected overestimation */
72 SCIP_Real coeffactororigvsrandom; /**< convex coefficient for orig dual val (1-this coef is factor for random dual value) */
73 SCIP_Bool dualvalsoptimaloriglpcalculated; /**< are the optimal dual values from original lp calulated? used for strong detection scores */
74 SCIP_Bool dualvalsrandomset; /**< are the random dual values set, used for strong detection scores */
75 SCIP_Real strongtimelimit; /**< timelimit for calculating strong decomposition score for one partialdec */
78// TODO ref add comments! this is used in strong decomposition score calculation in @see shuffleDualvalsRandom()
94 * @brief method that shuffles randomly and set dual variable values, used for strong detection score
122 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "set dual val random method to %d. \n", method );
131 gcg::DETPROBDATA* detprobdata = (transformed) ? GCGconshdlrDecompGetDetprobdataPresolved(gcg) : GCGconshdlrDecompGetDetprobdataOrig(gcg);
177 else if( usedmethod == GCG_RANDOM_DUAL_EXPECTED_EQUAL || usedmethod == GCG_RANDOM_DUAL_EXPECTED_OVERESTIMATE )
258 * @brief return the a random value of the dual variable of the corresponding ; if it is not calculated yet it will be calculated
279 * @brief method to calculate and set the optimal dual values from original lp, used for strong detection score
298 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "started calculating optimal dual values for original lp\n");
349 gcg::DETPROBDATA* detprobdata = (transformed) ? GCGconshdlrDecompGetDetprobdataPresolved(gcg) : GCGconshdlrDecompGetDetprobdataOrig(gcg);
365 SCIPwarningMessage(scip, "Could not find constraint for random dual variable initialization when calculating strong decomposition score; skipping cons: %s \n", SCIPconsGetName(cons));
381 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "optimal dual sol of constraint %s is %f \n", SCIPconsGetName(cons), (*scoredata->dualvalsoptimaloriglp)[c]);
384 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "finished calculating optimal dual values for original lp, start freeing\n");
395 * @brief returns the value of the optimal lp relaxation dual value of the given constrainr rid correspondoning problem of the detprobdata; if it is not calculated yet it will be calculated
396 * @returns the value of the optimal lp relaxation dual value of the given constraint rid correspondoning problem of the detprobdata
422 SCIP_Real infinity, /**< values larger than this are considered infinity in the pricing problem */
423 SCIP_Real epsilon, /**< absolute values smaller than this are considered zero in the pricing problem */
424 SCIP_Real sumepsilon, /**< absolute values of sums smaller than this are considered zero in the pricing problem */
426 SCIP_Real lpfeastolfactor, /**< primal feasibility tolerance factor of LP solver in the pricing problem */
427 SCIP_Real dualfeastol, /**< feasibility tolerance for reduced costs in LP solution in the pricing problem */
434 GCGsetPricingProblemParameters(GCG_DECTYPE_UNKNOWN, scip, clocktype, infinity, epsilon, sumepsilon, feastol, lpfeastolfactor,
451 SCIP_HASHMAP* hashorig2pricingvar /**< hashmap mapping original to corresponding pricing variables */
464 SCIP_CALL( SCIPhashmapCreate(&hashorig2pricingconstmp, SCIPblkmem(scip), detprobdata->getNConss() ) ); /*lint !e613*/
547 /** @todo use and introduce scip parameter limit (for a pricing problem to be considered fractional solvable) of difference optimal value of LP-Relaxation and optimal value of artificial pricing problem */
550 /** @todo use and introduce scip parameter weighted limit (for a pricing problem to be considered fractional solvable) difference optimal value of LP-Relaxation and optimal value of artificial pricing problem */
579 SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, NULL, " \n Attention! Strong decomposition score is not implemented for decomps belonging to the original problem \n\n");
588 /* get numerical tolerances of the original SCIP instance in order to use the same numerical tolerances in master and pricing problems */
593 SCIP_CALL( SCIPgetRealParam(scip, "numerics/lpfeastolfactor", &lpfeastolfactor) ); // changed from "numerics/lpfeastol"
596 /* get clocktype of the original SCIP instance in order to use the same clocktype in master and pricing problems */
610 /* for every pricing problem calculate a corresponding score coeff and break if a pricing problem cannot be solved in the timelimit */
627 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "started calculate strong decomposition subproblem for block %d \n", block );
631 SCIP_CALL( SCIPhashmapCreate(&hashpricingvartoindex, SCIPblkmem(scip), SCIPgetNVars(scip)) ); /*lint !e613*/
632 SCIP_CALL( SCIPhashmapCreate(&hashorig2pricingvar, SCIPblkmem(scip), SCIPgetNVars(scip)) ); /*lint !e613*/
644 SCIP_CALL( setTestpricingProblemParameters(subscip, clocktype, infinity, epsilon, sumepsilon, feastol, lpfeastolfactor, dualfeastol, enableppcuts, scoredata->strongtimelimit) );
649 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "started calculate strong decomposition, timelimit: %f timelimitfast: %f \n", scoredata->strongtimelimit, timelimitfast );
684 dualval = dualvalmethodcoef * getDualvalOptimalLP(gcg, score, consid, partialdec->isAssignedToOrigProb()) + (1. - dualvalmethodcoef) * getDualvalRandom(gcg, score, consid, partialdec->isAssignedToOrigProb());
707 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "started solving subproblem for block %d \n", block );
709 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "finished solving subproblem in %f seconds \n", SCIPgetSolvingTime(subscip) );
722 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "Hit timelimit in pricing problem %d \n.", block);
737 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "first dual bound: %f ; dual bound end: %f \n",SCIPgetFirstLPLowerboundRoot(subscip), SCIPgetDualbound(subscip) );
754 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "scorecoef for subproblem %d is %f with weighting factor %f\n", block, score_coef, weight_subproblem );
801 "Timelimit for strong decompositions score calculation per partialdec in seconds", &scoredata->strongtimelimit, FALSE,
805 "Method for random dual values use for strong decomposition: 1: naive, 2: expected equality exponential distributed, 3: expected overestimation exponential distributed ",
810 "Convex coefficient for orig dual val, i.e. (1-this coef) is factor for random dual value", &scoredata->coeffactororigvsrandom, FALSE,
class storing partialdecs and the problem matrix
class storing (potentially incomplete) decompositions
Definition class_detprobdata.h:110
GCG_EXPORT std::vector< int > & getConssForVar(int varIndex)
returns the constraint indices of the coefficient matrix for a variable
Definition class_detprobdata.cpp:762
GCG_EXPORT int getNConss()
returns the number of variables considered in the detprobdata
Definition class_detprobdata.cpp:850
GCG_EXPORT int getNConssForVar(int varIndex)
returns the number of constraints for a given variable where the var has a nonzero entry in
Definition class_detprobdata.cpp:864
GCG_EXPORT SCIP_VAR * getVar(int varIndex)
returns SCIP variable related to a variable index
Definition class_detprobdata.cpp:1015
GCG_EXPORT SCIP_Real getVal(int row, int col)
returns a coefficient from the coefficient matrix
Definition class_detprobdata.cpp:976
GCG_EXPORT SCIP_CONS * getCons(int consIndex)
returns the SCIP constraint related to a constraint index
Definition class_detprobdata.cpp:746
GCG_EXPORT bool isConsMastercons(int cons)
Gets whether the cons is a master cons.
Definition class_partialdecomp.cpp:4817
GCG_EXPORT std::vector< int > & getConssForBlock(int block)
returns array containing constraints assigned to a block
Definition class_partialdecomp.cpp:3968
GCG_EXPORT DETPROBDATA * getDetprobdata()
Gets the corresponding detprobdata.
Definition class_partialdecomp.cpp:4725
GCG_EXPORT int getNVarsForBlock(int block)
Gets size of the vector containing vars assigned to a block.
Definition class_partialdecomp.cpp:4537
GCG_EXPORT bool isAssignedToOrigProb()
Gets whether the partialdec is from the original problem.
Definition class_partialdecomp.cpp:4835
GCG_EXPORT int getNConssForBlock(int block)
Gets size of the vector containing conss assigned to a block.
Definition class_partialdecomp.cpp:4432
GCG_EXPORT std::vector< int > & getVarsForBlock(int block)
Gets array containing vars of a block.
Definition class_partialdecomp.cpp:4771
DETPROBDATA * GCGconshdlrDecompGetDetprobdataPresolved(GCG *gcg)
help method to access detprobdata for transformed problem
Definition cons_decomp.cpp:3976
DETPROBDATA * GCGconshdlrDecompGetDetprobdataOrig(GCG *gcg)
help method to access detprobdata for unpresolved problem
Definition cons_decomp.cpp:3962
PARTIALDECOMP * GCGconshdlrDecompGetPartialdecFromID(GCG *gcg, int partialdecid)
local method to find a partialdec for a given id or NULL if no partialdec with such id is found
Definition cons_decomp.cpp:281
constraint handler for structure detection
C++ interface of cons_decomp.
#define SCIP_MAXSTRLEN
#define SCIP_Bool
#define SCIP_Real
#define ABS(x)
#define MAX(x, y)
#define SCIP_CALL_ABORT(x)
#define TRUE
#define FALSE
#define infinity
SCIP_RETCODE SCIPcopy(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool threadsafe, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
SCIP_RETCODE SCIPgetConsCopy(SCIP *sourcescip, SCIP *targetscip, SCIP_CONS *sourcecons, SCIP_CONS **targetcons, SCIP_CONSHDLR *sourceconshdlr, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *name, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode, SCIP_Bool global, SCIP_Bool *valid)
SCIP_RETCODE SCIPfree(SCIP **scip)
SCIP_RETCODE SCIPcreate(SCIP **scip)
SCIP_STATUS SCIPgetStatus(SCIP *scip)
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
int SCIPgetNVars(SCIP *scip)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNConss(SCIP *scip)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
SCIP_RETCODE SCIPcreateProb(SCIP *scip, const char *name, SCIP_DECL_PROBDELORIG((*probdelorig)), SCIP_DECL_PROBTRANS((*probtrans)), SCIP_DECL_PROBDELTRANS((*probdeltrans)), SCIP_DECL_PROBINITSOL((*probinitsol)), SCIP_DECL_PROBEXITSOL((*probexitsol)), SCIP_DECL_PROBCOPY((*probcopy)), SCIP_PROBDATA *probdata)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
SCIP_RETCODE SCIPhashmapSetImage(SCIP_HASHMAP *hashmap, void *origin, void *image)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
SCIP_RETCODE GCGconsGetVars(SCIP *scip, SCIP_CONS *cons, SCIP_VAR **vars, int nvars)
Definition scip_misc.c:487
SCIP_RETCODE GCGconsGetVals(SCIP *scip, SCIP_CONS *cons, SCIP_Real *vals, int nvals)
Definition scip_misc.c:618
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
SCIP_RETCODE SCIPgetIntParam(SCIP *scip, const char *name, int *value)
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
const char * SCIPconsGetName(SCIP_CONS *cons)
SCIP_RETCODE SCIPgetTransformedCons(SCIP *scip, SCIP_CONS *cons, SCIP_CONS **transcons)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPallocMemory(scip, ptr)
#define SCIPfreeBufferArrayNull(scip, ptr)
GCG_EXPORT SCIP_RETCODE GCGincludeScore(GCG *gcg, const char *name, const char *shortname, const char *description, GCG_SCOREDATA *scoredata, GCG_DECL_SCOREFREE((*scorefree)),)
creates a score and includes it in GCG
Definition score.c:50
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
SCIP_RETCODE SCIPsolve(SCIP *scip)
SCIP_Real SCIPgetDualbound(SCIP *scip)
SCIP_Real SCIPgetFirstLPLowerboundRoot(SCIP *scip)
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIP_RETCODE SCIPchgVarType(SCIP *scip, SCIP_VAR *var, SCIP_VARTYPE vartype, SCIP_Bool *infeasible)
SCIP_RETCODE SCIPchgVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_RETCODE SCIPcreateVar(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_Real SCIPrandomGetReal(SCIP_RANDNUMGEN *randnumgen, SCIP_Real minrandval, SCIP_Real maxrandval)
SCIP_RETCODE SCIPcreateRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen, unsigned int initialseed, SCIP_Bool useglobalseed)
int SCIPsnprintf(char *t, int len, const char *s,...)
SCIPfreeMemory(GCGgetOrigprob(gcg), &divingdata)
static assert(heur !=NULL)
SCIP_CALL(SCIPgetExternBranchCands(origprob, &lpcands, &lpcandssol, NULL, &nlpcands, NULL, NULL, NULL, NULL))
SCIPdebugMessage("feasibility pump finished [%d iterations done].\n", nloops)
#define NULL
Definition class_conspartition.cpp:44
SCIP_RETCODE GCGsetPricingProblemParameters(GCG_DECTYPE dectype, SCIP *pricingprob, int clocktype, SCIP_Real infinity, SCIP_Real epsilon, SCIP_Real sumepsilon, SCIP_Real feastol, SCIP_Real lpfeastolfactor, SCIP_Real dualfeastol, SCIP_Bool enableppcuts)
Definition relax_gcg.c:865
various SCIP helper methods
SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
internal methods for scores
#define DEFAULT_SCORECOEF_FASTBENEFICIAL
Definition score_strong.cpp:58
#define DEFAULT_SCORECOEF_MEDIUMNOTBENEFICIAL
Definition score_strong.cpp:61
SCIP_RETCODE GCGincludeScoreStrongDecomp(GCG *gcg)
Definition score_strong.cpp:781
static SCIP_RETCODE createTestPricingprobConss(SCIP *scip, SCIP *subscip, gcg::PARTIALDECOMP *partialdec, int block, SCIP_HASHMAP *hashorig2pricingvar)
creates the pricing problem constraints
Definition score_strong.cpp:446
enum GCG_Random_dual_methods GCG_RANDOM_DUAL_METHOD
Definition score_strong.cpp:85
static SCIP_Real getDualvalRandom(GCG *gcg, GCG_SCORE *score, int consindex, SCIP_Bool transformed)
return the a random value of the dual variable of the corresponding ; if it is not calculated yet it ...
Definition score_strong.cpp:262
#define DEFAULT_SCORECOEF_FASTNOTBENEFICIAL
Definition score_strong.cpp:60
static SCIP_RETCODE calculateDualvalsOptimalOrigLP(GCG *gcg, GCG_SCORE *score, SCIP_Bool transformed)
method to calculate and set the optimal dual values from original lp, used for strong detection score
Definition score_strong.cpp:283
static SCIP_RETCODE shuffleDualvalsRandom(GCG *gcg, GCG_SCORE *score, SCIP_Bool transformed)
method that shuffles randomly and set dual variable values, used for strong detection score
Definition score_strong.cpp:98
#define DEFAULT_SCORECOEF_MEDIUMBENEFICIAL
Definition score_strong.cpp:59
static SCIP_RETCODE setTestpricingProblemParameters(SCIP *scip, int clocktype, SCIP_Real infinity, SCIP_Real epsilon, SCIP_Real sumepsilon, SCIP_Real feastol, SCIP_Real lpfeastolfactor, SCIP_Real dualfeastol, SCIP_Bool enableppcuts, SCIP_Real timelimit)
sets the pricing problem parameters
Definition score_strong.cpp:419
@ GCG_RANDOM_DUAL_EXPECTED_OVERESTIMATE
Definition score_strong.cpp:83
static SCIP_Real getDualvalOptimalLP(GCG *gcg, GCG_SCORE *score, int consindex, SCIP_Bool transformed)
returns the value of the optimal lp relaxation dual value of the given constrainr rid correspondoning...
Definition score_strong.cpp:399
strong score
Definition score_bender.cpp:52
std::vector< SCIP_Real > * dualvalsoptimaloriglp
Definition score_strong.cpp:70
std::vector< SCIP_Real > * dualvalsrandom
Definition score_strong.cpp:69
int strongdetectiondualvalrandommethod
Definition score_strong.cpp:71
SCIP_Bool dualvalsoptimaloriglpcalculated
Definition score_strong.cpp:73
struct SCIP_Cons SCIP_CONS
SCIP_VERBLEVEL_MINIMAL
SCIP_VERBLEVEL_HIGH
SCIP_VERBLEVEL_FULL
struct SCIP_HashMap SCIP_HASHMAP
struct SCIP_RandNumGen SCIP_RANDNUMGEN
SCIP_OBJSENSE_MAXIMIZE
SCIP_OBJSENSE_MINIMIZE
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
SCIP_STATUS_OPTIMAL
SCIP_STATUS_TIMELIMIT
struct SCIP_Var SCIP_VAR
SCIP_VARTYPE_CONTINUOUS
SCIP_VARTYPE_BINARY