33 #define HEUR_NAME "rens" 34 #define HEUR_DESC "LNS exploring fractional neighborhood of relaxation's optimum" 35 #define HEUR_DISPCHAR 'E' 36 #define HEUR_PRIORITY -1100000 38 #define HEUR_FREQOFS 0 39 #define HEUR_MAXDEPTH -1 40 #define HEUR_TIMING SCIP_HEURTIMING_AFTERLPNODE 41 #define HEUR_USESSUBSCIP TRUE 44 #define DEFAULT_BINARYBOUNDS TRUE 45 #define DEFAULT_MAXNODES 5000LL 46 #define DEFAULT_MINFIXINGRATE 0.5 47 #define DEFAULT_MINIMPROVE 0.01 48 #define DEFAULT_MINNODES 50LL 49 #define DEFAULT_NODESOFS 500LL 50 #define DEFAULT_NODESQUOT 0.1 51 #define DEFAULT_LPLIMFAC 2.0 52 #define DEFAULT_STARTSOL 'l' 53 #define STARTSOL_CHOICES "nl" 54 #define DEFAULT_USELPROWS FALSE 56 #define DEFAULT_COPYCUTS TRUE 59 #define DEFAULT_EXTRATIME FALSE 62 #define DEFAULT_ADDALLSOLS FALSE 64 #define DEFAULT_FULLSCALE FALSE 68 #define DEFAULT_BESTSOLLIMIT -1 69 #define DEFAULT_USEUCT FALSE 72 #define EVENTHDLR_NAME "Rens" 73 #define EVENTHDLR_DESC "LP event handler for " HEUR_NAME " heuristic" 130 assert(fixedvars !=
NULL);
131 assert(fixedvals !=
NULL);
132 assert(nfixedvars !=
NULL);
140 SCIPdebugMsg(scip,
"no NLP present, use LP relaxation instead\n");
146 assert(fixedvarssize >= nbinvars + nintvars);
150 if( (*startsol) ==
'n' )
162 SCIPdebugMsg(scip,
"try to solve NLP relaxation to obtain fixing values\n");
173 SCIPdebugMsg(scip,
"solving NLP relaxation was %s successful (stat=%d)\n", *success ?
"" :
"not", stat);
184 assert(*startsol ==
'l');
188 for( i = 0; i < nbinvars + nintvars; ++i )
202 fixedvars[(*nfixedvars)] = vars[i];
203 fixedvals[(*nfixedvars)] = solval;
211 if( (*nfixedvars) == nbinvars + nintvars )
214 *fixingrate = (*nfixedvars) / (
SCIP_Real)(
MAX(nbinvars + nintvars, 1));
217 if( *fixingrate < minfixingrate )
239 assert(scip !=
NULL);
240 assert(subscip !=
NULL);
241 assert(subvars !=
NULL);
243 assert(startsol ==
'l' || startsol ==
'n');
249 for( i = nbinvars; i < nbinvars + nintvars; i++ )
299 assert(scip !=
NULL);
300 assert(subscip !=
NULL);
301 assert(subvars !=
NULL);
302 assert(subsol !=
NULL);
340 assert(eventhdlr !=
NULL);
341 assert(eventdata !=
NULL);
343 assert(event !=
NULL);
347 assert(heurdata !=
NULL);
398 assert(scip !=
NULL);
399 assert(heur !=
NULL);
400 assert(result !=
NULL);
402 assert(maxnodes >= 0);
403 assert(nstallnodes >= 0);
405 assert(0.0 <= minfixingrate && minfixingrate <= 1.0);
406 assert(0.0 <= minimprove && minimprove <= 1.0);
407 assert(startsol ==
'l' || startsol ==
'n');
415 fixedvarssize = nbinvars + nintvars;
421 SCIP_CALL(
computeFixingrate(scip, fixedvars, fixedvals, &nfixedvars, fixedvarssize, minfixingrate, &startsol, &intfixingrate, &success) );
425 SCIPstatisticPrintf(
"RENS statistic: fixed only %5.2f integer variables --> abort \n", intfixingrate);
431 assert(heurdata !=
NULL);
452 heurdata->copycuts, &success,
NULL) );
457 if( eventhdlr ==
NULL )
465 for( i = 0; i < nvars; i++ )
494 heurdata->nodelimit = maxnodes;
503 if( !heurdata->fullscale )
574 cutoff =
MIN(upperbound, cutoff);
586 SCIPwarningMessage(scip,
"Error while presolving subproblem in RENS heuristic; sub-SCIP terminated with code <%d>\n", retcode);
601 allfixingrate =
MAX(allfixingrate, 0.0);
606 if( allfixingrate >= minfixingrate / 2.0 )
612 assert(eventhdlr !=
NULL);
617 SCIPdebugMsg(scip,
"solving subproblem: nstallnodes=%" SCIP_LONGINT_FORMAT
", maxnodes=%" SCIP_LONGINT_FORMAT
"\n", nstallnodes, maxnodes);
628 SCIPwarningMessage(scip,
"Error while solving subproblem in RENS heuristic; sub-SCIP terminated with code <%d>\n", retcode);
646 for( i = 0; i < nsubsols && (!success || heurdata->addallsols); ++i )
653 SCIPstatisticPrintf(
"RENS statistic: fixed %6.3f integer variables, %6.3f all variables, needed %6.1f seconds, %" SCIP_LONGINT_FORMAT
" nodes, solution %10.4f found at node %" SCIP_LONGINT_FORMAT
"\n",
659 SCIPstatisticPrintf(
"RENS statistic: fixed only %6.3f integer variables, %6.3f all variables --> abort \n", intfixingrate, allfixingrate);
684 assert(heur !=
NULL);
699 assert( heur !=
NULL );
704 assert( heurdata !=
NULL );
719 assert( heur !=
NULL );
724 assert( heurdata !=
NULL );
727 heurdata->usednodes = 0;
741 assert( heur !=
NULL );
743 assert( result !=
NULL );
754 assert( heurdata !=
NULL );
780 nstallnodes += heurdata->nodesofs;
783 nstallnodes -= heurdata->usednodes;
784 nstallnodes =
MIN(nstallnodes, heurdata->maxnodes);
787 if( nstallnodes < heurdata->minnodes )
789 SCIPdebugMsg(
scip,
"skipping RENS: nstallnodes=%" SCIP_LONGINT_FORMAT
", minnodes=%" SCIP_LONGINT_FORMAT
"\n", nstallnodes, heurdata->minnodes);
797 heurdata->maxnodes, nstallnodes, heurdata->startsol, heurdata->binarybounds, heurdata->uselprows) );
823 assert(heur !=
NULL);
833 "minimum percentage of integer variables that have to be fixable",
837 "maximum number of nodes to regard in the subproblem",
841 "number of nodes added to the contingent of the total nodes",
845 "minimum number of nodes required to start the subproblem",
849 "contingent of sub problem nodes in relation to the number of nodes of the original problem",
853 "factor by which RENS should at least improve the incumbent",
857 "factor by which the limit on the number of LP depends on the node limit",
861 "solution that is used for fixing values ('l'p relaxation, 'n'lp relaxation)",
865 "should general integers get binary bounds [floor(.),ceil(.)] ?",
869 "should subproblem be created out of the rows in the LP rows?",
873 "if uselprows == FALSE, should all active cuts from cutpool be copied to constraints in subproblem?",
877 "should the RENS sub-CIP get its own full time limit? This is only for tesing and not recommended!",
881 "should all subproblem solutions be added to the original SCIP?",
885 "should the RENS sub-CIP be solved with cuts, conflicts, strong branching,... This is only for tesing and not recommended!",
889 "limit on number of improving incumbent solutions in sub-CIP",
893 "should uct node selection be used at the beginning of the search?",
enum SCIP_Result SCIP_RESULT
static SCIP_DECL_HEURINIT(heurInitRens)
int SCIPgetNIntVars(SCIP *scip)
#define DEFAULT_BINARYBOUNDS
static SCIP_DECL_HEUREXEC(heurExecRens)
SCIP_RETCODE SCIPchgVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
#define SCIP_EVENTTYPE_LPSOLVED
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_Bool SCIPisNLPConstructed(SCIP *scip)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPgetNLPIntPar(SCIP *scip, SCIP_NLPPARAM type, int *ival)
SCIP_RETCODE SCIPapplyRens(SCIP *scip, SCIP_HEUR *heur, SCIP_RESULT *result, SCIP_Real minfixingrate, SCIP_Real minimprove, SCIP_Longint maxnodes, SCIP_Longint nstallnodes, char startsol, SCIP_Bool binarybounds, SCIP_Bool uselprows)
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
SCIP_Real SCIPgetCutoffbound(SCIP *scip)
SCIP_Real SCIPgetPrimalbound(SCIP *scip)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
#define DEFAULT_BESTSOLLIMIT
int SCIPgetNOrigVars(SCIP *scip)
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_NLPSOLSTAT SCIPgetNLPSolstat(SCIP *scip)
#define DEFAULT_EXTRATIME
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)
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)
SCIP_Real SCIPinfinity(SCIP *scip)
enum SCIP_Retcode SCIP_RETCODE
SCIP_RETCODE SCIPsolveNLP(SCIP *scip)
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
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 SCIPincludeHeurRens(SCIP *scip)
SCIP_RETCODE SCIPsetNLPIntPar(SCIP *scip, SCIP_NLPPARAM type, int ival)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
#define SCIPfreeBufferArray(scip, ptr)
SCIP_RETCODE SCIPcreate(SCIP **scip)
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
#define SCIPallocBlockMemory(scip, ptr)
int SCIPgetNLPBranchCands(SCIP *scip)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_RETCODE SCIPchgVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
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_Real SCIPfeasCeil(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPfeasFloor(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
#define DEFAULT_MINIMPROVE
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success)
SCIP_RETCODE SCIPsolve(SCIP *scip)
const char * SCIPheurGetName(SCIP_HEUR *heur)
#define DEFAULT_USELPROWS
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
enum SCIP_NlpSolStat SCIP_NLPSOLSTAT
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_RETCODE SCIPpresolve(SCIP *scip)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
struct SCIP_EventData SCIP_EVENTDATA
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
SCIP_RETCODE SCIPmergeVariableStatistics(SCIP *sourcescip, SCIP *targetscip, SCIP_VAR **sourcevars, SCIP_VAR **targetvars, int nvars)
int SCIPgetNNlpis(SCIP *scip)
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
SCIP_RETCODE SCIPsetNLPInitialGuessSol(SCIP *scip, SCIP_SOL *sol)
static SCIP_DECL_HEURFREE(heurFreeRens)
SCIP_Real SCIPgetLowerbound(SCIP *scip)
#define SCIPstatisticPrintf
LNS heuristic that finds the optimal rounding to a given point.
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
#define DEFAULT_MINFIXINGRATE
static SCIP_RETCODE restrictToBinaryBounds(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, char startsol)
#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_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
SCIP_Real SCIPvarGetNLPSol(SCIP_VAR *var)
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)
static SCIP_DECL_HEURCOPY(heurCopyRens)
SCIP_RETCODE SCIPdropEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
int SCIPgetNSols(SCIP *scip)
Constraint handler for linear constraints in their most general form, .
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
int SCIPgetNBinVars(SCIP *scip)
int SCIPgetNVars(SCIP *scip)
#define DEFAULT_ADDALLSOLS
SCIP_Real SCIPgetLPObjval(SCIP *scip)
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
SCIP_RETCODE SCIPaddCharParam(SCIP *scip, const char *name, const char *desc, char *valueptr, SCIP_Bool isadvanced, char defaultvalue, const char *allowedvalues, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
int SCIPgetNConss(SCIP *scip)
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)
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
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)
static SCIP_RETCODE computeFixingrate(SCIP *scip, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int *nfixedvars, int fixedvarssize, SCIP_Real minfixingrate, char *startsol, SCIP_Real *fixingrate, SCIP_Bool *success)
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
SCIP_Real SCIPgetUpperbound(SCIP *scip)
#define DEFAULT_FULLSCALE
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_Longint SCIPgetNLPs(SCIP *scip)
#define DEFAULT_NODESQUOT
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)
static SCIP_DECL_EVENTEXEC(eventExecRens)
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)