|
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
heur_vbounds.c
Go to the documentation of this file.
17 * @brief LNS heuristic uses the variable lower and upper bounds to determine the search neighborhood
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 #define HEUR_DESC "LNS heuristic uses the variable lower and upper bounds to determine the search neighborhood"
44 #define DEFAULT_MINFIXINGRATE 0.5 /* minimum percentage of integer variables that have to be fixed */
45 #define DEFAULT_MINIMPROVE 0.01 /* factor by which vbounds heuristic should at least improve the incumbent */
48 #define DEFAULT_NODESQUOT 0.1 /* subproblem nodes in relation to nodes of the original problem */
50 #define DEFAULT_COPYCUTS TRUE /**< should all active cuts from the cutpool of the original scip be copied to
64 SCIP_VAR** impvars; /**< topological sorted variables with respect to the variable lower and upper
76 SCIP_Real minimprove; /**< factor by which vbounds heuristic should at least improve the incumbent */
123 )
159 /** perform depth-first-search from the given variable using the variable lower or upper bounds of the variable */
164 SCIP_HASHMAP* varPosMap, /**< mapping a variable to its position in the (used) variable array, or NULL */
169 int* nsortedvars, /**< pointer to store the number of already collects variables in the sorted variables array */
170 SCIP_Bool lowerbound /**< depth-first-search with respect to the variable lower bounds, otherwise variable upper bound */
209 /* we could not resolve the variable bound variable to one active variable, therefore, ignore this variable bound */
213 /* insert variable bound variable into the hash table since they are involved in later propagation */
216 SCIPdebugMessage("insert variable <%s> with position %d into the hash map\n", SCIPvarGetName(vbvar), *nusedvars);
226 SCIP_CALL( depthFirstSearch(scip, vbvar, varPosMap, usedvars, nusedvars, connected, sortedvars, nsortedvars, lowerbound) );
234 /* insert variable bound variable into the hash table since they are involve in the later propagation */
237 SCIPdebugMessage("insert variable <%s> with position %d into the hash map\n", SCIPvarGetName(var), *nusedvars);
246 /** create a topological sorted variable array of the given variables and stores if (needed) the involved variables into
249 * @note: for all arrays and the hash map (if requested) you need to allocate enough memory before calling this method
256 SCIP_HASHMAP* varPosMap, /**< mapping a variable to its position in the (used) variable array, or NULL */
261 SCIP_Bool lowerbound /**< topological sorted with respect to the variable lower bounds, otherwise variable upper bound */
279 SCIPdebugMessage("create topological sorted variable array with respect to variables %s bounds\n",
293 SCIP_CALL( SCIPhashtableCreate(&connected, SCIPblkmem(scip), hashsize, SCIPvarGetHashkey, SCIPvarIsHashkeyEq, SCIPvarGetHashkeyVal, NULL) );
295 /* detect isolated variables; mark all variables which have at least one entering or leaving arc as connected */
326 /* loop over all "connected" variable and find for each connected component a "almost" topological sorted version */
335 /* use depth first search to get a "almost" topological sorted variables for the connected component which
339 SCIP_CALL( depthFirstSearch(scip, vars[v], varPosMap, usedvars, nusedvars, connected, sortedvars, &nsortedvars, lowerbound) );
403 SCIP_CALL( createTopoSortedVars(scip, allvars, nallvars, NULL, vars, &nvars, lbvars, &nlbvars, TRUE) );
406 SCIP_CALL( createTopoSortedVars(scip, allvars, nallvars, NULL, vars, &nvars, ubvars, &nubvars, FALSE) );
409 SCIP_CALL( SCIPhashtableCreate(&collectedvars, SCIPblkmem(scip), SCIPcalcHashtableSize(nallvars), hashGetKeyVar, hashKeyEqVar, hashKeyValVar, NULL) );
425 if( SCIPisLE(scip, SCIPvarGetObj(ubvars[v]), 0.0) && !SCIPhashtableExists(collectedvars, ubvars[v]) )
461 if( nlbvars > nlbimpvars && nubvars > nubimpvars && nlbimpvars + nubimpvars >= heurdata->minfixingrate * nallvars )
464 SCIP_CALL( SCIPduplicateMemoryArray(scip, &heurdata->impvars, impvars, nlbimpvars + nubimpvars) );
509 /* for each variable in topological order: start at best bound (MINIMIZE: neg coeff --> ub, pos coeff: lb) */
546 SCIPdebugMessage("vbound heuristic found roundable primal solution: obj=%g\n", SCIPgetSolOrigObj(scip, sol));
569 /** creates a new solution for the original problem by copying the solution of the subproblem */
592 /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP
593 * since constraint copying may have required the copy of variables that are fixed in the main SCIP
650 nstallnodes = (SCIP_Longint)(nstallnodes * 3.0 * (SCIPheurGetNBestSolsFound(heur)+1.0)/(SCIPheurGetNCalls(heur) + 1.0));
651 nstallnodes -= 100 * SCIPheurGetNCalls(heur); /* count the setup costs for the sub-MIP as 100 nodes */
661 SCIPdebugMessage("skipping "HEUR_NAME": nstallnodes=%"SCIP_LONGINT_FORMAT", minnodes=%"SCIP_LONGINT_FORMAT"\n", nstallnodes, heurdata->minnodes);
668 SCIPdebugMessage("apply variable bounds heuristic at node %lld on %d variable lower bound and %d variable upper bounds\n",
678 SCIP_CALL( applyVboundsFixings(scip, heurdata, probvars, nlbvars, nubvars, newsol, &infeasible, result) );
725 /* substract the memory already used by the main SCIP and the estimated memory usage of external software */
732 /* abort if no time is left or not enough memory to create a copy of SCIP, including external memory usage */
766 /* employ a limit on the number of enforcement rounds in the quadratic constraint handlers; this fixes the issue that
767 * sometimes the quadratic constraint handler needs hundreds or thousands of enforcement rounds to determine the
768 * feasibility status of a single node without fractional branching candidates by separation (namely for uflquad
769 * instances); however, the solution status of the sub-SCIP might get corrupted by this; hence no decutions shall be
772 if( SCIPfindConshdlr(subscip, "quadratic") != NULL && !SCIPisParamFixed(subscip, "constraints/quadratic/enfolplimit") )
806 /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic.
807 * Hence in optimized mode, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
815 SCIPwarningMessage(scip, "Error while presolving subMIP in vbounds heuristic; sub-SCIP terminated with code <%d>\n", retstat);
822 SCIPdebugMessage("vbounds heuristic presolved subproblem: %d vars, %d cons\n", SCIPgetNVars(subscip), SCIPgetNConss(subscip));
824 /* after presolving, we should have at least reached a certain fixing rate over ALL variables (including continuous)
833 SCIPdebugMessage("solving subproblem: nstallnodes=%"SCIP_LONGINT_FORMAT", maxnodes=%"SCIP_LONGINT_FORMAT"\n", nstallnodes, heurdata->maxnodes);
841 SCIPwarningMessage(scip, "Error while solving subMIP in vbounds heuristic; sub-SCIP terminated with code <%d>\n",retstat);
848 /* check, whether a solution was found; due to numerics, it might happen that not all solutions are feasible ->
917 /** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) */
983 SCIP_CALL( applyVbounds(scip, heur, heurdata, heurdata->impvars, heurdata->nlbimpvars, heurdata->nubimpvars, result) );
986 SCIP_CALL( applyVbounds(scip, heur, heurdata, heurdata->lbvars, heurdata->nlbvars, 0, result) );
989 SCIP_CALL( applyVbounds(scip, heur, heurdata, heurdata->ubvars, 0, heurdata->nubvars, result) );
1001 )
static void getVariableBounds(SCIP_VAR *var, SCIP_VAR ***vbvars, int *nvbvars, SCIP_Bool lowerbound) Definition: heur_vbounds.c:140 Definition: type_result.h:33 SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name) Definition: scip.c:5600 Definition: type_result.h:47 Definition: struct_scip.h:52 SCIP_RETCODE SCIPhashtableInsert(SCIP_HASHTABLE *hashtable, void *element) Definition: misc.c:1374 SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy))) Definition: scip.c:7014 void SCIPwarningMessage(SCIP *scip, const char *formatstr,...) Definition: scip.c:1206 Definition: struct_var.h:196 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:6969 SCIP_RETCODE SCIPgetProbvarSum(SCIP *scip, SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant) Definition: scip.c:15670 static SCIP_RETCODE initializeCandsLists(SCIP *scip, SCIP_HEURDATA *heurdata) Definition: heur_vbounds.c:369 SCIP_RETCODE SCIPpropagateProbing(SCIP *scip, int maxproprounds, SCIP_Bool *cutoff, SCIP_Longint *ndomredsfound) Definition: scip.c:29766 SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize) Definition: misc.c:1864 SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value) Definition: scip.c:3869 SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value) Definition: scip.c:3914 static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_SOL *newsol, SCIP_SOL *subsol, SCIP_Bool *success) Definition: heur_vbounds.c:573 SCIP_RETCODE SCIPaddLongintParam(SCIP *scip, const char *name, const char *desc, SCIP_Longint *valueptr, SCIP_Bool isadvanced, SCIP_Longint defaultvalue, SCIP_Longint minvalue, SCIP_Longint maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata) Definition: scip.c:3442 void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin) Definition: misc.c:1923 SCIP_RETCODE SCIPhashtableCreate(SCIP_HASHTABLE **hashtable, BMS_BLKMEM *blkmem, int tablesize, SCIP_DECL_HASHGETKEY((*hashgetkey)), SCIP_DECL_HASHKEYEQ((*hashkeyeq)), SCIP_DECL_HASHKEYVAL((*hashkeyval)), void *userptr) Definition: misc.c:1287 SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded) Definition: scip.c:2726 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:3388 SCIP_Bool SCIPhashmapExists(SCIP_HASHMAP *hashmap, void *origin) Definition: misc.c:1966 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:3414 Definition: struct_misc.h:101 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:3095 Definition: type_result.h:35 Definition: type_paramset.h:54 SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur) Definition: scip.c:30856 static SCIP_RETCODE createTopoSortedVars(SCIP *scip, SCIP_VAR **vars, int nvars, SCIP_HASHMAP *varPosMap, SCIP_VAR **usedvars, int *nusedvars, SCIP_VAR **topovars, int *ntopovars, SCIP_Bool lowerbound) Definition: heur_vbounds.c:254 SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet) Definition: scip.c:4199 Definition: type_retcode.h:33 SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals) Definition: scip.c:31809 SCIP_RETCODE SCIPhashtableRemove(SCIP_HASHTABLE *hashtable, void *element) Definition: misc.c:1526 Definition: struct_heur.h:36 static SCIP_RETCODE applyVboundsFixings(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR **vars, int nlbvars, int nubvars, SCIP_SOL *sol, SCIP_Bool *infeasible, SCIP_RESULT *result) Definition: heur_vbounds.c:497 #define SCIPduplicateMemoryArray(scip, ptr, source, num) Definition: scip.h:19173 SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value) Definition: scip.c:3824 SCIP_RETCODE SCIPlinkCurrentSol(SCIP *scip, SCIP_SOL *sol) Definition: scip.c:31549 SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet) Definition: scip.c:4124 static SCIP_RETCODE depthFirstSearch(SCIP *scip, SCIP_VAR *var, SCIP_HASHMAP *varPosMap, SCIP_VAR **usedvars, int *nusedvars, SCIP_HASHTABLE *connected, SCIP_VAR **sortedvars, int *nsortedvars, SCIP_Bool lowerbound) Definition: heur_vbounds.c:163 SCIP_RETCODE SCIPfixVarProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval) Definition: scip.c:29709 LNS heuristic uses the variable lower and upper bounds to determine the search neighborhood. SCIP_RETCODE SCIPsetHeurExitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol))) Definition: scip.c:7094 SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet) Definition: scip.c:4173 SCIP_RETCODE SCIPincludeHeurVbounds(SCIP *scip) Definition: heur_vbounds.c:1001 SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur) Definition: heur.c:737 Definition: struct_misc.h:80 SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree))) Definition: scip.c:7030 SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals) Definition: scip.c:31679 SCIP_Bool SCIPhashtableExists(SCIP_HASHTABLE *hashtable, void *element) Definition: misc.c:1499 SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value) Definition: scip.c:3779 SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars) Definition: scip.c:9945 SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value) Definition: scip.c:3638 SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image) Definition: misc.c:1901 Definition: type_paramset.h:53 static SCIP_RETCODE applyVbounds(SCIP *scip, SCIP_HEUR *heur, SCIP_HEURDATA *heurdata, SCIP_VAR **probvars, int nlbvars, int nubvars, SCIP_RESULT *result) Definition: heur_vbounds.c:616 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:3470 default SCIP plugins 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:32978 SCIP callable library. SCIP_RETCODE SCIProundSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *success) Definition: scip.c:32673 Definition: type_var.h:56 |