branch_distribution.c
Go to the documentation of this file.
21 * The distribution branching rule selects a variable based on its impact on row activity distributions. More formally, 22 * let \f$ a(x) = a_1 x_1 + \dots + a_n x_n \leq b \f$ be a row of the LP. Let further \f$ l_i, u_i \in R\f$ denote the 24 * Viewing every variable \f$x_i \f$ as (continuously) uniformly distributed within its bounds, we can approximately 25 * understand the row activity \f$a(x)\f$ as a Gaussian random variate with mean value \f$ \mu = E[a(x)] = \sum_i a_i\frac{l_i + u_i}{2}\f$ 26 * and variance \f$ \sigma^2 = \sum_i a_i^2 \sigma_i^2 \f$, with \f$ \sigma_i^2 = \frac{(u_i - l_i)^2}{12}\f$ for 28 * With these two parameters, we can calculate the probability to satisfy the row in terms of the cumulative distribution 31 * The impact of a variable on the probability to satisfy a constraint after branching can be estimated by altering 36 * The selection of the branching variable is subject to the parameter @p scoreparam. For both branching directions, 38 * - @b d: select a branching variable with largest difference in satisfaction probability after branching 41 * - @b v: highest number of votes for lowering row probability for all rows a variable appears in. 42 * - @b w: highest number of votes for increasing row probability for all rows a variable appears in. 44 * If the parameter @p usescipscore is set to @a TRUE, a single branching score is calculated from the respective 45 * up and down scores as defined by the SCIP branching score function (see advanced branching parameter @p scorefunc), 46 * otherwise, the variable with the single highest score is selected, and the maximizing direction is assigned 57 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 65 #define BRANCHRULE_DESC "branching rule based on variable influence on cumulative normal distribution of row activities" 75 #define DEFAULT_ONLYACTIVEROWS FALSE /**< should only rows which are active at the current node be considered? */ 76 #define DEFAULT_USEWEIGHTEDSCORE FALSE /**< should the branching score weigh up- and down-scores of a variable */ 80 #define EVENT_DISTRIBUTION SCIP_EVENTTYPE_BOUNDCHANGED /**< the event tyoe to be handled by this event handler */ 95 int* rowinfinitiesdown; /**< count the number of variables with infinite bounds which allow for always 97 int* rowinfinitiesup; /**< count the number of variables with infinite bounds which allow for always 105 SCIP_Bool onlyactiverows; /**< should only rows which are active at the current node be considered? */ 111 SCIP_BRANCHRULEDATA* branchruledata; /**< the branching rule data to access distribution arrays */ 118 /** ensure that maxindex + 1 rows can be represented in data arrays; memory gets reallocated with 10% extra space 175 SCIP_CALL( SCIPcatchVarEvent(scip, vars[v], EVENT_DISTRIBUTION, branchruledata->eventhdlr, NULL, &(branchruledata->varfilterposs[v])) ); 187 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &branchruledata->rowinfinitiesdown, branchruledata->memsize, newsize) ); 188 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &branchruledata->rowinfinitiesup, branchruledata->memsize, newsize) ); 189 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &branchruledata->rowmeans, branchruledata->memsize, newsize) ); 190 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &branchruledata->rowvariances, branchruledata->memsize, newsize) ); 193 /* loop over extended arrays and invalidate data to trigger initialization of this row when necessary */ 233 /** calculate the variable's distribution parameters (mean and variance) for the bounds specified in the arguments. 262 /* if the variable is continuous, we assume a continuous uniform distribution, otherwise a discrete one */ 274 /** calculates the cumulative distribution P(-infinity <= x <= value) that a normally distributed 307 /* scale and translate to standard normal distribution. Factor sqrt(2) is needed for SCIPerf() function */ 310 SCIPdebugMessage(" Normalized value %g = ( %g - %g ) / (%g * 1.4142136)\n", normvalue, value, mean, std); 312 /* calculate the cumulative distribution function for normvalue. For negative normvalues, we negate 313 * the normvalue and use the oddness of the SCIPerf()-function; special treatment for values close to zero. 341 * For equations (lhs==rhs), we use the centeredness measure p = min(PHI(lhs'), 1-PHI(lhs'))/max(PHI(lhs'), 1 - PHI(lhs')), 349 int rowinfinitiesdown, /**< the number of variables with infinite bounds to DECREASE activity */ 365 /* use the cumulative distribution if the row contains no variable to repair every infeasibility */ 369 /* use the cumulative distribution if the row contains no variable to repair every infeasibility 378 /* use centeredness measure for equations; for inequalities, the minimum of the two probabilities is the 393 SCIPdebugMessage(" Row %s, mean %g, sigma2 %g, LHS %g, RHS %g has probability %g to be satisfied\n", 404 * \f$n \f$ is the number of variables, and \f$ c_i, lb_i, ub_i \f$ are the variable coefficient and 416 SCIP_Real* sigma2, /**< pointer to store the variance value of the gaussian normal distribution */ 417 int* rowinfinitiesdown, /**< pointer to store the number of variables with infinite bounds to DECREASE activity */ 418 int* rowinfinitiesup /**< pointer to store the number of variables with infinite bounds to INCREASE activity */ 468 assert((branchruledata->currentlbs[varindex] == SCIP_INVALID) == (branchruledata->currentubs[varindex] == SCIP_INVALID)); /*lint !e777*/ 485 /* an infinite upper bound gives the row an infinite maximum activity or minimum activity, if the coefficient is 494 /* an infinite lower bound gives the row an infinite maximum activity or minimum activity, if the coefficient is 505 SCIPvarCalcDistributionParameters(scip, colvarlb, colvarub, SCIPvarGetType(colvar), &varmean, &varvariance); 507 /* actual values are updated; the contribution of the variable to mu is the arithmetic mean of its bounds */ 510 /* the variance contribution of a variable is c^2 * (u - l)^2 / 12.0 for continuous and c^2 * ((u - l + 1)^2 - 1) / 12.0 for integer */ 518 SCIPdebugMessage(" Row %s has a mean value of %g at a sigma2 of %g \n", SCIProwGetName(row), *mu, *sigma2); 521 /** update the up- and downscore of a single variable after calculating the impact of branching on a 599 SCIP_Real* upscore, /**< pointer to store the variable score when branching on it in upward direction */ 600 SCIP_Real* downscore, /**< pointer to store the variable score when branching on it in downward direction */ 621 SCIP_Bool onlyactiverows; /* should only rows which are active at the current node be considered? */ 644 SCIPvarCalcDistributionParameters(scip, varlb, varub, vartype, ¤tmean, &squaredbounddiff); 657 SCIPvarCalcDistributionParameters(scip, varlb, newub, vartype, &meandown, &squaredbounddiffdown); 699 rowCalculateGauss(scip, branchruledata, row, &branchruledata->rowmeans[rowpos], &branchruledata->rowvariances[rowpos], 716 /* first, get the probability change for the row if the variable is branched on upwards. The probability 740 newrowprobup = SCIProwCalcProbability(scip, row, changedrowmean, changedrowvariance, rowinftiesdownafterbranch, 767 newrowprobdown = SCIProwCalcProbability(scip, row, changedrowmean, changedrowvariance, rowinftiesdownafterbranch, 774 SCIP_CALL( SCIPupdateDistributionScore(scip, currentrowprob, newrowprobup, newrowprobdown, upscore, downscore, scoreparam) ); 776 SCIPdebugMessage(" Variable %s changes probability of row %s from %g to %g (branch up) or %g;\n", 808 /** add variable to the bound change event queue; skipped if variable is already in there, or if variable has 841 assert((branchruledata->currentlbs[varindex] == SCIP_INVALID) == (branchruledata->currentubs[varindex] == SCIP_INVALID)); /*lint !e777*/ 853 /** returns the next unprocessed variable (last in, first out) with pending bound changes, or NULL */ 907 /* skip event execution if SCIP is in Probing mode because these bound changes will be undone anyway before branching 924 /* skip update if the variable has never been subject of previously calculated row activities */ 1039 /** solving process deinitialization method of branching rule (called before branch and bound process data is freed) */ 1054 /* drop variable events at the end of branch and bound process (cannot be used after restarts, anyway) */ 1067 SCIP_CALL( SCIPdropVarEvent(scip, vars[v], EVENT_DISTRIBUTION, branchruledata->eventhdlr, NULL, branchruledata->varfilterposs[v]) ); 1128 /* if branching rule data arrays were not initialized before (usually the first call of the branching execution), 1161 /* invalidate the current row distribution data which is initialized on the fly when looping over the candidates */ 1177 /* in debug mode, ensure that all bound process events which occurred in the mean time have been captured 1183 assert((branchruledata->currentlbs[varindex] == SCIP_INVALID) == (branchruledata->currentubs[varindex] == SCIP_INVALID)); /*lint !e777*/ 1185 || SCIPisFeasEQ(scip, SCIPvarGetLbLocal(lpcand), branchruledata->currentlbs[varindex])); /*lint !e777*/ 1187 || SCIPisFeasEQ(scip, SCIPvarGetUbLocal(lpcand), branchruledata->currentubs[varindex])); /*lint !e777*/ 1198 /* loop over candidate rows and determine the candidate up- and down- branching score w.r.t. the score parameter */ 1202 /* if weighted scoring is enabled, use the branching score method of SCIP to weigh up and down score */ 1238 SCIPdebugMessage(" Candidate %s has score down %g and up %g \n", SCIPvarGetName(lpcand), downscore, upscore); 1239 SCIPdebugMessage(" Best candidate: %s, score %g, direction %d\n", SCIPvarGetName(bestcand), bestscore, bestbranchdir); 1245 SCIPdebugMessage(" Branching on variable %s with bounds [%g, %g] and solution value <%g>\n", SCIPvarGetName(bestcand), 1271 /** event execution method of distribution branching which handles bound change events of variables */ 1286 /* add the variable to the queue of unprocessed variables; method itself ensures that every variable is added at most once */ 1332 SCIP_CALL( SCIPincludeBranchruleBasic(scip, &branchrule, BRANCHRULE_NAME, BRANCHRULE_DESC, BRANCHRULE_PRIORITY, BRANCHRULE_MAXDEPTH, 1343 "the score;largest 'd'ifference, 'l'owest cumulative probability,'h'ighest c.p., 'v'otes lowest c.p., votes highest c.p.('w') ", SCIP_RETCODE SCIPgetLPBranchCands(SCIP *scip, SCIP_VAR ***lpcands, SCIP_Real **lpcandssol, SCIP_Real **lpcandsfrac, int *nlpcands, int *npriolpcands, int *nfracimplvars) Definition: scip.c:33125 Definition: type_result.h:33 probability based branching rule based on an article by J. Pryor and J.W. Chinneck ... static SCIP_DECL_BRANCHFREE(branchFreeDistribution) Definition: branch_distribution.c:1076 SCIP_RETCODE SCIPbranchVar(SCIP *scip, SCIP_VAR *var, SCIP_NODE **downchild, SCIP_NODE **eqchild, SCIP_NODE **upchild) Definition: scip.c:33734 Definition: struct_scip.h:53 static SCIP_RETCODE branchruledataFreeArrays(SCIP *scip, SCIP_BRANCHRULEDATA *branchruledata) Definition: branch_distribution.c:787 SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:41920 Definition: struct_var.h:196 SCIP_RETCODE SCIPincludeBranchruleDistribution(SCIP *scip) Definition: branch_distribution.c:1298 static SCIP_DECL_BRANCHCOPY(branchCopyDistribution) Definition: branch_distribution.c:1030 SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata) Definition: scip.c:7778 SCIP_RETCODE SCIPchgChildPrio(SCIP *scip, SCIP_NODE *child, SCIP_Real priority) Definition: scip.c:12396 const char * SCIPbranchruleGetName(SCIP_BRANCHRULE *branchrule) Definition: branch.c:1877 static void branchruledataAddBoundChangeVar(SCIP *scip, SCIP_BRANCHRULEDATA *branchruledata, SCIP_VAR *var) Definition: branch_distribution.c:812 SCIP_Real SCIPcalcCumulativeDistribution(SCIP *scip, SCIP_Real mean, SCIP_Real variance, SCIP_Real value) Definition: branch_distribution.c:280 SCIP_RETCODE SCIPsetBranchruleCopy(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHCOPY((*branchcopy))) Definition: scip.c:8290 SCIP_RETCODE SCIPsetBranchruleFree(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHFREE((*branchfree))) Definition: scip.c:8306 static void branchruledataUpdateCurrentBounds(SCIP *scip, SCIP_BRANCHRULEDATA *branchruledata, SCIP_VAR *var) Definition: branch_distribution.c:210 Definition: type_history.h:37 Definition: struct_tree.h:122 void SCIPeventhdlrSetData(SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTHDLRDATA *eventhdlrdata) Definition: event.c:298 Definition: struct_lp.h:123 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) Definition: scip.c:3547 SCIP_RETCODE SCIPsetBranchruleExecLp(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXECLP((*branchexeclp))) Definition: scip.c:8388 SCIP_RETCODE SCIPcatchVarEvent(SCIP *scip, SCIP_VAR *var, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos) Definition: scip.c:36622 SCIP_RETCODE SCIPincludeBranchruleBasic(SCIP *scip, SCIP_BRANCHRULE **branchruleptr, const char *name, const char *desc, int priority, int maxdepth, SCIP_Real maxbounddist, SCIP_BRANCHRULEDATA *branchruledata) Definition: scip.c:8253 static SCIP_VAR * branchruledataPopBoundChangeVar(SCIP *scip, SCIP_BRANCHRULEDATA *branchruledata) Definition: branch_distribution.c:855 Definition: type_retcode.h:42 void SCIPbranchruleSetData(SCIP_BRANCHRULE *branchrule, SCIP_BRANCHRULEDATA *branchruledata) Definition: branch.c:1765 SCIP_Real SCIPgetRowLPFeasibility(SCIP *scip, SCIP_ROW *row) Definition: scip.c:28151 static SCIP_RETCODE branchruledataEnsureArraySize(SCIP *scip, SCIP_BRANCHRULEDATA *branchruledata, int maxindex) Definition: branch_distribution.c:121 SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:41907 Definition: type_var.h:42 #define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum) Definition: scip.h:20562 void SCIPvarCalcDistributionParameters(SCIP *scip, SCIP_Real varlb, SCIP_Real varub, SCIP_VARTYPE vartype, SCIP_Real *mean, SCIP_Real *variance) Definition: branch_distribution.c:235 Definition: type_retcode.h:33 SCIP_EVENTHDLRDATA * SCIPeventhdlrGetData(SCIP_EVENTHDLR *eventhdlr) Definition: event.c:288 static SCIP_DECL_BRANCHEXECLP(branchExeclpDistribution) Definition: branch_distribution.c:1096 static SCIP_RETCODE calcBranchScore(SCIP *scip, SCIP_BRANCHRULEDATA *branchruledata, SCIP_VAR *var, SCIP_Real lpsolval, SCIP_Real *upscore, SCIP_Real *downscore, char scoreparam) Definition: branch_distribution.c:594 Definition: struct_branch.h:68 SCIP_RETCODE SCIPupdateDistributionScore(SCIP *scip, SCIP_Real currentprob, SCIP_Real newprobup, SCIP_Real newprobdown, SCIP_Real *upscore, SCIP_Real *downscore, char scoreparam) Definition: branch_distribution.c:524 Definition: struct_lp.h:189 SCIP_RETCODE SCIPsetBranchruleExitsol(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXITSOL((*branchexitsol))) Definition: scip.c:8370 static SCIP_RETCODE varProcessBoundChanges(SCIP *scip, SCIP_BRANCHRULEDATA *branchruledata, SCIP_VAR *var) Definition: branch_distribution.c:885 static SCIP_DECL_BRANCHEXITSOL(branchExitsolDistribution) Definition: branch_distribution.c:1041 SCIP_RETCODE SCIPdropVarEvent(SCIP *scip, SCIP_VAR *var, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos) Definition: scip.c:36668 Definition: type_history.h:34 Definition: type_history.h:35 SCIP_BRANCHRULEDATA * SCIPbranchruleGetData(SCIP_BRANCHRULE *branchrule) Definition: branch.c:1755 SCIP_Real SCIPgetBranchScore(SCIP *scip, SCIP_VAR *var, SCIP_Real downgain, SCIP_Real upgain) Definition: scip.c:33580 static SCIP_DECL_EVENTFREE(eventFreeDistribution) Definition: branch_distribution.c:1011 static void rowCalculateGauss(SCIP *scip, SCIP_BRANCHRULEDATA *branchruledata, SCIP_ROW *row, SCIP_Real *mu, SCIP_Real *sigma2, int *rowinfinitiesdown, int *rowinfinitiesup) Definition: branch_distribution.c:411 SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:41933 static SCIP_DECL_EVENTEXEC(eventExecDistribution) Definition: branch_distribution.c:1273 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) Definition: scip.c:3657 SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file) Definition: scip.c:28334 SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:41959 SCIP_RETCODE SCIPsetEventhdlrFree(SCIP *scip, SCIP_EVENTHDLR *eventhdlr, SCIP_DECL_EVENTFREE((*eventfree))) Definition: scip.c:7824 Definition: type_set.h:42 Definition: type_result.h:45 SCIP_Real SCIProwCalcProbability(SCIP *scip, SCIP_ROW *row, SCIP_Real mu, SCIP_Real sigma2, int rowinfinitiesdown, int rowinfinitiesup) Definition: branch_distribution.c:344 Definition: objbranchrule.h:33 Definition: struct_event.h:185 Definition: type_var.h:56 |