29 #define BRANCHRULE_NAME "leastinf" 30 #define BRANCHRULE_DESC "least infeasible branching" 31 #define BRANCHRULE_PRIORITY 50 32 #define BRANCHRULE_MAXDEPTH -1 33 #define BRANCHRULE_MAXBOUNDDIST 1.0 55 assert(bestvar !=
NULL);
56 assert(bestscore !=
NULL);
57 assert(bestobj !=
NULL);
58 assert(*bestobj >= 0.0);
99 for( i = 0; i < nmultvars; ++i )
104 if(
SCIPisEQ(scip, multvarlb, multvarub) )
107 assert(multscalars !=
NULL);
108 assert(multscalars[i] != 0.0);
114 if( multscalars[i] > 0.0 )
120 aggrvarsol1 = (candsol - maxact) / multscalars[i] + multvarub;
126 aggrvarsol2 = (candsol - minact) / multscalars[i] + multvarlb;
134 aggrvarsol2 = (candsol - maxact) / multscalars[i] + multvarlb;
140 aggrvarsol1 = (candsol - minact) / multscalars[i] + multvarub;
153 aggrvarsol = aggrvarsol2;
158 aggrvarsol = aggrvarsol1;
160 aggrvarsol =
REALABS(aggrvarsol1) <
REALABS(aggrvarsol2) ? aggrvarsol1 : aggrvarsol2;
165 multvars[i], candscore, aggrvarsol);
170 for( i = 0; i < nmultvars; ++i )
175 if(
SCIPisEQ(scip, multvarlb, multvarub) )
182 assert(*bestvar !=
NULL);
192 (
SCIPisLT(scip, candscore, *bestscore) || (
SCIPisLE(scip, candscore, *bestscore) && obj > *bestobj))) )
195 *bestscore = candscore;
210 assert(branchrule !=
NULL);
235 assert(branchrule !=
NULL);
238 assert(result !=
NULL);
244 assert(nlpcands > 0);
250 for( i = 0; i < nlpcands; ++i )
252 assert(lpcands[i] !=
NULL);
254 infeasibility = lpcandsfrac[i];
255 infeasibility =
MIN(infeasibility, 1.0-infeasibility);
256 score = 1.0 - infeasibility;
261 || (
SCIPisGE(
scip, score, bestscore) && obj > bestobj) )
268 assert(bestcand >= 0);
270 SCIPdebugMsg(
scip,
" -> %d candidates, selected candidate %d: variable <%s> (frac=%g, obj=%g, factor=%g, score=%g)\n",
271 nlpcands, bestcand,
SCIPvarGetName(lpcands[bestcand]), lpcandsfrac[bestcand], bestobj,
300 assert(branchrule !=
NULL);
303 assert(result !=
NULL);
309 assert(nexterncands > 0);
316 for( i = 0; i < nexterncands; ++i )
318 updateBestCandidate(
scip, &bestcand, &bestscore, &bestobj, &bestsol, externcands[i], externcandsscore[i], externcandssol[i]);
321 if( bestcand ==
NULL )
323 SCIPerrorMessage(
"branchExecextLeastinf failed to select a branching variable from %d candidates\n", nexterncands);
330 SCIPdebugMsg(
scip,
" -> %d candidates, selected variable <%s> (infeas=%g, obj=%g, factor=%g, score=%g), branching point=%g\n",
337 if( downchild !=
NULL || eqchild !=
NULL || upchild !=
NULL )
367 assert(branchrule !=
NULL);
SCIP_RETCODE SCIPgetLPBranchCands(SCIP *scip, SCIP_VAR ***lpcands, SCIP_Real **lpcandssol, SCIP_Real **lpcandsfrac, int *nlpcands, int *npriolpcands, int *nfracimplvars)
SCIP_Real * SCIPvarGetMultaggrScalars(SCIP_VAR *var)
SCIP_Real SCIPvarGetBranchFactor(SCIP_VAR *var)
SCIP_VAR ** SCIPvarGetMultaggrVars(SCIP_VAR *var)
static SCIP_DECL_BRANCHCOPY(branchCopyLeastinf)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define BRANCHRULE_PRIORITY
SCIP_Real SCIPgetBranchingPoint(SCIP *scip, SCIP_VAR *var, SCIP_Real suggestion)
#define BRANCHRULE_MAXBOUNDDIST
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_RETCODE SCIPsetBranchruleCopy(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHCOPY((*branchcopy)))
enum SCIP_Retcode SCIP_RETCODE
least infeasible LP branching rule
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_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPgetExternBranchCands(SCIP *scip, SCIP_VAR ***externcands, SCIP_Real **externcandssol, SCIP_Real **externcandsscore, int *nexterncands, int *nprioexterncands, int *nprioexternbins, int *nprioexternints, int *nprioexternimpls)
SCIP_Real SCIPcomputeVarLbLocal(SCIP *scip, SCIP_VAR *var)
SCIP_RETCODE SCIPsetBranchruleExecLp(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXECLP((*branchexeclp)))
static SCIP_DECL_BRANCHEXECEXT(branchExecextLeastinf)
SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
SCIP_RETCODE SCIPbranchVar(SCIP *scip, SCIP_VAR *var, SCIP_NODE **downchild, SCIP_NODE **eqchild, SCIP_NODE **upchild)
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_Real SCIPcomputeVarUbLocal(SCIP *scip, SCIP_VAR *var)
SCIP_RETCODE SCIPbranchVarVal(SCIP *scip, SCIP_VAR *var, SCIP_Real val, SCIP_NODE **downchild, SCIP_NODE **eqchild, SCIP_NODE **upchild)
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
static void updateBestCandidate(SCIP *scip, SCIP_VAR **bestvar, SCIP_Real *bestscore, SCIP_Real *bestobj, SCIP_Real *bestsol, SCIP_VAR *cand, SCIP_Real candscore, SCIP_Real candsol)
SCIP_RETCODE SCIPincludeBranchruleLeastinf(SCIP *scip)
static SCIP_DECL_BRANCHEXECLP(branchExeclpLeastinf)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_RETCODE SCIPsetBranchruleExecExt(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHEXECEXT((*branchexecext)))
int SCIPvarGetMultaggrNVars(SCIP_VAR *var)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
const char * SCIPbranchruleGetName(SCIP_BRANCHRULE *branchrule)
#define BRANCHRULE_MAXDEPTH
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_Bool SCIPvarIsActive(SCIP_VAR *var)