|
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
heur_proximity.c
Go to the documentation of this file.
17 * @brief improvement heuristic which uses an auxiliary objective instead of the original objective function which
18 * is itself added as a constraint to a sub-SCIP instance. The heuristic was presented by Matteo Fischetti
25 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 #define HEUR_DESC "heuristic trying to improve the incumbent by an auxiliary proximity objective function"
50 #define DEFAULT_MINIMPROVE 0.02 /* factor by which proximity should at least improve the incumbent */
54 #define DEFAULT_MAXLPITERS 100000LL /* maximum number of LP iterations to be performed in the subproblem */
56 #define DEFAULT_WAITINGNODES 100LL /* default waiting nodes since last incumbent before heuristic is executed */
57 #define DEFAULT_NODESQUOT 0.1 /* default quotient of sub-MIP nodes with respect to number of processed nodes*/
58 #define DEFAULT_USELPROWS FALSE /* should subproblem be constructed based on LP row information? */
59 #define DEFAULT_BINVARQUOT 0.1 /* default threshold for percentage of binary variables required to start */
60 #define DEFAULT_RESTART TRUE /* should the heuristic immediately run again on its newly found solution? */
61 #define DEFAULT_USEFINALLP FALSE /* should the heuristic solve a final LP in case of continuous objective variables? */
62 #define DEFAULT_LPITERSQUOT 0.2 /* default quotient of sub-MIP LP iterations with respect to LP iterations so far */
73 SCIP_Longint maxlpiters; /**< maximum number of LP iterations to be performed in the subproblem */
78 SCIP_Longint waitingnodes; /**< waiting nodes since last incumbent before heuristic is executed */
79 SCIP_Real lpitersquot; /**< quotient of sub-MIP LP iterations with respect to LP iterations so far */
96 SCIP_Bool usefinallp; /* should the heuristic solve a final LP in case of continuous objective variables? */
104 /** optimizes the continuous variables in an LP diving by fixing all integer variables to the given solution values */
129 /**@todo in case of an MINLP, if SCIPisNLPConstructed() is TRUE rather solve the NLP instead of the LP */
160 SCIPdebugMessage(" -> old LP iterations: %"SCIP_LONGINT_FORMAT"\n", SCIPgetNLPIterations(scip));
162 /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic.
163 * Hence in optimized mode, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
169 SCIPwarningMessage(scip, "Error while solving LP in Proximity heuristic; LP solve terminated with code <%d>\n",retstat);
175 SCIPdebugMessage(" -> new LP iterations: %"SCIP_LONGINT_FORMAT"\n", SCIPgetNLPIterations(scip));
189 /** creates a new solution for the original problem by copying the solution of the subproblem */
216 /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP
217 * since constraint copying may have required the copy of variables that are fixed in the main SCIP
235 int ncontobjvars; /* does the problem instance have continuous variables with nonzero objective coefficients? */
256 SCIPstatisticMessage(" Continuous Objective variables: %d, Euclidean OBJ: %g total, %g continuous\n", ncontobjvars, SCIPgetObjNorm(scip), sumofobjsquares);
258 SCIPstatisticMessage("Solution Value before LP resolve: %g\n", SCIPgetSolOrigObj(scip, newsol));
302 if( SCIPfindNodesel(subscip, "dfs") != NULL && !SCIPisParamFixed(subscip, "nodeselection/dfs/stdpriority") )
323 if( SCIPfindBranchrule(subscip, "leastinf") != NULL && !SCIPisParamFixed(subscip, "branching/leastinf/priority") )
338 /* employ a limit on the number of enforcement rounds in the quadratic constraint handler; this fixes the issue that
339 * sometimes the quadratic constraint handler needs hundreds or thousands of enforcement rounds to determine the
340 * feasibility status of a single node without fractional branching candidates by separation (namely for uflquad
341 * instances); however, the solution status of the sub-SCIP might get corrupted by this; hence no deductions shall be
344 if( SCIPfindConshdlr(subscip, "quadratic") != NULL && !SCIPisParamFixed(subscip, "constraints/quadratic/enfolplimit") )
411 SCIP_CALL( SCIPcreateConsLinear(subscip, &cons, SCIProwGetName(rows[i]), nnonz, consvars, vals, lhs, rhs,
474 if( SCIPgetLPSolstat(scip) == SCIP_LPSOLSTAT_ITERLIMIT || SCIPgetNLPIterations(scip) >= heurdata->maxlpiters )
607 SCIPdebugMessage("skipping proximity: nnodes=%"SCIP_LONGINT_FORMAT", minnodes=%"SCIP_LONGINT_FORMAT"\n", nnodes, heurdata->minnodes);
622 /* main loop of proximity: in every iteration, a new subproblem is set up and solved until no improved solution
635 SCIP_CALL( SCIPapplyProximity(scip, heur, result, heurdata->minimprove, nnodes, nlpiters, &nusednodes, &nusedlpiters, FALSE) );
658 /* just for testing the library method, in debug mode, we call the wrapper method for the actual delete method */
697 * @note the method can be applied in an iterative way, keeping the same subscip in between. If the @p freesubscip
698 * parameter is set to FALSE, the heuristic will keep the subscip data structures. Always set this parameter
777 if( SCIPsolGetHeur(incumbent) != NULL && strcmp(SCIPheurGetName(SCIPsolGetHeur(incumbent)), "trivial") == 0 )
780 /* waitingnodes parameter defines the minimum number of nodes to wait before a new incumbent is processed */
781 if( SCIPgetNNodes(scip) > 1 && SCIPgetNNodes(scip) - SCIPsolGetNodenum(incumbent) < heurdata->waitingnodes )
790 SCIPdebugMessage(" Rounding up lower bound: %f --> %f \n", lowerbound, SCIPfeasCeil(scip, lowerbound));
798 /* calculate the minimum improvement for a heuristic solution in terms of the distance between incumbent objective
803 /* use integrality of the objective function to round down (and thus strengthen) the objective cutoff */
810 /* exit execution if the right hand side of the objective constraint does not change (suggests that the heuristic
812 if( heurdata->objcons != NULL && SCIPisFeasEQ(scip, SCIPgetRhsLinear(heurdata->subscip, heurdata->objcons), objcutoff) )
823 /* substract the memory already used by the main SCIP and the estimated memory usage of external software */
830 /* abort if no time is left or not enough memory to create a copy of SCIP, including external memory usage */
851 SCIP_CALL( SCIPhashmapCreate(&varmapfw, SCIPblkmem(subscip), SCIPcalcHashtableSize(5 * nvars)) );
864 SCIP_CALL( SCIPcopyPlugins(scip, subscip, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
878 SCIP_CALL( SCIPincludeEventhdlrBasic(subscip, &eventhdlr, EVENTHDLR_NAME, EVENTHDLR_DESC, eventExecProximity, NULL) );
888 /* create the objective constraint in the sub scip, first without variables and values which will be added later */
889 SCIP_CALL( SCIPcreateConsBasicLinear(subscip, &objcons, "objbound_of_origscip", 0, NULL, NULL, -SCIPinfinity(subscip), SCIPinfinity(subscip)) );
891 /* determine large value to set variable bounds to, safe-guard to avoid fixings to infinite values */
897 /* get variable image and change objective to proximity function (Manhattan distance) in sub-SCIP */
939 /* the instance, event handler, hash map and variable array were already copied in a previous iteration
987 /*todo set iterations limit depending on the number of iterations of the original problem root */
994 SCIP_CALL( SCIPcatchEvent(subscip, SCIP_EVENTTYPE_NODESOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, NULL) );
1015 SCIPgetNNodes(subscip), SCIPgetNLPIterations(subscip), SCIPgetNRootLPIterations(subscip), SCIPgetPresolvingTime(subscip));
1017 SCIPstatisticMessage("Solving Time %d: %.2f\n", heurdata->subprobidx, SCIPgetSolvingTime(subscip) );
1019 SCIP_CALL( SCIPdropEvent(subscip, SCIP_EVENTTYPE_NODESOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, -1) );
1022 * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
1029 SCIPwarningMessage(scip, "Error while solving subproblem in proximity heuristic; sub-SCIP terminated with code <%d>\n",retcode);
1046 SCIPstatisticMessage("primal bound before subproblem %d: %g\n", heurdata->subprobidx, SCIPgetPrimalbound(scip));
1053 SCIP_CALL( createNewSol(scip, subscip, subvars, heur, incumbent, heurdata->usefinallp, &success) );
1058 SCIPstatisticMessage("primal bound after subproblem %d: %g\n", heurdata->subprobidx, SCIPgetPrimalbound(scip));
1063 /* save subproblem in heuristic data for subsequent runs if it has been successful, otherwise free subproblem */
1105 SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/"HEUR_NAME"/uselprows", "should subproblem be constructed based on LP row information?",
1108 SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/"HEUR_NAME"/restart", "should the heuristic immediately run again on its newly found solution?",
1111 SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/"HEUR_NAME"/usefinallp", "should the heuristic solve a final LP in case of continuous objective variables?",
1130 SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/"HEUR_NAME"/minlpiters", "minimum number of LP iterations performed in "
1131 "subproblem", &heurdata->minlpiters, TRUE, DEFAULT_MINLPITERS, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1134 "waiting nodes since last incumbent before heuristic is executed", &heurdata->waitingnodes, TRUE, DEFAULT_WAITINGNODES,
1141 SCIP_CALL( SCIPaddRealParam(scip, "heuristics/"HEUR_NAME"/nodesquot", "sub-MIP node limit w.r.t number of original nodes",
SCIP_RETCODE SCIPcreateConsBasicLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs) Definition: cons_linear.c:15013 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 SCIPincludeHeurProximity(SCIP *scip) Definition: heur_proximity.c:1081 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 SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:38667 static SCIP_RETCODE solveLp(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *success) Definition: heur_proximity.c:106 Definition: struct_var.h:196 SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val) Definition: scip.c:31639 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 SCIPchgVarUbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound) Definition: scip.c:29095 static SCIP_RETCODE deleteSubproblem(SCIP *scip, SCIP_HEURDATA *heurdata) Definition: heur_proximity.c:425 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 static SCIP_RETCODE createRows(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars) Definition: heur_proximity.c:364 SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata) Definition: scip.c:7209 SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value) Definition: scip.c:3914 SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj) Definition: scip.c:17775 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 SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var) Definition: scip.c:31775 void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin) Definition: misc.c:1923 SCIP_EVENTHDLR * SCIPfindEventhdlr(SCIP *scip, const char *name) Definition: scip.c:7339 Definition: struct_lp.h:123 SCIP_RETCODE SCIPchgVarLbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound) Definition: scip.c:29063 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_RETCODE SCIPapplyProximity(SCIP *scip, SCIP_HEUR *heur, SCIP_RESULT *result, SCIP_Real minimprove, SCIP_Longint nnodes, SCIP_Longint nlpiters, SCIP_Longint *nusednodes, SCIP_Longint *nusedlpiters, SCIP_Bool freesubscip) Definition: heur_proximity.c:701 SCIP_RETCODE SCIPcreateProbBasic(SCIP *scip, const char *name) Definition: scip.c:8510 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 SCIP_RETCODE SCIPchgVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound) Definition: scip.c:18227 Definition: struct_cons.h:36 Definition: type_paramset.h:54 SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur) Definition: scip.c:30856 SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:38648 static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool usefinallp, SCIP_Bool *success) Definition: heur_proximity.c:191 Definition: type_var.h:42 SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons) Definition: cons_linear.c:15337 SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet) Definition: scip.c:4199 Definition: type_retcode.h:33 SCIP_RETCODE SCIPgetLPRowsData(SCIP *scip, SCIP_ROW ***rows, int *nrows) Definition: scip.c:24447 SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals) Definition: scip.c:31809 Definition: struct_heur.h:36 Definition: type_lp.h:34 SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value) Definition: scip.c:3824 SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet) Definition: scip.c:4124 SCIP_RETCODE SCIPcopyVars(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global) Definition: scip.c:2087 Definition: struct_lp.h:188 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 Constraint handler for linear constraints in their most general form, . SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit))) Definition: scip.c:7046 SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val) Definition: cons_linear.c:15158 SCIP_RETCODE SCIPdropEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos) Definition: scip.c:33344 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:14821 const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr) Definition: event.c:278 SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:38686 SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree))) Definition: scip.c:7030 SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name) Definition: scip.c:7867 SCIP_RETCODE SCIPdeleteSubproblemProximity(SCIP *scip) Definition: heur_proximity.c:674 SCIP_RETCODE SCIPchgRhsLinear(SCIP *scip, SCIP_CONS *cons, SCIP_Real rhs) Definition: cons_linear.c:15382 SCIP_RETCODE SCIPchgVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound) Definition: scip.c:18150 static SCIP_DECL_HEUREXITSOL(heurExitsolProximity) Definition: heur_proximity.c:549 Definition: type_retcode.h:45 SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals) Definition: scip.c:31679 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 SCIPcopyPlugins(SCIP *sourcescip, SCIP *targetscip, SCIP_Bool copyreaders, SCIP_Bool copypricers, SCIP_Bool copyconshdlrs, SCIP_Bool copyconflicthdlrs, SCIP_Bool copypresolvers, SCIP_Bool copyrelaxators, SCIP_Bool copyseparators, SCIP_Bool copypropagators, SCIP_Bool copyheuristics, SCIP_Bool copyeventhdlrs, SCIP_Bool copynodeselectors, SCIP_Bool copybranchrules, SCIP_Bool copydisplays, SCIP_Bool copydialogs, SCIP_Bool copynlpis, SCIP_Bool passmessagehdlr, SCIP_Bool *valid) Definition: scip.c:1422 SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value) Definition: scip.c:3638 Definition: type_lp.h:38 Definition: type_paramset.h:53 SCIP_RETCODE SCIPsolveDiveLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff) Definition: scip.c:29322 SCIP_Longint SCIPgetNRootFirstLPIterations(SCIP *scip) Definition: scip.c:34184 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 improvement heuristic which uses an auxiliary objective instead of the original objective function wh... 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 Definition: struct_event.h:185 SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos) Definition: scip.c:33310 |