30 #define BRANCHRULE_NAME "pscost" 31 #define BRANCHRULE_DESC "branching on pseudo cost values" 32 #define BRANCHRULE_PRIORITY 2000 33 #define BRANCHRULE_MAXDEPTH -1 34 #define BRANCHRULE_MAXBOUNDDIST 1.0 36 #define BRANCHRULE_STRATEGIES "cdsu" 37 #define BRANCHRULE_STRATEGY_DEFAULT 'u' 38 #define BRANCHRULE_SCOREMINWEIGHT_DEFAULT 0.8 39 #define BRANCHRULE_SCOREMAXWEIGHT_DEFAULT 1.3 40 #define BRANCHRULE_SCORESUMWEIGHT_DEFAULT 0.1 41 #define BRANCHRULE_NCHILDREN_DEFAULT 2 42 #define BRANCHRULE_NARYMAXDEPTH_DEFAULT -1 43 #define BRANCHRULE_NARYMINWIDTH_DEFAULT 0.001 44 #define BRANCHRULE_NARYWIDTHFAC_DEFAULT 2.0 45 #define BRANCHRULE_RANDSEED_DEFAULT 47 48 #define WEIGHTEDSCORING(data, min, max, sum) \ 49 ((data)->scoreminweight * (min) + (data)->scoremaxweight * (max) + (data)->scoresumweight * (sum)) 52 struct SCIP_BranchruleData
101 assert(scip !=
NULL);
102 assert(branchruledata !=
NULL);
103 assert(bestvar !=
NULL);
104 assert(bestbrpoint !=
NULL);
105 assert(bestscore !=
NULL);
106 assert(cand !=
NULL);
146 for( i = 0; i < nmultvars; ++i )
151 if(
SCIPisEQ(scip, multvarlb, multvarub) )
154 assert(multscalars !=
NULL);
155 assert(multscalars[i] != 0.0);
161 if( multscalars[i] > 0.0 )
167 aggrvarsol1 = (candsol - maxact) / multscalars[i] + multvarub;
173 aggrvarsol2 = (candsol - minact) / multscalars[i] + multvarlb;
181 aggrvarsol2 = (candsol - maxact) / multscalars[i] + multvarlb;
187 aggrvarsol1 = (candsol - minact) / multscalars[i] + multvarub;
200 aggrvarsol = aggrvarsol2;
205 aggrvarsol = aggrvarsol1;
207 aggrvarsol =
REALABS(aggrvarsol1) <
REALABS(aggrvarsol2) ? aggrvarsol1 : aggrvarsol2;
212 multvars[i], candscoremin, candscoremax, candscoresum, candrndscore, aggrvarsol) );
217 for( i = 0; i < nmultvars; ++i )
222 if(
SCIPisEQ(scip, multvarlb, multvarub) )
226 multvars[i], candscoremin, candscoremax, candscoresum, candrndscore,
SCIP_INVALID) );
229 assert(*bestvar !=
NULL);
248 strategy = (branchruledata->strategy ==
'u' ? branchruledata->updatestrategy : branchruledata->strategy);
250 strategy = (branchruledata->strategy ==
'u' ?
'l' : branchruledata->strategy);
291 deltaminus = deltaplus;
311 SCIPdebugMsg(scip,
"branching score variable <%s>[%g,%g] = %g; wscore = %g; type=%d bestbrscore=%g\n",
320 (*bestscore) = branchscore;
321 (*bestrndscore) = candrndscore;
323 (*bestbrpoint) = candbrpoint;
342 (*bestscore) = branchscore;
343 (*bestrndscore) = candrndscore;
345 (*bestbrpoint) = candbrpoint;
363 (*bestscore) = branchscore;
364 (*bestrndscore) = candrndscore;
366 (*bestbrpoint) = candbrpoint;
385 (*bestscore) = branchscore;
386 (*bestrndscore) = candrndscore;
388 (*bestbrpoint) = candbrpoint;
403 (*bestscore) = branchscore;
404 (*bestrndscore) = candrndscore;
406 (*bestbrpoint) = candbrpoint;
416 if( candrndscore >= (*bestrndscore) )
418 (*bestscore) = branchscore;
419 (*bestrndscore) = candrndscore;
421 (*bestbrpoint) = candbrpoint;
458 assert(brvar !=
NULL);
459 assert(brpoint !=
NULL);
468 assert(branchruledata !=
NULL);
473 for( i = 0; i < ncands; ++i )
476 SCIPsortPtrInt((
void**)candssorted, candsorigidx, SCIPvarComp, ncands);
478 bestbranchscore = -1.0;
481 for( i = 0; i < ncands; ++i )
483 cand = candssorted[i];
490 scoremin = candsscore[candsorigidx[i]];
493 candsol = candssol[candsorigidx[i]];
494 for( j = i+1 ; j < ncands &&
SCIPvarCompare(candssorted[j], cand) == 0; ++j )
496 assert(candsscore[candsorigidx[j]] >= 0.0);
497 scoresum += candsscore[candsorigidx[j]];
498 if( candsscore[candsorigidx[j]] < scoremin )
499 scoremin = candsscore[candsorigidx[j]];
500 else if( candsscore[candsorigidx[j]] > scoremax )
501 scoremax = candsscore[candsorigidx[j]];
505 candsol = candssol[candsorigidx[j]];
509 assert(candssorted[i] == cand);
513 scoremin, scoremax, scoresum,
SCIPrandomGetReal(branchruledata->randnumgen, 0.0, 1.0), candsol) );
520 if( (*brvar) ==
NULL )
522 SCIPerrorMessage(
"no branching could be created: all external candidates have huge bounds\n");
543 assert(branchrule !=
NULL);
560 assert(branchruledata !=
NULL);
577 assert(branchruledata !=
NULL);
594 assert(branchruledata !=
NULL);
614 assert(branchrule !=
NULL);
617 assert(result !=
NULL);
623 assert(nlpcands > 0);
628 for( c = 0; c < nlpcands; ++c )
636 rootdiff =
REALABS(lpcandssol[c] - rootsolval);
641 bestrootdiff = rootdiff;
644 assert(0 <= bestcand && bestcand < nlpcands);
649 SCIPdebugMsg(
scip,
" -> %d cands, selected cand %d: variable <%s> (solval=%g, score=%g)\n",
650 nlpcands, bestcand,
SCIPvarGetName(lpcands[bestcand]), lpcandssol[bestcand], bestscore);
668 int nprioexterncands;
673 assert(branchrule !=
NULL);
676 assert(result !=
NULL);
679 assert(branchruledata !=
NULL);
685 assert(nprioexterncands > 0);
688 if( branchruledata->strategy ==
'u' )
698 SCIPerrorMessage(
"branchExecextPscost failed to select a branching variable from %d candidates\n", nprioexterncands);
705 SCIPdebugMsg(
scip,
"branching on variable <%s>: new intervals: [%g, %g] and [%g, %g]\n",
759 assert(branchrule !=
NULL);
770 "strategy for utilizing pseudo-costs of external branching candidates (multiply as in pseudo costs 'u'pdate rule, or by 'd'omain reduction, or by domain reduction of 's'ibling, or by 'v'ariable score)",
774 "weight for minimum of scores of a branching candidate when building weighted sum of min/max/sum of scores",
778 "weight for maximum of scores of a branching candidate when building weighted sum of min/max/sum of scores",
782 "weight for sum of scores of a branching candidate when building weighted sum of min/max/sum of scores",
786 "number of children to create in n-ary branching",
790 "maximal depth where to do n-ary branching, -1 to turn off",
794 "minimal domain width in children when doing n-ary branching, relative to global bounds",
798 "factor of domain width in n-ary branching when creating nodes with increasing distance from branching value",
818 assert(scip !=
NULL);
822 assert(branchrule !=
NULL);
825 SCIP_CALL(
selectBranchVar(scip, branchrule, branchcands, branchcandssol, branchcandsscore, nbranchcands, var, brpoint) );
SCIP_RETCODE SCIPgetLPBranchCands(SCIP *scip, SCIP_VAR ***lpcands, SCIP_Real **lpcandssol, SCIP_Real **lpcandsfrac, int *nlpcands, int *npriolpcands, int *nfracimplvars)
void SCIPsortPtrInt(void **ptrarray, int *intarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
SCIP_RETCODE SCIPrandomCreate(SCIP_RANDNUMGEN **randnumgen, BMS_BLKMEM *blkmem, unsigned int initialseed)
SCIP_RETCODE SCIPgetCharParam(SCIP *scip, const char *name, char *value)
SCIP_BRANCHRULEDATA * SCIPbranchruleGetData(SCIP_BRANCHRULE *branchrule)
static SCIP_RETCODE updateBestCandidate(SCIP *scip, SCIP_BRANCHRULEDATA *branchruledata, SCIP_VAR **bestvar, SCIP_Real *bestbrpoint, SCIP_Real *bestscore, SCIP_Real *bestrndscore, SCIP_VAR *cand, SCIP_Real candscoremin, SCIP_Real candscoremax, SCIP_Real candscoresum, SCIP_Real candrndscore, SCIP_Real candsol)
#define BRANCHRULE_NCHILDREN_DEFAULT
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
SCIP_Real * SCIPvarGetMultaggrScalars(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
#define BRANCHRULE_NARYMAXDEPTH_DEFAULT
SCIP_Real SCIPgetVarPseudocostVal(SCIP *scip, SCIP_VAR *var, SCIP_Real solvaldelta)
SCIP_VAR ** SCIPvarGetMultaggrVars(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
struct SCIP_BranchruleData SCIP_BRANCHRULEDATA
SCIP_Real SCIPgetBranchingPoint(SCIP *scip, SCIP_VAR *var, SCIP_Real suggestion)
SCIP_RETCODE SCIPsetBranchruleExit(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXIT((*branchexit)))
SCIP_Real SCIPvarGetSol(SCIP_VAR *var, SCIP_Bool getlpval)
SCIP_Real SCIPvarGetRootSol(SCIP_VAR *var)
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPsetBranchruleFree(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHFREE((*branchfree)))
static SCIP_DECL_BRANCHEXECEXT(branchExecextPscost)
SCIP_Real SCIPadjustedVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real ub)
SCIP_RETCODE SCIPbranchVarValNary(SCIP *scip, SCIP_VAR *var, SCIP_Real val, int n, SCIP_Real minwidth, SCIP_Real widthfactor, int *nchildren)
SCIP_Real SCIPrelDiff(SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
static SCIP_DECL_BRANCHCOPY(branchCopyPscost)
SCIP_RETCODE SCIPsetBranchruleCopy(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHCOPY((*branchcopy)))
enum SCIP_Retcode SCIP_RETCODE
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
#define BRANCHRULE_NARYMINWIDTH_DEFAULT
#define SCIPfreeBlockMemory(scip, ptr)
static SCIP_DECL_BRANCHINIT(branchInitPscost)
SCIP_RETCODE SCIPincludeBranchruleBasic(SCIP *scip, SCIP_BRANCHRULE **branchruleptr, const char *name, const char *desc, int priority, int maxdepth, SCIP_Real maxbounddist, SCIP_BRANCHRULEDATA *branchruledata)
#define SCIPduplicateBufferArray(scip, ptr, source, num)
#define BRANCHRULE_STRATEGY_DEFAULT
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
int SCIPnodeGetDepth(SCIP_NODE *node)
SCIP_RETCODE SCIPgetExternBranchCands(SCIP *scip, SCIP_VAR ***externcands, SCIP_Real **externcandssol, SCIP_Real **externcandsscore, int *nexterncands, int *nprioexterncands, int *nprioexternbins, int *nprioexternints, int *nprioexternimpls)
#define SCIPfreeBufferArray(scip, ptr)
SCIP_Real SCIPadjustedVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real lb)
#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)
#define WEIGHTEDSCORING(data, min, max, sum)
SCIP_Real SCIPcomputeVarLbLocal(SCIP *scip, SCIP_VAR *var)
SCIP_Real SCIPgetVarPseudocostScore(SCIP *scip, SCIP_VAR *var, SCIP_Real solval)
SCIP_RETCODE SCIPsetBranchruleExecLp(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXECLP((*branchexeclp)))
SCIP_Real SCIPgetBranchScore(SCIP *scip, SCIP_VAR *var, SCIP_Real downgain, SCIP_Real upgain)
static SCIP_DECL_BRANCHEXECLP(branchExeclpPscost)
SCIP_RETCODE SCIPselectBranchVarPscost(SCIP *scip, SCIP_VAR **branchcands, SCIP_Real *branchcandssol, SCIP_Real *branchcandsscore, int nbranchcands, SCIP_VAR **var, SCIP_Real *brpoint)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
void SCIPrandomFree(SCIP_RANDNUMGEN **randnumgen)
#define BRANCHRULE_STRATEGIES
SCIP_RETCODE SCIPbranchVar(SCIP *scip, SCIP_VAR *var, SCIP_NODE **downchild, SCIP_NODE **eqchild, SCIP_NODE **upchild)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
const char * SCIPvarGetName(SCIP_VAR *var)
static SCIP_DECL_BRANCHFREE(branchFreePscost)
SCIP_Bool SCIPisSumEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPcomputeVarUbLocal(SCIP *scip, SCIP_VAR *var)
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define BRANCHRULE_PRIORITY
SCIP_Bool SCIPisHugeValue(SCIP *scip, SCIP_Real val)
#define SCIPallocBufferArray(scip, ptr, num)
static SCIP_RETCODE selectBranchVar(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_VAR **cands, SCIP_Real *candssol, SCIP_Real *candsscore, int ncands, SCIP_VAR **brvar, SCIP_Real *brpoint)
public data structures and miscellaneous methods
pseudo costs branching rule
SCIP_Bool SCIPisSumGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define BRANCHRULE_RANDSEED_DEFAULT
#define BRANCHRULE_MAXDEPTH
void SCIPbranchruleSetData(SCIP_BRANCHRULE *branchrule, SCIP_BRANCHRULEDATA *branchruledata)
int SCIPvarCompare(SCIP_VAR *var1, SCIP_VAR *var2)
unsigned int SCIPinitializeRandomSeed(SCIP *scip, int initialseedvalue)
SCIP_RETCODE SCIPsetBranchruleExecExt(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXECEXT((*branchexecext)))
static SCIP_DECL_BRANCHEXIT(branchExitPscost)
#define BRANCHRULE_SCORESUMWEIGHT_DEFAULT
#define BRANCHRULE_SCOREMAXWEIGHT_DEFAULT
int SCIPvarGetMultaggrNVars(SCIP_VAR *var)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPrandomGetReal(SCIP_RANDNUMGEN *randnumgen, SCIP_Real minrandval, SCIP_Real maxrandval)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
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)
#define BRANCHRULE_MAXBOUNDDIST
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
const char * SCIPbranchruleGetName(SCIP_BRANCHRULE *branchrule)
SCIP_RETCODE SCIPsetBranchruleInit(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHINIT((*branchinit)))
#define BRANCHRULE_NARYWIDTHFAC_DEFAULT
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_RETCODE SCIPincludeBranchrulePscost(SCIP *scip)
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
#define BRANCHRULE_SCOREMINWEIGHT_DEFAULT
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_Bool SCIPvarIsActive(SCIP_VAR *var)