heur_feaspump.c
Go to the documentation of this file.
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 41 #define DEFAULT_MAXLPITERQUOT 0.01 /**< maximal fraction of diving LP iterations compared to node LP iterations */ 43 #define DEFAULT_MAXSOLS 10 /**< total number of feasible solutions found up to which heuristic is called 46 #define DEFAULT_MAXSTALLLOOPS 10 /**< maximal number of pumping rounds without fractionality improvement (-1: no limit) */ 47 #define DEFAULT_MINFLIPS 10 /**< minimum number of random variables to flip, if a 1-cycle is encountered */ 48 #define DEFAULT_CYCLELENGTH 3 /**< maximum length of cycles to be checked explicitly in each round */ 49 #define DEFAULT_PERTURBFREQ 100 /**< number of iterations until a random perturbation is forced */ 50 #define DEFAULT_OBJFACTOR 0.1 /**< factor by which the regard of the objective is decreased in each round, 52 #define DEFAULT_ALPHA 1.0 /**< initial weight of the objective function in the convex combination */ 53 #define DEFAULT_ALPHADIFF 1.0 /**< threshold difference for the convex parameter to perform perturbation */ 54 #define DEFAULT_BEFORECUTS TRUE /**< should the feasibility pump be called at root node before cut separation? */ 55 #define DEFAULT_USEFP20 FALSE /**< should an iterative round-and-propagate scheme be used to find the integral points? */ 56 #define DEFAULT_PERTSOLFOUND TRUE /**< should a random perturbation be performed if a feasible solution was found? */ 57 #define DEFAULT_STAGE3 FALSE /**< should we solve a local branching sub-MIP if no solution could be found? */ 59 #define DEFAULT_COPYCUTS TRUE /**< should all active cuts from the cutpool of the original SCIP be copied to 72 SCIP_Real maxlpiterquot; /**< maximal fraction of diving LP iterations compared to node LP iterations */ 73 SCIP_Real objfactor; /**< factor by which the regard of the objective is decreased in each round, 76 SCIP_Real alphadiff; /**< threshold difference for the convex parameter to perform perturbation */ 82 int maxstallloops; /**< maximal number of pumping rounds without fractionality improvement (-1: no limit) */ 90 SCIP_Bool beforecuts; /**< should the feasibility pump be called at root node before cut separation? */ 91 SCIP_Bool usefp20; /**< should an iterative round-and-propagate scheme be used to find the integral points? */ 92 SCIP_Bool pertsolfound; /**< should a random perturbation be performed if a feasible solution was found? */ 93 SCIP_Bool stage3; /**< should we solve a local branching sub-MIP if no solution could be found? */ 105 SCIP_Bool copycuts, /**< should all active cuts from cutpool of scip copied to constraints in subscip */ 124 SCIP_CALL( SCIPcopy(scip, *probingscip, *varmapfw, NULL, "feaspump", FALSE, FALSE, TRUE, success) ); 141 { 144 SCIPwarningMessage(scip, "unfixing parameter heuristics/" HEUR_NAME "/freq in probingscip of " HEUR_NAME " heuristic to avoid recursive calls\n"); 161 SCIPwarningMessage(scip, "unfixing parameter lp/solvefreq in probingscip of " HEUR_NAME " heuristic to speed up propagation\n"); 200 SCIPwarningMessage(scip,"unfixing parameter heuristics/" HEUR_NAME "/freq in probingscip of " HEUR_NAME " heuristic to avoid recursive calls\n"); 226 if( SCIPfindNodesel(probingscip, "estimate") != NULL && !SCIPisParamFixed(probingscip, "nodeselection/estimate/stdpriority") ) 232 if( SCIPfindBranchrule(probingscip, "inference") != NULL && !SCIPisParamFixed(probingscip, "branching/inference/priority") ) 283 /* if there are already enough candidates and the variable is less fractional, return, else reserve the last entry */ 325 /* just flipping the objective coefficients from +1 to -1 and the rounding from floor to ceil */ 350 /** flips the roundings of randomly chosen fractional variables, preferring highly fractional ones, 370 /* just flipping the objective coefficients from +1 to -1 and the rounding from floor to ceil */ 469 /** creates new solutions for the original problem by copying the solutions of the subproblem */ 494 /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP 495 * since constraint copying may have required the copy of variables that are fixed in the main SCIP 609 /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin) */ 618 /* if the heuristic is called at the root node, we may want to be called directly after the initial root LP solve */ 626 /** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) */ 642 ) 661 SCIP_SOL** lastroundedsols;/* solutions of the last pumping rounds (depending on heurdata->cyclelength) */ 665 SCIP* probingscip; /* copied SCIP structure, used for round-and-propagate loop of feasibility pump 2.0 */ 681 SCIP_Real objfactor; /* factor by which the regard of the objective is decreased in each round, in [0,0.99] */ 682 SCIP_Real alpha; /* factor how the original objective is regarded, used for convex combination of two functions */ 685 SCIP_Real mindistance; /* distance of the closest rounded solution from the LP relaxation: used for stage3 */ 703 int maxflips; /* maximum number of flips, if a 1-cycle is found (depending on heurdata->minflips) */ 705 int nstallloops; /* number of loops without reducing the current best number of factional variables */ 754 /* only call the heuristic before cutting planes if we do not have an incumbent and no pricer exists */ 755 if( heurtiming == SCIP_HEURTIMING_DURINGLPLOOP && SCIPgetNSolsFound(scip) > 0 && SCIPgetNPricers(scip) == 0 ) 763 if( heurdata->maxsols >= 0 && SCIPgetNSolsFound(scip) > heurdata->maxsols && SCIPgetNPricers(scip) == 0 ) 766 /* get all variables of LP and number of fractional variables in LP solution that should be integral */ 777 maxnlpiterations = (SCIP_Longint)((1.0 + 10.0*(nsolsfound+1.0)/(ncalls+1.0)) * heurdata->maxlpiterquot * nlpiterations); 796 SCIPdebugMessage("executing feasibility pump heuristic, nlpiters=%" SCIP_LONGINT_FORMAT ", maxnlpit:%" SCIP_LONGINT_FORMAT ", maxflips:%d \n", 815 * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop. */ 821 SCIPwarningMessage(scip, "Error while solving subproblem in feaspump heuristic; sub-SCIP terminated with code <%d>\n", retcode); 907 && heurdata->nlpiterations < adjustedMaxNLPIterations(maxnlpiterations, nsolsfound, nstallloops) 920 SCIPdebugMessage("feasibility pump loop %d: %d fractional variables (alpha: %.4f, stall: %d/%d)\n", 940 /* randomly choose maximum number of variables to flip in current pumping round in case of a 1-cycle */ 941 maxnflipcands = SCIPgetRandomInt(MIN(nfracs/2+1, heurdata->minflips), MIN(nfracs, maxflips), &heurdata->randseed); 999 SCIPdebugMessage("try to fix variable <%s> (domain [%f,%f] to %f\n",SCIPvarGetName(probingvar), lb, ub, 1017 assert(SCIPisFeasLE(scip, SCIPvarGetLbLocal(var), solval) && SCIPisFeasLE(scip, solval, SCIPvarGetUbLocal(var))); 1088 if( nloops % heurdata->perturbfreq == 0 || (heurdata->pertsolfound && SCIPgetNBestSolsFound(scip) > nbestsolsfound) ) 1100 /* if we got the same rounded solution as in some step before, we have to flip some variables */ 1121 nlpiterationsleft = adjustedMaxNLPIterations(maxnlpiterations, nsolsfound, nstallloops) - heurdata->nlpiterations; 1133 /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic. 1134 * Hence in optimized mode, the return code is caught and a warning is printed, only in debug mode, SCIP will stop. 1144 SCIPwarningMessage(scip, "Error while solving LP in Feaspump heuristic; LP solve terminated with code <%d>\n", retcode); 1145 SCIPwarningMessage(scip, "This does not affect the remaining solution procedure --> continue\n"); 1150 SCIPdebugMessage(" -> number of iterations: %" SCIP_LONGINT_FORMAT "/%" SCIP_LONGINT_FORMAT ", lperror=%u, lpsolstat=%d\n", 1151 heurdata->nlpiterations, adjustedMaxNLPIterations(maxnlpiterations, nsolsfound, nstallloops), lperror, lpsolstat); 1181 SCIP_CALL( SCIPsetSolVal(scip, closestsol, vars[i], SCIPgetSolVal(scip, heurdata->roundedsol, vars[i])) ); 1209 SCIPdebugMessage(" -> loop finished: %d fractional variables (stall: %d/%d, iterations: %" SCIP_LONGINT_FORMAT "/%" SCIP_LONGINT_FORMAT ")\n", 1210 nfracs, nstallloops, maxstallloops, heurdata->nlpiterations, adjustedMaxNLPIterations(maxnlpiterations, nsolsfound, nstallloops)); 1240 /* only do stage 3 if the distance of the closest infeasible solution to the polyhedron is below a certain threshold */ 1241 if( heurdata->stage3 && (*result != SCIP_FOUNDSOL) && SCIPisLE(scip, mindistance, (SCIP_Real) heurdata->neighborhoodsize) ) 1268 /* substract the memory already used by the main SCIP and the estimated memory usage of external software */ 1275 /* abort if no time is left or not enough memory to create a copy of SCIP, including external memory usage */ 1283 SCIP_CALL( addLocalBranchingConstraint(scip, probingscip, varmapfw, closestsol, mindistance) ); 1285 /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic. 1286 * Hence in optimized mode, the return code is caught and a warning is printed, only in debug mode, SCIP will stop. 1292 SCIPwarningMessage(scip, "Error while solving sub-SCIP in stage 3 of feasibility pump heuristic; sub-SCIP terminated with code <%d>\n", 1348 SCIPstatisticMessage("feasibility pump found: 1, objval: %f, iterations: %d, primal bound: %f\n", objval, nloops, primalBound); 1355 SCIPstatisticMessage("feasibility pump found: 0, objval: +inf, iterations: %d, primal bound: %f\n", nloops, primalBound); SCIP_RETCODE SCIPsetHeurInitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol))) Definition: scip.c:7361 Definition: type_result.h:33 Definition: type_result.h:47 Definition: type_result.h:34 Definition: struct_scip.h:53 SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy))) Definition: scip.c:7297 SCIP_RETCODE SCIPbacktrackProbing(SCIP *scip, int probingdepth) Definition: scip.c:32250 void SCIPwarningMessage(SCIP *scip, const char *formatstr,...) Definition: scip.c:1248 static SCIP_RETCODE addLocalBranchingConstraint(SCIP *scip, SCIP *probingscip, SCIP_HASHMAP *varmapfw, SCIP_SOL *bestsol, SCIP_Real neighborhoodsize) Definition: heur_feaspump.c:407 static SCIP_DECL_HEUREXITSOL(heurExitsolFeaspump) Definition: heur_feaspump.c:632 Definition: struct_var.h:196 SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val) Definition: scip.c:34843 SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, unsigned int timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata) Definition: scip.c:7252 SCIP_RETCODE SCIPpropagateProbing(SCIP *scip, int maxproprounds, SCIP_Bool *cutoff, SCIP_Longint *ndomredsfound) Definition: scip.c:32552 SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize) Definition: misc.c:2057 SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value) Definition: scip.c:4046 Definition: type_var.h:53 SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored) Definition: scip.c:36299 SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value) Definition: scip.c:4109 SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj) Definition: scip.c:19590 SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var) Definition: scip.c:34983 void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin) Definition: misc.c:2116 SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded) Definition: scip.c:2883 Definition: struct_sol.h:50 SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata) Definition: scip.c:3547 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) Definition: scip.c:3573 static SCIP_RETCODE setupSCIPparamsStage3(SCIP *scip, SCIP *probingscip, SCIP_Real timelimit, SCIP_Real memorylimit) Definition: heur_feaspump.c:179 Definition: struct_misc.h:101 SCIP_RETCODE SCIPcopyParamSettings(SCIP *sourcescip, SCIP *targetscip) Definition: scip.c:3164 SCIP_RETCODE SCIPincludeHeurFeaspump(SCIP *scip) Definition: heur_feaspump.c:1373 SCIP_RETCODE SCIPcopy(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool passmessagehdlr, SCIP_Bool *valid) Definition: scip.c:3254 Definition: type_result.h:35 SCIP_RETCODE SCIPchgVarObjDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj) Definition: scip.c:31699 Definition: struct_cons.h:36 Definition: type_paramset.h:54 Definition: type_stat.h:52 SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur) Definition: scip.c:34002 SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:41907 SCIP_RETCODE SCIPgetPseudoBranchCands(SCIP *scip, SCIP_VAR ***pseudocands, int *npseudocands, int *npriopseudocands) Definition: scip.c:33464 SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet) Definition: scip.c:4457 Definition: type_retcode.h:33 SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals) Definition: scip.c:35020 void SCIPheurSetTimingmask(SCIP_HEUR *heur, SCIP_HEURTIMING timingmask) Definition: heur.c:1187 Definition: struct_heur.h:75 void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata) Definition: heur.c:1068 Definition: type_lp.h:34 SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value) Definition: scip.c:4001 SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet) Definition: scip.c:4382 Objective Feasibility Pump 2.0. SCIP_RETCODE SCIPfixVarProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval) Definition: scip.c:32415 SCIP_RETCODE SCIPsetHeurExitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol))) Definition: scip.c:7377 static SCIP_RETCODE handle1Cycle(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR **mostfracvars, int nflipcands, SCIP_Real alpha) Definition: heur_feaspump.c:314 SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet) Definition: scip.c:4431 Constraint handler for linear constraints in their most general form, . static SCIP_RETCODE handleCycle(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR **vars, int nbinandintvars, SCIP_Real alpha) Definition: heur_feaspump.c:358 SCIP_RETCODE SCIPsetHeurExit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXIT((*heurexit))) Definition: scip.c:7345 int SCIPgetRandomInt(int minrandval, int maxrandval, unsigned int *seedp) Definition: misc.c:7700 SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit))) Definition: scip.c:7329 SCIP_Real SCIPgetRandomReal(SCIP_Real minrandval, SCIP_Real maxrandval, unsigned int *seedp) Definition: misc.c:7719 Definition: type_lp.h:36 SCIP_RETCODE SCIPsetHeuristics(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet) Definition: scip.c:4405 static void insertFlipCand(SCIP_VAR **mostfracvars, SCIP_Real *mostfracvals, int *nflipcands, int maxnflipcands, SCIP_VAR *var, SCIP_Real frac) Definition: heur_feaspump.c:268 SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur) Definition: heur.c:1293 SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, 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) Definition: cons_linear.c:16099 #define SCIPduplicateBufferArray(scip, ptr, source, num) Definition: scip.h:20593 SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:41933 SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree))) Definition: scip.c:7313 SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name) Definition: scip.c:8436 void SCIPsortRealPtr(SCIP_Real *realarray, void **ptrarray, int len) Definition: type_set.h:42 SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals) Definition: scip.c:34885 SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value) Definition: scip.c:3938 SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars) Definition: scip.c:10572 SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value) Definition: scip.c:3797 static SCIP_DECL_HEURINITSOL(heurInitsolFeaspump) Definition: heur_feaspump.c:615 Definition: type_paramset.h:53 SCIP_RETCODE SCIPsolveDiveLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff) Definition: scip.c:31999 Definition: objbranchrule.h:33 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) Definition: scip.c:3629 static SCIP_RETCODE setupSCIPparamsFP2(SCIP *scip, SCIP *probingscip) Definition: heur_feaspump.c:141 static SCIP_Longint adjustedMaxNLPIterations(SCIP_Longint maxnlpiterations, SCIP_Longint nsolsfound, int nstallloops) Definition: heur_feaspump.c:642 default SCIP plugins static SCIP_RETCODE createNewSols(SCIP *scip, SCIP *subscip, SCIP_HASHMAP *varmapfw, SCIP_HEUR *heur, SCIP_Bool *success) Definition: heur_feaspump.c:475 SCIP_RETCODE SCIPtrySol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored) Definition: scip.c:36217 static SCIP_RETCODE setupProbingSCIP(SCIP *scip, SCIP **probingscip, SCIP_HASHMAP **varmapfw, SCIP_Bool copycuts, SCIP_Bool *success) Definition: heur_feaspump.c:105 SCIP_RETCODE SCIProundSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *success) Definition: scip.c:35909 |