38 #define BRANCHRULE_NAME "cloud" 39 #define BRANCHRULE_DESC "branching rule that considers several alternative LP optima" 40 #define BRANCHRULE_PRIORITY 0 41 #define BRANCHRULE_MAXDEPTH -1 42 #define BRANCHRULE_MAXBOUNDDIST 1.0 44 #define DEFAULT_USECLOUD TRUE 45 #define DEFAULT_USEUNION FALSE 46 #define DEFAULT_MAXPOINTS -1 47 #define DEFAULT_MINSUCCESSRATE 0.0 48 #define DEFAULT_MINSUCCESSUNION 0.0 49 #define DEFAULT_MAXDEPTHUNION 65000 50 #define DEFAULT_ONLYF2 FALSE 57 struct SCIP_BranchruleData
92 if( branchruledata->cloudclock !=
NULL)
100 ntried = branchruledata->ntried;
101 nuseful = branchruledata->nuseful;
102 ncloudpoints = branchruledata->ncloudpoints;
103 nsavedlps = branchruledata->nsavedlps;
109 SCIPstatisticMessage(
"cloud success rates useful/tried: %8.6g points/useful: %8.6g saved/useful: %8.6g \n",
110 ntried == 0 ? -1 : (
SCIP_Real)nuseful / ntried, nuseful == 0 ? -1 : (
SCIP_Real)ncloudpoints / nuseful, nuseful == 0 ? -1 : (
SCIP_Real)nsavedlps / nuseful);
132 branchruledata->lastcand = 0;
133 branchruledata->nuseful = 0;
134 branchruledata->nusefulunions = 0;
135 branchruledata->ntried = 0;
136 branchruledata->ntriedunions = 0;
137 branchruledata->ncloudpoints = 0;
138 branchruledata->nsavedlps = 0;
140 if( branchruledata->cloudclock !=
NULL)
188 assert(branchrule !=
NULL);
191 assert(result !=
NULL);
207 assert(nlpcands > 0);
211 assert(branchruledata !=
NULL);
214 if( branchruledata->skipdown ==
NULL )
216 assert(branchruledata->skipup ==
NULL);
218 branchruledata->skipsize = nvars;
233 newlpcandsmin =
NULL;
234 newlpcandsmax =
NULL;
235 if( branchruledata->useunion &&
SCIPgetDepth(
scip) < branchruledata->maxdepthunion && !branchruledata->onlyF2)
247 branchruledata->ntried++;
253 for( i = 0; i < nvars; ++i )
273 for( i = 0; i < nlprows; ++i )
293 if( branchruledata->useunion && !branchruledata->onlyF2 &&
SCIPgetDepth(
scip) < branchruledata->maxdepthunion )
296 for( i = 0; i < ndiscvars; ++i)
301 assert(newlpcandsmin !=
NULL);
302 assert(newlpcandsmax !=
NULL);
304 newlpcandsmin[i] = solval;
305 newlpcandsmax[i] = solval;
310 while( newpoint && branchruledata->usecloud )
317 for( i = 0; i < nlpcands; ++i )
377 for( i = 0; i < nlpcands; ++i)
385 lpcandsmin[i] =
MIN(lpcandsmin[i], solval);
386 lpcandsmax[i] =
MAX(lpcandsmax[i], solval);
389 if( branchruledata->useunion && !branchruledata->onlyF2 &&
SCIPgetDepth(
scip) < branchruledata->maxdepthunion )
392 for( i = 0; i < ndiscvars; ++i)
397 assert(newlpcandsmin !=
NULL);
398 assert(newlpcandsmax !=
NULL);
400 newlpcandsmin[i] =
MIN(newlpcandsmin[i], solval);
401 newlpcandsmax[i] =
MAX(newlpcandsmax[i], solval);
408 if( branchruledata->maxpoints != -1 && counter >= branchruledata->maxpoints )
412 SCIPdebugMsg(
scip,
"considered %d additional points in the cloud\n",counter);
419 ncomplete = nlpcands;
423 branchruledata->ncloudpoints += (counter+1);
424 branchruledata->nuseful++;
429 for( i = 0; i < nlpcands; ++i)
433 assert(counter <= i);
434 lpcandscopy[counter] = lpcandscopy[i];
435 lpcandssolcopy[counter] = lpcandssolcopy[i];
436 lpcandsfraccopy[counter] = lpcandsfraccopy[i];
442 assert(nlpcands - counter > 0);
447 for( i = 0; i < nlpcands && !branchruledata->onlyF2; ++i)
451 assert(counter < nlpcands);
452 lpcandscopy[counter] = lpcandscopy[i];
453 lpcandssolcopy[counter] = lpcandssolcopy[i];
454 lpcandsfraccopy[counter] = lpcandsfraccopy[i];
457 branchruledata->skipdown[counter] =
TRUE;
459 branchruledata->skipup[counter] =
TRUE;
460 assert(branchruledata->skipdown[counter] != branchruledata->skipup[counter]);
466 SCIPdebugMsg(
scip,
"can fully skip %d/%d strong branching candidates\n", nlpcands - counter, nlpcands);
467 SCIPdebugMsg(
scip,
"can half skip %d/%d strong branching candidates\n", counter - ncomplete, nlpcands);
473 if( branchruledata->usecloud &&
474 branchruledata->ntried > 100 &&
475 (
SCIP_Real)branchruledata->nuseful / branchruledata->ntried < branchruledata->minsuccessrate )
478 branchruledata->usecloud =
FALSE;
481 if( branchruledata->onlyF2 )
482 counter =
MAX(counter,1);
486 branchruledata->skipup, counter, counter, ncomplete, &branchruledata->lastcand, allowaddcons, 0,
FALSE,
FALSE,
487 &bestcand, &bestdown, &bestup, &bestscore, &bestdownvalid, &bestupvalid, &provedbound, result) );
489 if( branchruledata->lastcand <= ncomplete )
491 SCIPdebugMsg(
scip,
"saved %d of %d LPs\n", 2*(nlpcands - ncomplete), 2*nlpcands);
492 branchruledata->nsavedlps += 2*(nlpcands - ncomplete);
496 SCIPdebugMsg(
scip,
"saved %d of %d LPs\n", 2*(nlpcands - counter)+counter - ncomplete, 2*nlpcands);
497 branchruledata->nsavedlps += 2*(nlpcands - counter)+counter - ncomplete;
511 assert(0 <= bestcand && bestcand < nlpcands);
514 var = lpcandscopy[bestcand];
518 if( branchruledata->useunion && !branchruledata->onlyF2 &&
SCIPgetDepth(
scip) < branchruledata->maxdepthunion && branchruledata->lastcand > ncomplete )
530 for( i = 0; i < ndiscvars; ++i)
535 assert(newlpcandsmin !=
NULL);
536 assert(newlpcandsmax !=
NULL);
540 newlpcands[counter] = vars[i];
543 branchruledata->skipdown[counter] =
TRUE;
545 branchruledata->skipup[counter] =
TRUE;
546 assert(branchruledata->skipdown[counter] != branchruledata->skipup[counter]);
563 branchruledata->ntriedunions++;
566 allowaddcons, &newcand, &newdown, &newup, &newscore, &newdownvalid, &newupvalid, &newbound, result) );
574 if( newscore > bestscore )
577 var = newlpcands[newcand];
580 bestdownvalid = newdownvalid;
581 bestupvalid = newupvalid;
582 bestscore = newscore;
584 branchruledata->nusefulunions++;
594 SCIPdebugMsg(
scip,
" -> %d candidates, selected candidate %d: variable <%s> (solval=%g, down=%g, up=%g, score=%g)\n",
595 counter, bestcand,
SCIPvarGetName(var), lpcandssolcopy[bestcand], bestdown, bestup, bestscore);
599 SCIPdebugMsg(
scip,
" -> selected from %d new candidates, candidate %d: variable <%s> (down=%g, up=%g, score=%g)\n",
600 counter, bestcand,
SCIPvarGetName(var), bestdown, bestup, bestscore);
606 assert(downchild !=
NULL);
607 assert(upchild !=
NULL);
618 if( allcolsinlp && !exactsolve )
630 if( branchruledata->useunion && !branchruledata->onlyF2 &&
SCIPgetDepth(
scip) < branchruledata->maxdepthunion )
642 if( branchruledata->useunion &&
643 branchruledata->ntriedunions > 10 &&
644 (
SCIP_Real)branchruledata->nusefulunions / branchruledata->ntriedunions < branchruledata->minsuccessunion )
647 branchruledata->useunion =
FALSE;
667 branchruledata->lastcand = 0;
668 branchruledata->skipsize = 0;
669 branchruledata->skipup =
NULL;
670 branchruledata->skipdown =
NULL;
677 assert(branchrule !=
NULL);
687 "should a cloud of points be used?",
691 "should only F2 be used?",
695 "should the union of candidates be used?",
699 "maximum number of points for the cloud (-1 means no limit)",
703 "minimum success rate for the cloud",
707 "minimum success rate for the union",
711 "maximum depth for the union",
SCIP_RETCODE SCIPgetLPBranchCands(SCIP *scip, SCIP_VAR ***lpcands, SCIP_Real **lpcandssol, SCIP_Real **lpcandsfrac, int *nlpcands, int *npriolpcands, int *nfracimplvars)
SCIP_ROW ** SCIPgetLPRows(SCIP *scip)
int SCIPgetNIntVars(SCIP *scip)
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
SCIP_BRANCHRULEDATA * SCIPbranchruleGetData(SCIP_BRANCHRULE *branchrule)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPgetCutoffbound(SCIP *scip)
SCIP_Real SCIPnodeGetLowerbound(SCIP_NODE *node)
SCIP_Real SCIPgetVarRedcost(SCIP *scip, SCIP_VAR *var)
struct SCIP_BranchruleData SCIP_BRANCHRULEDATA
SCIP_RETCODE SCIPstopClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_Real SCIPvarGetSol(SCIP_VAR *var, SCIP_Bool getlpval)
SCIP_RETCODE SCIPsetBranchruleFree(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHFREE((*branchfree)))
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
SCIP_Real SCIPinfinity(SCIP *scip)
enum SCIP_Retcode SCIP_RETCODE
#define DEFAULT_MAXPOINTS
#define SCIPstatisticMessage
SCIP_RETCODE SCIPchgVarLbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
#define SCIPfreeBlockMemory(scip, ptr)
static SCIP_DECL_BRANCHINIT(branchInitCloud)
SCIP_RETCODE SCIPincludeBranchruleBasic(SCIP *scip, SCIP_BRANCHRULE **branchruleptr, const char *name, const char *desc, int priority, int maxdepth, SCIP_Real maxbounddist, SCIP_BRANCHRULEDATA *branchruledata)
SCIP_RETCODE SCIPfreeClock(SCIP *scip, SCIP_CLOCK **clck)
#define DEFAULT_MAXDEPTHUNION
#define SCIPfreeBufferArray(scip, ptr)
#define BRANCHRULE_PRIORITY
#define SCIPallocBlockMemory(scip, ptr)
int SCIPgetNLPBranchCands(SCIP *scip)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_Real SCIProwGetDualsol(SCIP_ROW *row)
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 SCIPsetBranchruleExecLp(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXECLP((*branchexeclp)))
static SCIP_DECL_BRANCHEXECLP(branchExeclpCloud)
#define DEFAULT_MINSUCCESSUNION
SCIP_Bool SCIPisLPSolBasic(SCIP *scip)
SCIP_RETCODE SCIPchgRowLhsDive(SCIP *scip, SCIP_ROW *row, SCIP_Real newlhs)
SCIP_RETCODE SCIPcreateClock(SCIP *scip, SCIP_CLOCK **clck)
SCIP_RETCODE SCIPbranchVar(SCIP *scip, SCIP_VAR *var, SCIP_NODE **downchild, SCIP_NODE **eqchild, SCIP_NODE **upchild)
SCIP_RETCODE SCIPsolveDiveLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
const char * SCIPvarGetName(SCIP_VAR *var)
int SCIPgetNLPRows(SCIP *scip)
#define BRANCHRULE_MAXBOUNDDIST
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
SCIP_RETCODE SCIPincludeBranchruleCloud(SCIP *scip)
#define SCIPallocBufferArray(scip, ptr, num)
full strong LP branching rule
#define BRANCHRULE_MAXDEPTH
#define DEFAULT_MINSUCCESSRATE
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
SCIP_Real SCIPgetClockTime(SCIP *scip, SCIP_CLOCK *clck)
int SCIPgetDepth(SCIP *scip)
SCIP_RETCODE SCIPupdateNodeLowerbound(SCIP *scip, SCIP_NODE *node, SCIP_Real newbound)
SCIP_RETCODE SCIPchgVarUbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
void SCIPbranchruleSetData(SCIP_BRANCHRULE *branchrule, SCIP_BRANCHRULEDATA *branchruledata)
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 SCIPselectVarPseudoStrongBranching(SCIP *scip, SCIP_VAR **pseudocands, SCIP_Bool *skipdown, SCIP_Bool *skipup, int npseudocands, int npriopseudocands, SCIP_Bool allowaddcons, int *bestpseudocand, SCIP_Real *bestdown, SCIP_Real *bestup, SCIP_Real *bestscore, SCIP_Bool *bestdownvalid, SCIP_Bool *bestupvalid, SCIP_Real *provedbound, SCIP_RESULT *result)
#define BMScopyMemoryArray(ptr, source, num)
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
int SCIPgetNBinVars(SCIP *scip)
static SCIP_DECL_BRANCHFREE(branchFreeCloud)
all variables full strong LP branching rule
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPchgVarObjDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
SCIP_RETCODE SCIPresetClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_RETCODE SCIPselectVarStrongBranching(SCIP *scip, SCIP_VAR **lpcands, SCIP_Real *lpcandssol, SCIP_Real *lpcandsfrac, SCIP_Bool *skipdown, SCIP_Bool *skipup, int nlpcands, int npriolpcands, int ncomplete, int *start, SCIP_Bool allowaddcons, int maxproprounds, SCIP_Bool probingbounds, SCIP_Bool forcestrongbranch, int *bestcand, SCIP_Real *bestdown, SCIP_Real *bestup, SCIP_Real *bestscore, SCIP_Bool *bestdownvalid, SCIP_Bool *bestupvalid, SCIP_Real *provedbound, SCIP_RESULT *result)
const char * SCIPbranchruleGetName(SCIP_BRANCHRULE *branchrule)
SCIP_RETCODE SCIPsetBranchruleInit(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHINIT((*branchinit)))
SCIP_Bool SCIPallColsInLP(SCIP *scip)
SCIP_Real SCIPfrac(SCIP *scip, SCIP_Real val)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_RETCODE SCIPstartDive(SCIP *scip)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
#define BMSclearMemoryArray(ptr, num)
SCIP_RETCODE SCIPendDive(SCIP *scip)
SCIP_Real SCIPceil(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPchgRowRhsDive(SCIP *scip, SCIP_ROW *row, SCIP_Real newrhs)
SCIP_RETCODE SCIPstartClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
SCIP_Bool SCIPisExactSolve(SCIP *scip)
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_Real SCIPfloor(SCIP *scip, SCIP_Real val)
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_Real SCIPgetRowActivity(SCIP *scip, SCIP_ROW *row)
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)