All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 */
117 SCIP_CALL( SCIPcopy(scip, *probingscip, *varmapfw, NULL, "feaspump", FALSE, FALSE, TRUE, success) );
137 SCIPwarningMessage(scip, "unfixing parameter heuristics/"HEUR_NAME"/freq in probingscip of "HEUR_NAME" heuristic to avoid recursive calls\n");
154 SCIPwarningMessage(scip, "unfixing parameter lp/solvefreq in probingscip of "HEUR_NAME" heuristic to speed up propagation\n");
193 SCIPwarningMessage(scip,"unfixing parameter heuristics/"HEUR_NAME"/freq in probingscip of "HEUR_NAME" heuristic to avoid recursive calls\n");
219 if( SCIPfindNodesel(probingscip, "estimate") != NULL && !SCIPisParamFixed(probingscip, "nodeselection/estimate/stdpriority") )
225 if( SCIPfindBranchrule(probingscip, "inference") != NULL && !SCIPisParamFixed(probingscip, "branching/inference/priority") )
276 /* if there are already enough candidates and the variable is less fractional, return, else reserve the last entry */
318 /* just flipping the objective coefficients from +1 to -1 and the rounding from floor to ceil */
343 /** flips the roundings of randomly chosen fractional variables, preferring highly fractional ones,
363 /* just flipping the objective coefficients from +1 to -1 and the rounding from floor to ceil */
462 /** creates new solutions for the original problem by copying the solutions of the subproblem */
487 /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP
488 * since constraint copying may have required the copy of variables that are fixed in the main SCIP
602 /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin) */
611 /* if the heuristic is called at the root node, we may want to be called directly after the initial root LP solve */
619 /** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) */
654 SCIP_SOL** lastroundedsols;/* solutions of the last pumping rounds (depending on heurdata->cyclelength) */
658 SCIP* probingscip; /* copied SCIP structure, used for round-and-propagate loop of feasibility pump 2.0 */
674 SCIP_Real objfactor; /* factor by which the regard of the objective is decreased in each round, in [0,0.99] */
675 SCIP_Real alpha; /* factor how the original objective is regarded, used for convex combination of two functions */
678 SCIP_Real mindistance; /* distance of the closest rounded solution from the LP relaxation: used for stage3 */
696 int maxflips; /* maximum number of flips, if a 1-cycle is found (depending on heurdata->minflips) */
698 int nstallloops; /* number of loops without reducing the current best number of factional variables */
747 /* only call the heuristic before cutting planes if we do not have an incumbent and no pricer exists */
748 if( heurtiming == SCIP_HEURTIMING_DURINGLPLOOP && SCIPgetNSolsFound(scip) > 0 && SCIPgetNPricers(scip) == 0 )
756 if( heurdata->maxsols >= 0 && SCIPgetNSolsFound(scip) > heurdata->maxsols && SCIPgetNPricers(scip) == 0 )
759 /* get all variables of LP and number of fractional variables in LP solution that should be integral */
770 maxnlpiterations = (SCIP_Longint)((1.0 + 10.0*(nsolsfound+1.0)/(ncalls+1.0)) * heurdata->maxlpiterquot * nlpiterations);
789 SCIPdebugMessage("executing feasibility pump heuristic, nlpiters=%"SCIP_LONGINT_FORMAT", maxnlpit:%"SCIP_LONGINT_FORMAT", maxflips:%d \n",
808 * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop. */
814 SCIPwarningMessage(scip, "Error while solving subproblem in feaspump heuristic; sub-SCIP terminated with code <%d>\n", retcode);
896 && heurdata->nlpiterations < adjustedMaxNLPIterations(maxnlpiterations, nsolsfound, nstallloops)
909 SCIPdebugMessage("feasibility pump loop %d: %d fractional variables (alpha: %.4f, stall: %d/%d)\n",
929 /* randomly choose maximum number of variables to flip in current pumping round in case of a 1-cycle */
930 maxnflipcands = SCIPgetRandomInt(MIN(nfracs/2+1, heurdata->minflips), MIN(nfracs, maxflips), &heurdata->randseed);
988 SCIPdebugMessage("try to fix variable <%s> (domain [%f,%f] to %f\n",SCIPvarGetName(probingvar), lb, ub,
1006 assert(SCIPisFeasLE(scip, SCIPvarGetLbLocal(var), solval) && SCIPisFeasLE(scip, solval, SCIPvarGetUbLocal(var)));
1077 if( nloops % heurdata->perturbfreq == 0 || (heurdata->pertsolfound && SCIPgetNBestSolsFound(scip) > nbestsolsfound) )
1089 /* if we got the same rounded solution as in some step before, we have to flip some variables */
1110 nlpiterationsleft = adjustedMaxNLPIterations(maxnlpiterations, nsolsfound, nstallloops) - heurdata->nlpiterations;
1122 /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic.
1123 * Hence in optimized mode, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
1133 SCIPwarningMessage(scip, "Error while solving LP in Feaspump heuristic; LP solve terminated with code <%d>\n", retcode);
1134 SCIPwarningMessage(scip, "This does not affect the remaining solution procedure --> continue\n");
1139 SCIPdebugMessage(" -> number of iterations: %"SCIP_LONGINT_FORMAT"/%"SCIP_LONGINT_FORMAT", lperror=%u, lpsolstat=%d\n",
1140 heurdata->nlpiterations, adjustedMaxNLPIterations(maxnlpiterations, nsolsfound, nstallloops), lperror, lpsolstat);
1170 SCIP_CALL( SCIPsetSolVal(scip, closestsol, vars[i], SCIPgetSolVal(scip, heurdata->roundedsol, vars[i])) );
1197 SCIPdebugMessage(" -> loop finished: %d fractional variables (stall: %d/%d, iterations: %"SCIP_LONGINT_FORMAT"/%"SCIP_LONGINT_FORMAT")\n",
1198 nfracs, nstallloops, maxstallloops, heurdata->nlpiterations, adjustedMaxNLPIterations(maxnlpiterations, nsolsfound, nstallloops));
1228 /* only do stage 3 if the distance of the closest infeasible solution to the polyhedron is below a certain threshold */
1229 if( heurdata->stage3 && (*result != SCIP_FOUNDSOL) && SCIPisLE(scip, mindistance, (SCIP_Real) heurdata->neighborhoodsize) )
1256 /* substract the memory already used by the main SCIP and the estimated memory usage of external software */
1263 /* abort if no time is left or not enough memory to create a copy of SCIP, including external memory usage */
1271 SCIP_CALL( addLocalBranchingConstraint(scip, probingscip, varmapfw, closestsol, mindistance) );
1273 /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic.
1274 * Hence in optimized mode, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
1280 SCIPwarningMessage(scip, "Error while solving sub-SCIP in stage 3 of feasibility pump heuristic; sub-SCIP terminated with code <%d>\n",
1336 SCIPstatisticMessage("feasibility pump found: 1, objval: %f, iterations: %d, primal bound: %f\n", objval, nloops, primalBound);
1343 SCIPstatisticMessage("feasibility pump found: 0, objval: +inf, iterations: %d, primal bound: %f\n", nloops, primalBound);
|