46 #define HEUR_NAME "vbounds" 47 #define HEUR_DESC "LNS heuristic uses the variable lower and upper bounds to determine the search neighborhood" 48 #define HEUR_DISPCHAR 'V' 49 #define HEUR_PRIORITY -1106000 51 #define HEUR_FREQOFS 0 52 #define HEUR_MAXDEPTH -1 53 #define HEUR_TIMING SCIP_HEURTIMING_BEFORENODE 54 #define HEUR_USESSUBSCIP TRUE 56 #define DEFAULT_MAXNODES 5000LL 57 #define DEFAULT_MINFIXINGRATE 0.25 58 #define DEFAULT_MINIMPROVE 0.01 59 #define DEFAULT_MINNODES 500LL 60 #define DEFAULT_NODESOFS 500LL 61 #define DEFAULT_NODESQUOT 0.1 62 #define DEFAULT_MAXPROPROUNDS 2 63 #define DEFAULT_COPYCUTS TRUE 104 #define getLbIndex(idx) (2*(idx)) 105 #define getUbIndex(idx) (2*(idx)+1) 106 #define getVarIndex(idx) ((idx)/2) 107 #define getBoundtype(idx) (((idx) % 2 == 0) ? SCIP_BOUNDTYPE_LOWER : SCIP_BOUNDTYPE_UPPER) 108 #define isIndexLowerbound(idx) ((idx) % 2 == 0) 125 heurdata->vbvars =
NULL;
126 heurdata->vbbounds =
NULL;
127 heurdata->nvbvars = 0;
128 heurdata->initialized =
FALSE;
129 heurdata->applicable =
FALSE;
161 assert(startnode >= 0);
163 assert(visited !=
NULL);
164 assert(visited[startnode] ==
FALSE);
165 assert(dfsstack !=
NULL);
166 assert(dfsnodes !=
NULL);
167 assert(ndfsnodes !=
NULL);
172 dfsstack[0] = startnode;
173 stacknextedge[0] = 0;
178 while( stacksize > 0 )
181 curridx = dfsstack[stacksize - 1];
184 assert(visited[curridx] == (stacknextedge[stacksize - 1] > 0));
185 visited[curridx] =
TRUE;
205 for( i = stacknextedge[stacksize - 1]; i < nvbvars; ++i )
221 assert(!visited[idx]);
224 dfsstack[stacksize] = idx;
225 stacknextedge[stacksize] = 0;
226 stacknextedge[stacksize - 1] = i + 1;
240 dfsnodes[(*ndfsnodes)] = curridx;
244 visited[curridx] =
FALSE;
265 assert(scip !=
NULL);
278 for( i = 0; i < nbounds; ++i )
282 SCIP_CALL(
dfs(scip, i, inqueue, dfsstack, stacknextedge, vbvars, nvbvars) );
285 assert(*nvbvars <= nbounds);
320 if( nvbs >= heurdata->minfixingrate * nvars )
326 for( v = 0; v < nvbs; ++v )
334 heurdata->nvbvars = nvbs;
335 heurdata->applicable =
TRUE;
342 heurdata->usednodes = 0;
343 heurdata->initialized =
TRUE;
370 for( v = 0; v < nvbvars && !(*infeasible); ++v )
373 bound = heurdata->vbbounds[v];
423 SCIPdebugMsg(scip,
"fixing %d: variable <%s> to lower bound <%g> (%d pseudo cands)\n",
444 SCIPdebugMsg(scip,
"fixing %d: variable <%s> to upper bound <%g> (%d pseudo cands)\n",
453 SCIPdebugMsg(scip,
"probing ended with %sfeasible problem\n", (*infeasible) ?
"in" :
"");
473 assert( scip !=
NULL );
474 assert( subscip !=
NULL );
475 assert( subvars !=
NULL );
476 assert( subsol !=
NULL );
530 assert(heur !=
NULL);
531 assert(heurdata !=
NULL);
542 if( nvbvars < nvars * heurdata->minfixingrate )
556 nstallnodes += heurdata->nodesofs;
559 nstallnodes -= heurdata->usednodes;
560 nstallnodes =
MIN(nstallnodes, heurdata->maxnodes);
563 if( nstallnodes < heurdata->minnodes )
565 SCIPdebugMsg(scip,
"skipping " HEUR_NAME ": nstallnodes=%" SCIP_LONGINT_FORMAT
", minnodes=%" SCIP_LONGINT_FORMAT
"\n", nstallnodes, heurdata->minnodes);
575 SCIPdebugMsg(scip,
"apply variable bounds heuristic at node %lld on %d variable bounds\n",
608 &lastfixedvar, &lastfixedlower) );
613 assert(lastfixedvar !=
NULL);
624 SCIPdebugMsg(scip,
"backtracking ended with %sfeasible problem\n", (infeasible ?
"in" :
""));
630 SCIPdebugMsg(scip,
"npscands=%d, oldnpscands=%d, heurdata->minfixingrate=%g\n", npscands, oldnpscands, heurdata->minfixingrate);
633 if( npscands > oldnpscands * (1 - heurdata->minfixingrate) )
645 if( !infeasible && solvelp )
659 SCIPwarningMessage(scip,
"Error while solving LP in vbound heuristic; LP solve terminated with code <%d>\n",
671 SCIPdebugMsg(scip,
" -> error=%u, status=%d\n", lperror, lpstatus);
687 SCIPdebugMsg(scip,
"vbound heuristic found roundable primal solution: obj=%g\n",
737 SCIP_CALL(
SCIPcopyConsCompression(scip, subscip, varmap,
NULL,
"_vbounds",
NULL,
NULL, 0,
FALSE,
FALSE,
TRUE,
NULL) );
739 if( heurdata->copycuts )
747 for( i = 0; i < nvars; i++ )
819 minimprove = heurdata->minimprove;
835 cutoff =
MIN(upperbound, cutoff);
849 SCIPwarningMessage(scip,
"Error while presolving subMIP in vbounds heuristic; sub-SCIP terminated with code <%d>\n", retstat);
869 SCIPdebugMsg(scip,
"solving subproblem: nstallnodes=%" SCIP_LONGINT_FORMAT
", maxnodes=%" SCIP_LONGINT_FORMAT
"\n", nstallnodes, heurdata->maxnodes);
877 SCIPwarningMessage(scip,
"Error while solving subMIP in vbounds heuristic; sub-SCIP terminated with code <%d>\n",retstat);
891 for( i = 0; i < nsubsols && !success; ++i )
910 #ifdef SCIP_STATISTIC 912 SCIPstatisticMessage(
"vbound: tighten=%d obj=%d nvars=%d presolnvars=%d ratio=%.2f infeas=%d found=%d time=%.2f\n",
913 tighten, obj, nvars, nprevars, (nvars - nprevars) / (
SCIP_Real)nvars, infeasible,
938 assert(heur !=
NULL);
971 assert(heurdata !=
NULL);
974 for( v = 0; v < heurdata->nvbvars; ++v )
995 assert( heur !=
NULL );
996 assert( scip !=
NULL );
997 assert( result !=
NULL );
1005 assert(heurdata !=
NULL);
1007 if( !heurdata->initialized )
1012 if( !heurdata->applicable )
1045 assert(heur !=
NULL);
1054 "minimum percentage of integer variables that have to be fixable",
1058 "maximum number of nodes to regard in the subproblem",
1062 "number of nodes added to the contingent of the total nodes",
1066 "minimum number of nodes required to start the subproblem",
1070 "contingent of sub problem nodes in relation to the number of nodes of the original problem",
1074 "factor by which " HEUR_NAME " heuristic should at least improve the incumbent",
1078 "maximum number of propagation rounds during probing (-1 infinity)",
1082 "should all active cuts from cutpool be copied to constraints in subproblem?",
enum SCIP_Result SCIP_RESULT
SCIP_RETCODE SCIPsetHeurExitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol)))
enum SCIP_BoundType SCIP_BOUNDTYPE
#define DEFAULT_NODESQUOT
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_Real * SCIPvarGetVlbCoefs(SCIP_VAR *var)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
SCIP_RETCODE SCIPbacktrackProbing(SCIP *scip, int probingdepth)
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
SCIP_RETCODE SCIPincludeHeurVbounds(SCIP *scip)
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
int SCIPgetProbingDepth(SCIP *scip)
int SCIPvarGetNVlbs(SCIP_VAR *var)
static void heurdataReset(SCIP_HEURDATA *heurdata)
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
internal methods for clocks and timing issues
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
int SCIPgetNOrigVars(SCIP *scip)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
int SCIPgetNPseudoBranchCands(SCIP *scip)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIP_RETCODE SCIPstopClock(SCIP *scip, SCIP_CLOCK *clck)
#define isIndexLowerbound(idx)
static SCIP_RETCODE initializeCandsLists(SCIP *scip, SCIP_HEURDATA *heurdata)
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
SCIP_SOL ** SCIPgetSols(SCIP *scip)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
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)
static SCIP_RETCODE applyVboundsFixings(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR **vars, int nvbvars, SCIP_Bool tighten, SCIP_Bool obj, SCIP_Bool *infeasible, SCIP_VAR **lastvar, SCIP_Bool *fixedtolb)
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)
SCIP_RETCODE SCIPcutoffNode(SCIP *scip, SCIP_NODE *node)
enum SCIP_Retcode SCIP_RETCODE
#define SCIPstatisticMessage
int SCIPvarGetNVubs(SCIP_VAR *var)
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
#define DEFAULT_MINIMPROVE
int SCIPvarGetProbindex(SCIP_VAR *var)
struct SCIP_HeurData SCIP_HEURDATA
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_SOL *newsol, SCIP_SOL *subsol, SCIP_Bool *success)
#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_VAR ** SCIPvarGetVlbVars(SCIP_VAR *var)
SCIP_RETCODE SCIPfreeClock(SCIP *scip, SCIP_CLOCK **clck)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
SCIP_RETCODE SCIPconstructLP(SCIP *scip, SCIP_Bool *cutoff)
#define SCIPfreeBufferArray(scip, ptr)
enum SCIP_LPSolStat SCIP_LPSOLSTAT
SCIP_RETCODE SCIPcreate(SCIP **scip)
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
#define SCIPallocBlockMemory(scip, ptr)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
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)
const char * SCIPgetProbName(SCIP *scip)
SCIP_Bool SCIPisLPConstructed(SCIP *scip)
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
SCIP_RETCODE SCIPsolve(SCIP *scip)
const char * SCIPheurGetName(SCIP_HEUR *heur)
SCIP_RETCODE SCIPcreateClock(SCIP *scip, SCIP_CLOCK **clck)
static SCIP_RETCODE topologicalSort(SCIP *scip, int *vbvars, int *nvbvars)
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
SCIP_RETCODE SCIPpropagateProbing(SCIP *scip, int maxproprounds, SCIP_Bool *cutoff, SCIP_Longint *ndomredsfound)
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
SCIP_RETCODE SCIPfixVarProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval)
static SCIP_RETCODE applyVbounds(SCIP *scip, SCIP_HEUR *heur, SCIP_HEURDATA *heurdata, SCIP_VAR **vbvars, int nvbvars, SCIP_Bool tighten, SCIP_Bool obj, SCIP_RESULT *result)
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
SCIP_RETCODE SCIPpresolve(SCIP *scip)
#define DEFAULT_MINFIXINGRATE
SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
static SCIP_DECL_HEURCOPY(heurCopyVbounds)
SCIP_RETCODE SCIPendProbing(SCIP *scip)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
SCIP_Real SCIPgetLowerbound(SCIP *scip)
SCIP_RETCODE SCIPsolveProbingLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
SCIP_Real * SCIPvarGetVubCoefs(SCIP_VAR *var)
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
static SCIP_DECL_HEUREXEC(heurExecVbounds)
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
#define SCIPallocBufferArray(scip, ptr, num)
SCIP_RETCODE SCIPclearSol(SCIP *scip, SCIP_SOL *sol)
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
static SCIP_DECL_HEUREXITSOL(heurExitsolVbounds)
SCIP_RETCODE SCIProundSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *success)
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
int SCIPgetDepth(SCIP *scip)
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
LNS heuristic uses the variable lower and upper bounds to determine the search neighborhood.
int SCIPgetNSols(SCIP *scip)
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
SCIP_RETCODE SCIPflushLP(SCIP *scip)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPtrySol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
#define SCIP_MAXTREEDEPTH
static SCIP_RETCODE dfs(SCIP *scip, int startnode, SCIP_Bool *visited, int *dfsstack, int *stacknextedge, int *dfsnodes, int *ndfsnodes)
int SCIPgetNVars(SCIP *scip)
#define getBoundtype(idx)
int SCIPgetNConss(SCIP *scip)
SCIP_NODESEL * SCIPfindNodesel(SCIP *scip, const char *name)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
SCIP_RETCODE SCIPcaptureVar(SCIP *scip, SCIP_VAR *var)
SCIP_Bool SCIPisStopped(SCIP *scip)
SCIP_VAR ** SCIPvarGetVubVars(SCIP_VAR *var)
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
SCIP_RETCODE SCIPnewProbingNode(SCIP *scip)
SCIP_Real SCIPsumepsilon(SCIP *scip)
SCIP_Real SCIPgetUpperbound(SCIP *scip)
SCIP_RETCODE SCIPstartProbing(SCIP *scip)
#define BMSclearMemoryArray(ptr, num)
#define SCIP_CALL_ABORT(x)
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
static SCIP_DECL_HEURFREE(heurFreeVbounds)
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_RETCODE SCIPstartClock(SCIP *scip, SCIP_CLOCK *clck)
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_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
#define DEFAULT_MAXPROPROUNDS
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)