37 #define HEUR_NAME "randrounding" 38 #define HEUR_DESC "fast LP rounding heuristic" 39 #define HEUR_DISPCHAR 'G' 40 #define HEUR_PRIORITY -200 42 #define HEUR_FREQOFS 0 43 #define HEUR_MAXDEPTH -1 44 #define HEUR_TIMING SCIP_HEURTIMING_DURINGLPLOOP 45 #define HEUR_USESSUBSCIP FALSE 47 #define DEFAULT_ONCEPERNODE FALSE 48 #define DEFAULT_RANDSEED 23 49 #define DEFAULT_USESIMPLEROUNDING FALSE 51 #define DEFAULT_MAXPROPROUNDS 1 52 #define DEFAULT_PROPAGATEONLYROOT TRUE 90 assert(heurdata !=
NULL);
102 assert(permutedcands !=
NULL);
108 for (c = 0; c < ncands && !cutoff; ++c)
122 var = permutedcands[c];
135 SCIPdebugMsg(scip,
"rand rounding heuristic: var <%s>, val=%g, rounddown=%u, roundup=%u\n",
140 if( lb > ceilval + 0.5 || ub < floorval - 0.5 )
155 newsolval = floorval;
157 else if( !heurdata->usesimplerounding || !(mayroundup || mayrounddown) )
163 if( randnumber <= oldsolval - floorval )
166 newsolval = floorval;
169 else if( mayrounddown && mayroundup )
173 newsolval = floorval;
177 else if( mayrounddown )
178 newsolval = floorval;
194 lbadjust =
SCIPisGT(scip, newsolval, lb);
195 ubadjust =
SCIPisLT(scip, newsolval, ub);
197 assert( lbadjust || ubadjust ||
SCIPisFeasEQ(scip, lb, ub));
200 if( lbadjust || ubadjust )
256 SCIPdebugMsg(scip,
"found feasible rounded solution:\n");
309 assert( sol !=
NULL );
316 if( nlps == heurdata->lastlp )
318 heurdata->lastlp = nlps;
323 SCIPdebugMsg(scip,
"executing rand LP-rounding heuristic: %d fractionals\n", nlpcands);
337 assert(scip !=
NULL);
338 assert(heur !=
NULL);
353 assert(heur !=
NULL);
355 assert(scip !=
NULL);
359 assert(heurdata !=
NULL);
374 assert(heurdata !=
NULL);
378 heurdata->lastlp = -1;
397 assert(heurdata !=
NULL);
415 assert(heurdata !=
NULL);
416 heurdata->lastlp = -1;
419 if( heurdata->oncepernode )
444 assert(result !=
NULL);
459 assert(heurdata !=
NULL);
465 propagate = (!heurdata->propagateonlyroot ||
SCIPgetDepth(scip) == 0);
492 assert(heur !=
NULL);
503 "should the heuristic only be called once per node?",
505 SCIP_CALL(
SCIPaddBoolParam(scip,
"heuristics/" HEUR_NAME "/usesimplerounding",
"should the heuristic apply the variable lock strategy of simple rounding, if possible?",
508 "should the probing part of the heuristic be applied exclusively at the root node?",
511 "limit of rounds for each propagation call",
enum SCIP_Result SCIP_RESULT
SCIP_RETCODE SCIPsetHeurExitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol)))
SCIP_RETCODE SCIPgetLPBranchCands(SCIP *scip, SCIP_VAR ***lpcands, SCIP_Real **lpcandssol, SCIP_Real **lpcandsfrac, int *nlpcands, int *npriolpcands, int *nfracimplvars)
SCIP_RETCODE SCIPrandomCreate(SCIP_RANDNUMGEN **randnumgen, BMS_BLKMEM *blkmem, unsigned int initialseed)
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
static SCIP_DECL_HEUREXIT(heurExitRandrounding)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPincludeHeurRandrounding(SCIP *scip)
SCIP_Real SCIPgetCutoffbound(SCIP *scip)
unsigned int SCIP_HEURTIMING
SCIP_RETCODE SCIPsetHeurExit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXIT((*heurexit)))
static SCIP_RETCODE performRandRounding(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_SOL *sol, SCIP_VAR **cands, int ncands, SCIP_Bool propagate, SCIP_RESULT *result)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
void SCIPrandomPermuteArray(SCIP_RANDNUMGEN *randnumgen, void **array, int begin, int end)
enum SCIP_Retcode SCIP_RETCODE
static SCIP_DECL_HEUREXEC(heurExecRandrounding)
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)
#define SCIP_HEURTIMING_DURINGPRICINGLOOP
#define SCIPduplicateBufferArray(scip, ptr, source, num)
#define SCIPfreeBufferArray(scip, ptr)
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_Real SCIPfeasCeil(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPfeasFloor(SCIP *scip, SCIP_Real val)
void SCIPrandomFree(SCIP_RANDNUMGEN **randnumgen)
SCIP_RETCODE SCIPsetHeurInitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol)))
const char * SCIPheurGetName(SCIP_HEUR *heur)
static SCIP_DECL_HEURCOPY(heurCopyRandrounding)
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)
#define SCIP_HEURTIMING_AFTERLPNODE
static SCIP_DECL_HEUREXITSOL(heurExitsolRandrounding)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
SCIP_RETCODE SCIPendProbing(SCIP *scip)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
static SCIP_DECL_HEURFREE(heurFreeRandrounding)
#define DEFAULT_USESIMPLEROUNDING
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
public data structures and miscellaneous methods
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
#define DEFAULT_ONCEPERNODE
int SCIPgetDepth(SCIP *scip)
static SCIP_RETCODE performLPRandRounding(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_HEURTIMING heurtiming, SCIP_Bool propagate, SCIP_RESULT *result)
unsigned int SCIPinitializeRandomSeed(SCIP *scip, int initialseedvalue)
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
void SCIPenableVarHistory(SCIP *scip)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
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
SCIP_Real SCIPrandomGetReal(SCIP_RANDNUMGEN *randnumgen, SCIP_Real minrandval, SCIP_Real maxrandval)
SCIP_Bool SCIPinProbing(SCIP *scip)
SCIP_Real SCIPgetLPObjval(SCIP *scip)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisRelaxSolValid(SCIP *scip)
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
#define DEFAULT_MAXPROPROUNDS
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
SCIP_Bool SCIPisStopped(SCIP *scip)
static SCIP_DECL_HEURINIT(heurInitRandrounding)
void SCIPheurSetTimingmask(SCIP_HEUR *heur, SCIP_HEURTIMING timingmask)
SCIP_Bool SCIPallColsInLP(SCIP *scip)
randomized LP rounding heuristic which also generates conflicts via an auxiliary probing tree ...
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_RETCODE SCIPnewProbingNode(SCIP *scip)
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPstartProbing(SCIP *scip)
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
SCIP_Longint SCIPgetNLPs(SCIP *scip)
SCIP_RETCODE SCIPchgVarUbProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
SCIP_Bool SCIPvarMayRoundUp(SCIP_VAR *var)
SCIP_Bool SCIPvarMayRoundDown(SCIP_VAR *var)
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)
static SCIP_DECL_HEURINITSOL(heurInitsolRandrounding)
#define DEFAULT_PROPAGATEONLYROOT
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)