32 #define HEUR_NAME "localbranching" 33 #define HEUR_DESC "local branching heuristic by Fischetti and Lodi" 34 #define HEUR_DISPCHAR 'L' 35 #define HEUR_PRIORITY -1102000 37 #define HEUR_FREQOFS 0 38 #define HEUR_MAXDEPTH -1 39 #define HEUR_TIMING SCIP_HEURTIMING_AFTERNODE 40 #define HEUR_USESSUBSCIP TRUE 42 #define DEFAULT_NEIGHBORHOODSIZE 18 43 #define DEFAULT_NODESOFS 1000 44 #define DEFAULT_MAXNODES 10000 45 #define DEFAULT_MINIMPROVE 0.01 46 #define DEFAULT_MINNODES 1000 47 #define DEFAULT_NODESQUOT 0.05 48 #define DEFAULT_LPLIMFAC 1.5 49 #define DEFAULT_NWAITINGNODES 200 50 #define DEFAULT_USELPROWS FALSE 52 #define DEFAULT_COPYCUTS TRUE 55 #define DEFAULT_BESTSOLLIMIT 3 56 #define DEFAULT_USEUCT FALSE 59 #define EVENTHDLR_NAME "Localbranching" 60 #define EVENTHDLR_DESC "LP event handler for " HEUR_NAME " heuristic" 64 #define WAITFORNEWSOL 1 86 int curneighborhoodsize;
88 int emptyneighborhoodsize;
128 assert( bestsol !=
NULL );
135 lhs = (
SCIP_Real)heurdata->emptyneighborhoodsize + 1.0;
136 rhs = (
SCIP_Real)heurdata->curneighborhoodsize;
139 for( i = 0; i < nbinvars; i++ )
155 consvars[i] = subvars[i];
161 lhs, rhs,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
TRUE,
TRUE,
FALSE) );
189 assert( scip !=
NULL );
190 assert( subscip !=
NULL );
191 assert( subvars !=
NULL );
192 assert( subsol !=
NULL );
229 assert(eventhdlr !=
NULL);
230 assert(eventdata !=
NULL);
232 assert(event !=
NULL);
236 assert(heurdata !=
NULL);
258 assert(heur !=
NULL);
273 assert( heur !=
NULL );
278 assert( heurdata !=
NULL );
294 assert( heur !=
NULL );
299 assert( heurdata !=
NULL );
303 heurdata->lastsol =
NULL;
304 heurdata->usednodes = 0;
305 heurdata->curneighborhoodsize = heurdata->neighborhoodsize;
306 heurdata->curminnodes = heurdata->minnodes;
307 heurdata->emptyneighborhoodsize = 0;
337 assert(heur !=
NULL);
339 assert(result !=
NULL);
345 assert( heurdata !=
NULL );
358 assert(bestsol !=
NULL);
373 if( heurdata->lastsol != bestsol )
375 heurdata->curneighborhoodsize = heurdata->neighborhoodsize;
376 heurdata->curminnodes = heurdata->minnodes;
377 heurdata->emptyneighborhoodsize = 0;
378 heurdata->callstatus =
EXECUTE;
379 heurdata->lastsol = bestsol;
394 maxnnodes += heurdata->nodesofs;
397 nsubnodes = maxnnodes - heurdata->usednodes;
398 nsubnodes =
MIN(nsubnodes, heurdata->maxnodes);
401 if( nsubnodes < heurdata->curminnodes )
431 heurdata->copycuts, &success,
NULL) );
436 if( eventhdlr ==
NULL )
444 SCIPdebugMsg(
scip,
"Copying the plugins was %ssuccessful.\n", success ?
"" :
"not ");
446 for (i = 0; i < nvars; ++i)
474 heurdata->nodelimit = nsubnodes;
547 cutoff =
MIN(upperbound, cutoff );
551 if( !heurdata->uselprows )
553 assert(eventhdlr !=
NULL);
560 SCIPdebugMsg(
scip,
"solving local branching subproblem with neighborhoodsize %d and maxnodes %" SCIP_LONGINT_FORMAT
"\n",
561 heurdata->curneighborhoodsize, nsubnodes);
570 if( !heurdata->uselprows )
572 assert(eventhdlr !=
NULL);
581 SCIPdebugMsg(
scip,
"local branching used %" SCIP_LONGINT_FORMAT
"/%" SCIP_LONGINT_FORMAT
" nodes\n",
596 for( i = 0; i < nsubsols && !success; ++i )
619 heurdata->callstatus =
EXECUTE;
620 heurdata->curneighborhoodsize = (heurdata->emptyneighborhoodsize + heurdata->curneighborhoodsize)/2;
621 heurdata->curminnodes *= 2;
622 SCIPdebugMsg(
scip,
" -> node limit reached: reduced neighborhood to %d, increased minnodes to %d\n",
623 heurdata->curneighborhoodsize, heurdata->curminnodes);
624 if( heurdata->curneighborhoodsize <= heurdata->emptyneighborhoodsize )
627 SCIPdebugMsg(
scip,
" -> new neighborhood was already proven to be empty: wait for new solution\n");
633 heurdata->emptyneighborhoodsize = heurdata->curneighborhoodsize;
634 heurdata->curneighborhoodsize += heurdata->curneighborhoodsize/2;
635 heurdata->curneighborhoodsize =
MAX(heurdata->curneighborhoodsize, heurdata->emptyneighborhoodsize + 2);
636 heurdata->callstatus =
EXECUTE;
637 SCIPdebugMsg(
scip,
" -> neighborhood is empty: increased neighborhood to %d\n", heurdata->curneighborhoodsize);
683 assert(heur !=
NULL);
692 "number of nodes added to the contingent of the total nodes",
696 "radius (using Manhattan metric) of the incumbent's neighborhood to be searched",
700 "contingent of sub problem nodes in relation to the number of nodes of the original problem",
704 "factor by which the limit on the number of LP depends on the node limit",
708 "minimum number of nodes required to start the subproblem",
712 "maximum number of nodes to regard in the subproblem",
716 "number of nodes without incumbent change that heuristic should wait",
720 "factor by which localbranching should at least improve the incumbent",
724 "should subproblem be created out of the rows in the LP rows?",
728 "if uselprows == FALSE, should all active cuts from cutpool be copied to constraints in subproblem?",
732 "limit on number of improving incumbent solutions in sub-CIP",
736 "should uct node selection be used at the beginning of the search?",
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
#define SCIP_EVENTTYPE_LPSOLVED
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define DEFAULT_NODESQUOT
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
int SCIPgetNOrigVars(SCIP *scip)
static SCIP_RETCODE addLocalBranchingConstraint(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEURDATA *heurdata)
SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
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)
const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr)
#define DEFAULT_NWAITINGNODES
SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
int SCIPsnprintf(char *t, int len, const char *s,...)
enum SCIP_Retcode SCIP_RETCODE
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
static SCIP_DECL_HEURINIT(heurInitLocalbranching)
struct SCIP_HeurData SCIP_HEURDATA
SCIP_RETCODE SCIPincludeHeurLocalbranching(SCIP *scip)
#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)
#define DEFAULT_BESTSOLLIMIT
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
static SCIP_DECL_HEUREXEC(heurExecLocalbranching)
#define SCIPfreeBufferArray(scip, ptr)
SCIP_RETCODE SCIPcreate(SCIP **scip)
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
#define SCIPallocBlockMemory(scip, ptr)
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_RETCODE SCIPsolve(SCIP *scip)
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_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
SCIP_STATUS SCIPgetStatus(SCIP *scip)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Local branching heuristic according to Fischetti and Lodi.
struct SCIP_EventData SCIP_EVENTDATA
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
SCIP_Real SCIPgetLowerbound(SCIP *scip)
#define DEFAULT_NEIGHBORHOODSIZE
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
#define SCIPallocBufferArray(scip, ptr, num)
public data structures and miscellaneous methods
SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success)
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
#define DEFAULT_MINIMPROVE
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)
int SCIPgetNSols(SCIP *scip)
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
Constraint handler for linear constraints in their most general form, .
static SCIP_DECL_HEURFREE(heurFreeLocalbranching)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
int SCIPgetNBinVars(SCIP *scip)
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)
static SCIP_DECL_EVENTEXEC(eventExecLocalbranching)
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
SCIP_NODESEL * SCIPfindNodesel(SCIP *scip, const char *name)
SCIP_RETCODE SCIPcopyLargeNeighborhoodSearch(SCIP *sourcescip, SCIP *subscip, SCIP_HASHMAP *varmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool uselprows, SCIP_Bool copycuts, SCIP_Bool *success, SCIP_Bool *valid)
SCIP_Bool SCIPisStopped(SCIP *scip)
static SCIP_DECL_HEURCOPY(heurCopyLocalbranching)
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 SCIPtransformProb(SCIP *scip)
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPsumepsilon(SCIP *scip)
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
SCIP_Real SCIPgetUpperbound(SCIP *scip)
#define DEFAULT_USELPROWS
#define SCIP_CALL_ABORT(x)
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_Longint SCIPgetNLPs(SCIP *scip)
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_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_RETCODE SCIPfree(SCIP **scip)
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
SCIP_Longint SCIPgetSolNodenum(SCIP *scip, SCIP_SOL *sol)