29 #define BRANCHRULE_NAME "mostinf" 30 #define BRANCHRULE_DESC "most infeasible branching" 31 #define BRANCHRULE_PRIORITY 100 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 (
SCIPisGT(scip, candscore, *bestscore) || (
SCIPisGE(scip, candscore, *bestscore) && obj > *bestobj))) )
195 *bestscore = candscore;
209 assert(
scip != NULL);
210 assert(branchrule != NULL);
235 assert(branchrule != NULL);
237 assert(
scip != 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 = 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,
299 assert(branchrule != NULL);
301 assert(
scip != NULL);
302 assert(result != NULL);
308 assert(nexterncands > 0);
315 for( i = 0; i < nexterncands; ++i )
317 updateBestCandidate(
scip, &bestcand, &bestscore, &bestobj, &bestsol, externcands[i], externcandsscore[i], externcandssol[i]);
320 if( bestcand == NULL )
322 SCIPerrorMessage(
"branchExecextMostinf failed to select a branching variable from %d candidates\n", nexterncands);
329 SCIPdebugMsg(
scip,
" -> %d candidates, selected variable <%s> (infeas=%g, obj=%g, factor=%g, score=%g), branching point=%g\n",
336 if( downchild != NULL || eqchild != NULL || upchild != NULL )
366 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)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPgetBranchingPoint(SCIP *scip, SCIP_VAR *var, SCIP_Real suggestion)
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPsetBranchruleCopy(SCIP *scip, SCIP_BRANCHRULE *branchrule, SCIP_DECL_BRANCHCOPY((*branchcopy)))
enum SCIP_Retcode SCIP_RETCODE
SCIP_RETCODE SCIPincludeBranchruleMostinf(SCIP *scip)
#define BRANCHRULE_MAXDEPTH
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)))
#define BRANCHRULE_PRIORITY
static SCIP_DECL_BRANCHCOPY(branchCopyMostinf)
SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
SCIP_RETCODE SCIPbranchVar(SCIP *scip, SCIP_VAR *var, SCIP_NODE **downchild, SCIP_NODE **eqchild, SCIP_NODE **upchild)
static SCIP_DECL_BRANCHEXECLP(branchExeclpMostinf)
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)
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)
#define BRANCHRULE_MAXBOUNDDIST
most infeasible LP branching rule
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
const char * SCIPbranchruleGetName(SCIP_BRANCHRULE *branchrule)
static SCIP_DECL_BRANCHEXECEXT(branchExecextMostinf)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
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_Bool SCIPvarIsActive(SCIP_VAR *var)