32 #define HEUR_NAME "completesol" 33 #define HEUR_DESC "primal heuristic trying to complete given partial solutions" 34 #define HEUR_DISPCHAR 'h' 35 #define HEUR_PRIORITY 0 37 #define HEUR_FREQOFS 0 38 #define HEUR_MAXDEPTH 0 39 #define HEUR_TIMING SCIP_HEURTIMING_BEFOREPRESOL 40 #define HEUR_USESSUBSCIP TRUE 43 #define DEFAULT_MAXNODES 5000LL 44 #define DEFAULT_MAXUNKRATE 0.85 45 #define DEFAULT_ADDALLSOLS FALSE 46 #define DEFAULT_MINNODES 50LL 47 #define DEFAULT_NODESOFS 500LL 48 #define DEFAULT_NODESQUOT 0.1 49 #define DEFAULT_LPLIMFAC 2.0 50 #define DEFAULT_OBJWEIGHT 1.0 51 #define DEFAULT_BOUNDWIDENING 0.1 54 #define DEFAULT_MINIMPROVE 0.01 55 #define DEFAULT_MINOBJWEIGHT 1e-3 56 #define DEFAULT_IGNORECONT FALSE 57 #define DEFAULT_BESTSOLS 5 58 #define DEFAULT_MAXPROPROUNDS 10 61 #define EVENTHDLR_NAME "Completesol" 62 #define EVENTHDLR_DESC "LP event handler for " HEUR_NAME " heuristic" 97 assert(eventhdlr !=
NULL);
98 assert(eventdata !=
NULL);
100 assert(event !=
NULL);
104 assert(heurdata !=
NULL);
137 assert(scip !=
NULL);
138 assert(subscip !=
NULL);
139 assert(subvars !=
NULL);
140 assert(heurdata !=
NULL);
160 cutoff =
MIN(upperbound, cutoff);
161 SCIPdebugMsg(scip,
"set cutoff=%g for sub-SCIP\n", cutoff);
167 if(
SCIPisEQ(scip, heurdata->objweight, 1.0) )
174 epsobj = (1.0 - heurdata->objweight)/heurdata->objweight;
188 for( i = 0; i < nvars; i++ )
199 if( objcons ==
NULL )
236 if( tightened[idx] ==
FALSE )
248 frac =
MIN(frac, 1-frac);
300 if( objcons !=
NULL )
325 assert(scip !=
NULL);
326 assert(subscip !=
NULL);
327 assert(subvars !=
NULL);
328 assert(subsol !=
NULL);
341 for( v = 0; v < nvars; v++ )
370 assert(scip !=
NULL);
429 assert(scip !=
NULL);
430 assert(heurdata !=
NULL);
431 assert(vars !=
NULL);
434 assert(tightened !=
NULL);
438 SCIPdebugMsg(scip,
"> start probing along the solution values\n");
444 incontsection =
FALSE;
453 for( v = 0; v < nvars && !abortearly; v++ )
472 if( ndomredssum > 0.3*nvars )
492 #ifdef SCIP_MORE_DEBUG 509 #ifdef SCIP_MORE_DEBUG 522 #ifdef SCIP_MORE_DEBUG 560 #ifdef SCIP_MORE_DEBUG 578 offset =
REALABS(heurdata->boundwidening * (newub-newlb));
583 offset =
REALABS(heurdata->boundwidening * (solval-newlb));
587 offset =
REALABS(heurdata->boundwidening * (newub-solval));
592 newub =
SCIPceil(scip, solval) + offset;
593 newlb =
SCIPfloor(scip, solval) - offset;
621 #ifdef SCIP_MORE_DEBUG 622 SCIPdebugMsg(scip,
"> tighten lower bound of variable <%s>: %g to %g\n",
631 #ifdef SCIP_MORE_DEBUG 632 SCIPdebugMsg(scip,
"> tighten upper bound of variable <%s>: %g to %g (ndomreds=%lld)\n",
668 #ifdef SCIP_MORE_DEBUG 669 SCIPdebugMsg(scip,
"> tighten upper bound of variable <%s>: %g to %g\n",
678 #ifdef SCIP_MORE_DEBUG 679 SCIPdebugMsg(scip,
"> tighten lower bound of variable <%s>: %g to %g (ndomreds=%lld)\n",
691 ndomredssum += ndomreds;
694 SCIPdebugMsg(scip,
"> found %d bound tightenings and %lld induced domain reductions (abort=%u).\n", nbndtightenings,
695 ndomredssum, abortearly);
726 assert(scip !=
NULL);
727 assert(heur !=
NULL);
728 assert(heurdata !=
NULL);
729 assert(result !=
NULL);
730 assert(partialsol !=
NULL);
734 SCIPdebugMsg(scip,
"+---+ Start Completesol heuristic +---+\n");
768 SCIP_CALL(
SCIPcopyConsCompression(scip, subscip, varmapf,
NULL,
"completesol",
NULL,
NULL, 0,
FALSE,
FALSE,
TRUE, &valid) );
769 SCIPdebugMsg(scip,
"Copying the SCIP instance was %s complete.\n", valid ?
"" :
"not ");
773 if( eventhdlr ==
NULL )
780 for( i = 0; i < nvars; i++ )
783 assert(subvars[i] !=
NULL);
793 SCIPdebugMsg(scip,
"Error while creating completesol subproblem w.r.t. partial solution <%p>.\n", (
void*)partialsol);
813 heurdata->nodelimit = heurdata->maxnodes;
852 SCIPdebugMsg(scip,
"solving subproblem: nstallnodes=%" SCIP_LONGINT_FORMAT
", maxnodes=%" SCIP_LONGINT_FORMAT
"\n", nstallnodes, heurdata->maxnodes);
870 for( i = 0; i < nsubsols && (!success || heurdata->addallsols); i++ )
877 SCIPstatisticPrintf(
"%s statistic: fixed %6.3f integer variables, needed %6.1f seconds, %" SCIP_LONGINT_FORMAT
" nodes, solution %10.4f found at node %" SCIP_LONGINT_FORMAT
"\n",
902 assert(heur !=
NULL);
917 assert(heur !=
NULL);
922 assert(heurdata !=
NULL);
946 assert( heur !=
NULL );
948 assert( result !=
NULL );
958 assert( heurdata !=
NULL );
982 nstallnodes += heurdata->nodesofs;
985 nstallnodes =
MIN(nstallnodes, heurdata->maxnodes);
988 if( nstallnodes < heurdata->minnodes )
990 SCIPdebugMsg(
scip,
"skipping Complete: nstallnodes=%" SCIP_LONGINT_FORMAT
", minnodes=%" SCIP_LONGINT_FORMAT
"\n",
991 nstallnodes, heurdata->minnodes);
1003 for( s = 0; s < npartialsols; s++ )
1009 sol = partialsols[s];
1010 assert(sol !=
NULL);
1015 for( v = 0; v < nvars; v++ )
1032 if( heurdata->ignorecont )
1035 unknownrate = nunknown/((
SCIP_Real)nvars);
1036 SCIPdebugMsg(
scip,
"%d (rate %.4f) unknown solution values\n", nunknown, unknownrate);
1039 if( unknownrate > heurdata->maxunknownrate )
1045 if( nunknown == 0 && nfracints == 0 )
1057 for( v = 0; v < norigvars; v++ )
1094 assert(heurdata !=
NULL);
1101 assert(heur !=
NULL);
1110 "maximum number of nodes to regard in the subproblem",
1114 "minimum number of nodes required to start the subproblem",
1118 "maximal rate of unknown solution values",
1122 "should all subproblem solutions be added to the original SCIP?",
1126 "number of nodes added to the contingent of the total nodes",
1130 "contingent of sub problem nodes in relation to the number of nodes of the original problem",
1134 "factor by which the limit on the number of LP depends on the node limit",
1138 "weight of the original objective function (1: only original objective)",
1142 "bound widening factor applied to continuous variables (0: fix variables to given solution values, 1: relax to global bounds)",
1146 "factor by which the incumbent should be improved at least",
1150 "should solution values for continuous variables be ignored?",
1154 "heuristic stops, if the given number of improving solutions were found (-1: no limit)",
1158 "maximal number of iterations in propagation (-1: no limit)",
enum SCIP_Result SCIP_RESULT
int SCIPgetNIntVars(SCIP *scip)
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
#define SCIP_EVENTTYPE_LPSOLVED
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
#define DEFAULT_NODESQUOT
static SCIP_RETCODE createSubproblem(SCIP *scip, SCIP *subscip, SCIP_HEURDATA *heurdata, SCIP_VAR **subvars, SCIP_SOL *partialsol, SCIP_Bool *tightened, SCIP_Bool *success)
SCIP_RETCODE SCIPbacktrackProbing(SCIP *scip, int probingdepth)
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)
int SCIPgetProbingDepth(SCIP *scip)
#define DEFAULT_MINOBJWEIGHT
SCIP_Real SCIPgetPrimalbound(SCIP *scip)
#define SCIPallocClearBufferArray(scip, ptr, num)
primal heuristic trying to complete given partial solutions
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
int SCIPgetNOrigVars(SCIP *scip)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
#define DEFAULT_MINIMPROVE
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
#define DEFAULT_MAXPROPROUNDS
SCIP_SOL ** SCIPgetSols(SCIP *scip)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr)
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)
SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
int SCIPgetNPartialSols(SCIP *scip)
SCIP_RETCODE SCIPcopyConsCompression(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
static SCIP_DECL_HEURCOPY(heurCopyCompletesol)
SCIP_Real SCIPinfinity(SCIP *scip)
#define DEFAULT_ADDALLSOLS
int SCIPsnprintf(char *t, int len, const char *s,...)
#define DEFAULT_BOUNDWIDENING
enum SCIP_Retcode SCIP_RETCODE
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
int SCIPvarGetProbindex(SCIP_VAR *var)
SCIP_RETCODE SCIPcreateVarBasic(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype)
SCIP_VAR ** SCIPgetOrigVars(SCIP *scip)
struct SCIP_HeurData SCIP_HEURDATA
#define SCIPfreeBlockMemory(scip, ptr)
SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, SCIP_HEURTIMING timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
SCIP_RETCODE SCIPchgVarLbProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
SCIP_Real SCIPfeasFrac(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define SCIPfreeBufferArray(scip, ptr)
SCIP_RETCODE SCIPcreate(SCIP **scip)
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_SOL ** SCIPgetPartialSols(SCIP *scip)
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)
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
int SCIPgetNContVars(SCIP *scip)
SCIP_RETCODE SCIPcreateOrigSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
enum SCIP_BranchDir SCIP_BRANCHDIR
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
static SCIP_DECL_EVENTEXEC(eventExecCompletesol)
SCIP_RETCODE SCIPsolve(SCIP *scip)
static SCIP_RETCODE tightenVariables(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR **vars, int nvars, SCIP_SOL *sol, SCIP_Bool *tightened)
const char * SCIPheurGetName(SCIP_HEUR *heur)
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPpropagateProbing(SCIP *scip, int maxproprounds, SCIP_Bool *cutoff, SCIP_Longint *ndomredsfound)
SCIP_RETCODE SCIPfixVarProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval)
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
SCIP_RETCODE SCIPendProbing(SCIP *scip)
struct SCIP_EventData SCIP_EVENTDATA
const char * SCIPvarGetName(SCIP_VAR *var)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
static SCIP_DECL_HEURFREE(heurFreeCompletesol)
SCIP_Real SCIPgetLowerbound(SCIP *scip)
static SCIP_RETCODE applyCompletesol(SCIP *scip, SCIP_HEUR *heur, SCIP_HEURDATA *heurdata, SCIP_RESULT *result, SCIP_Longint nstallnodes, SCIP_SOL *partialsol)
#define SCIPstatisticPrintf
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
#define DEFAULT_MAXUNKRATE
#define DEFAULT_IGNORECONT
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
#define SCIPallocBufferArray(scip, ptr, num)
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
public data structures and miscellaneous methods
SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
int SCIPgetNImplVars(SCIP *scip)
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
#define DEFAULT_OBJWEIGHT
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
SCIP_RETCODE SCIPdropEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_RETCODE SCIPincludeHeurCompletesol(SCIP *scip)
int SCIPgetNSols(SCIP *scip)
int SCIPgetNRuns(SCIP *scip)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success)
#define SCIP_MAXTREEDEPTH
int SCIPgetNBinVars(SCIP *scip)
static SCIP_RETCODE chgProbingBound(SCIP *scip, SCIP_VAR *var, SCIP_Real newval, SCIP_BRANCHDIR branchdir, SCIP_Bool *success)
int SCIPgetNVars(SCIP *scip)
static SCIP_DECL_HEUREXEC(heurExecCompletesol)
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
int SCIPgetNConss(SCIP *scip)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
SCIP_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
SCIP_NODESEL * SCIPfindNodesel(SCIP *scip, const char *name)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
SCIP_Bool SCIPisStopped(SCIP *scip)
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_RETCODE SCIPnewProbingNode(SCIP *scip)
SCIP_Real SCIPsumepsilon(SCIP *scip)
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
SCIP_Real SCIPgetUpperbound(SCIP *scip)
SCIP_RETCODE SCIPstartProbing(SCIP *scip)
SCIP_Bool SCIPsolIsPartial(SCIP_SOL *sol)
common defines and data types used in all packages of SCIP
#define SCIP_CALL_ABORT(x)
SCIP_Real SCIPceil(SCIP *scip, SCIP_Real val)
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_Longint SCIPgetNLPs(SCIP *scip)
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
SCIP_RETCODE SCIPchgVarUbProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
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)
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
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)
SCIP_Bool SCIPvarIsActive(SCIP_VAR *var)
SCIP_RETCODE SCIPfree(SCIP **scip)
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)