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.25 /* 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 TRUE /* 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));
188 /** creates a new solution for the original problem by copying the solution of the subproblem */
214 /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP
215 * since constraint copying may have required the copy of variables that are fixed in the main SCIP
232 int ncontobjvars; /* does the problem instance have continuous variables with nonzero objective coefficients? */
253 SCIPstatisticMessage(" Continuous Objective variables: %d, Euclidean OBJ: %g total, %g continuous\n", ncontobjvars, SCIPgetObjNorm(scip), sumofobjsquares);
257 SCIPstatisticMessage("Solution Value before LP resolve: %g\n", SCIPgetSolOrigObj(scip, newsol));
301 if( SCIPfindNodesel(subscip, "dfs") != NULL && !SCIPisParamFixed(subscip, "nodeselection/dfs/stdpriority") )
322 if( SCIPfindBranchrule(subscip, "leastinf") != NULL && !SCIPisParamFixed(subscip, "branching/leastinf/priority") )
337 /* employ a limit on the number of enforcement rounds in the quadratic constraint handler; this fixes the issue that
338 * sometimes the quadratic constraint handler needs hundreds or thousands of enforcement rounds to determine the
339 * feasibility status of a single node without fractional branching candidates by separation (namely for uflquad
340 * instances); however, the solution status of the sub-SCIP might get corrupted by this; hence no deductions shall be
343 if( SCIPfindConshdlr(subscip, "quadratic") != NULL && !SCIPisParamFixed(subscip, "constraints/quadratic/enfolplimit") )
410 SCIP_CALL( SCIPcreateConsLinear(subscip, &cons, SCIProwGetName(rows[i]), nnonz, consvars, vals, lhs, rhs,
473 if( SCIPgetLPSolstat(scip) == SCIP_LPSOLSTAT_ITERLIMIT || SCIPgetNLPIterations(scip) >= heurdata->maxlpiters )
606 SCIPdebugMessage("skipping proximity: nnodes=%"SCIP_LONGINT_FORMAT", minnodes=%"SCIP_LONGINT_FORMAT"\n", nnodes, heurdata->minnodes);
621 /* main loop of proximity: in every iteration, a new subproblem is set up and solved until no improved solution
634 SCIP_CALL( SCIPapplyProximity(scip, heur, result, heurdata->minimprove, nnodes, nlpiters, &nusednodes, &nusedlpiters) );
743 if( SCIPsolGetHeur(incumbent) != NULL && strcmp(SCIPheurGetName(SCIPsolGetHeur(incumbent)), "trivial") == 0 )
746 /* waitingnodes parameter defines the minimum number of nodes to wait before a new incumbent is processed */
747 if( SCIPgetNNodes(scip) > 1 && SCIPgetNNodes(scip) - SCIPsolGetNodenum(incumbent) < heurdata->waitingnodes )
756 SCIPdebugMessage(" Rounding up lower bound: %f --> %f \n", lowerbound, SCIPfeasCeil(scip, lowerbound));
764 /* calculate the minimum improvement for a heuristic solution in terms of the distance between incumbent objective
769 /* use integrality of the objective function to round down (and thus strengthen) the objective cutoff */
776 /* exit execution if the right hand side of the objective constraint does not change (suggests that the heuristic
778 if( heurdata->objcons != NULL && SCIPisFeasEQ(scip, SCIPgetRhsLinear(heurdata->subscip, heurdata->objcons), objcutoff) )
789 /* substract the memory already used by the main SCIP and the estimated memory usage of external software */
796 /* abort if no time is left or not enough memory to create a copy of SCIP, including external memory usage */
817 SCIP_CALL( SCIPhashmapCreate(&varmapfw, SCIPblkmem(subscip), SCIPcalcHashtableSize(5 * nvars)) );
830 SCIP_CALL( SCIPcopyPlugins(scip, subscip, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
844 SCIP_CALL( SCIPincludeEventhdlrBasic(subscip, &eventhdlr, EVENTHDLR_NAME, EVENTHDLR_DESC, eventExecProximity, NULL) );
854 /* create the objective constraint in the sub scip, first without variables and values which will be added later */
855 SCIP_CALL( SCIPcreateConsBasicLinear(subscip, &objcons, "objbound_of_origscip", 0, NULL, NULL, -SCIPinfinity(subscip), SCIPinfinity(subscip)) );
857 /* determine large value to set variable bounds to, safe-guard to avoid fixings to infinite values */
863 /* get variable image and change objective to proximity function (Manhattan distance) in sub-SCIP */
905 /* the instance, event handler, hash map and variable array were already copied in a previous iteration
950 /*todo set iterations limit depending on the number of iterations of the original problem root */
957 SCIP_CALL( SCIPcatchEvent(subscip, SCIP_EVENTTYPE_NODESOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, NULL) );
978 SCIPgetNNodes(subscip), SCIPgetNLPIterations(subscip), SCIPgetNRootLPIterations(subscip), SCIPgetPresolvingTime(subscip));
980 SCIPstatisticMessage("Solving Time %d: %.2f\n", heurdata->subprobidx, SCIPgetSolvingTime(subscip) );
982 SCIP_CALL( SCIPdropEvent(subscip, SCIP_EVENTTYPE_NODESOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, -1) );
985 * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
992 SCIPwarningMessage(scip, "Error while solving subproblem in proximity heuristic; sub-SCIP terminated with code <%d>\n",retcode);
1009 SCIPstatisticMessage("primal bound before subproblem %d: %g\n", heurdata->subprobidx, SCIPgetPrimalbound(scip));
1016 SCIP_CALL( createNewSol(scip, subscip, subvars, heur, incumbent, heurdata->usefinallp, &success) );
1021 SCIPstatisticMessage("primal bound after subproblem %d: %g\n", heurdata->subprobidx, SCIPgetPrimalbound(scip));
1026 /* save subproblem in heuristic data for subsequent runs if it has been successful, otherwise free subproblem */
1062 SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/"HEUR_NAME"/uselprows", "should subproblem be constructed based on LP row information?",
1065 SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/"HEUR_NAME"/restart", "should the heuristic immediately run again on its newly found solution?",
1068 SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/"HEUR_NAME"/usefinallp", "should the heuristic solve a final LP in case of continuous objective variables?",
1087 SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/"HEUR_NAME"/minlpiters", "minimum number of LP iterations performed in "
1088 "subproblem", &heurdata->minlpiters, TRUE, DEFAULT_MINLPITERS, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1091 "waiting nodes since last incumbent before heuristic is executed", &heurdata->waitingnodes, TRUE, DEFAULT_WAITINGNODES,
1098 SCIP_CALL( SCIPaddRealParam(scip, "heuristics/"HEUR_NAME"/nodesquot", "sub-MIP node limit w.r.t number of original nodes",
|