54 #define BRANCHRULE_NAME "sdpmostinf" 55 #define BRANCHRULE_DESC "branch on the most infeasible variable of the SDP" 56 #define BRANCHRULE_PRIORITY 1000000 57 #define BRANCHRULE_MAXDEPTH -1 58 #define BRANCHRULE_MAXBOUNDDIST 1.0 81 assert(branchrule != NULL);
82 assert(strcmp(SCIPbranchruleGetName(branchrule),
BRANCHRULE_NAME) == 0);
96 SCIP_VAR** cands = NULL;
98 SCIP_Real* candsscore;
99 SCIP_Real currentfrac;
100 SCIP_Real currentinf;
101 SCIP_Real mostinfinf;
102 SCIP_Real mostinfscore;
103 SCIP_Real mostinfobj;
104 SCIP_Real mostinfval;
105 SCIP_VAR* mostinfvar = NULL;
107 assert(
scip != NULL );
108 assert( result != NULL );
110 SCIPdebugMsg(
scip,
"Executing External Branching method of SDP-mostinf!\n");
114 SCIP_CALL( SCIPgetExternBranchCands(
scip, &cands, &candssol, &candsscore, &ncands, NULL, NULL, NULL, NULL) );
116 assert( ncands > 0 );
119 SCIPdebugMsg(
scip,
"branching candidates for SDP-mostinf:\n");
120 for (i = 0; i < ncands; i++)
121 SCIPdebugMsg(
scip,
"%s, value = %f, score = %f\n", SCIPvarGetName(cands[i]), candssol[i], candsscore[i]);
130 for (i = 0; i < ncands; i++)
133 if ( SCIPvarGetType(cands[i]) == SCIP_VARTYPE_CONTINUOUS )
135 SCIPdebugMsg(
scip,
"skipping continuous variable %s\n", SCIPvarGetName(cands[i]));
139 currentfrac = SCIPfeasFrac(
scip, candssol[i]);
140 currentinf = (currentfrac <= 0.5) ? currentfrac : 1 - currentfrac;
146 if ( SCIPisFeasGT(
scip, currentinf, mostinfinf) ||
147 (SCIPisFeasEQ(
scip, currentinf, mostinfinf) && SCIPisGT(
scip, candsscore[i], mostinfscore)) ||
148 (SCIPisFeasEQ(
scip, currentinf, mostinfinf) && SCIPisEQ(
scip, candsscore[i], mostinfscore) && SCIPisGT(
scip, SCIPvarGetObj(cands[i]), mostinfobj)) ||
149 (SCIPisFeasEQ(
scip, currentinf, mostinfinf) && SCIPisEQ(
scip, candsscore[i], mostinfscore) && SCIPisEQ(
scip, SCIPvarGetObj(cands[i]), mostinfobj) &&
150 SCIPvarGetIndex(cands[i]) < SCIPvarGetIndex(mostinfvar)) )
153 mostinfinf = currentinf;
154 mostinfval = candssol[i];
155 mostinfobj = REALABS(SCIPvarGetObj(cands[i]));
156 mostinfscore = candsscore[i];
157 mostinfvar = cands[i];
162 if ( mostinfinf == -1.0 )
164 SCIPdebugMsg(
scip,
"Skipping SDP-mostinf branching rule since all branching variables are continuous\n");
165 *result = SCIP_DIDNOTFIND;
169 assert( mostinfvar != NULL );
170 assert( SCIPisFeasGT(
scip, mostinfinf, 0.0) );
173 SCIPdebugMsg(
scip,
"branching on variable %s with value %f and score %f\n", SCIPvarGetName(mostinfvar), mostinfval, mostinfscore);
174 SCIP_CALL( SCIPbranchVarVal(
scip, mostinfvar, mostinfval, NULL, NULL, NULL) );
176 *result = SCIP_BRANCHED;
190 SCIP_BRANCHRULEDATA* branchruledata;
191 SCIP_BRANCHRULE* branchrule;
194 branchruledata = NULL;
202 assert(branchrule != NULL);
205 SCIP_CALL( SCIPsetBranchruleCopy(scip, branchrule, branchCopySdpmostinf) );
206 SCIP_CALL( SCIPsetBranchruleExecExt(scip, branchrule, branchExecextSdpmostinf) );
#define BRANCHRULE_MAXBOUNDDIST
SCIP_RETCODE SCIPincludeBranchruleSdpmostinf(SCIP *scip)
most infeasible branching rule for SCIP-SDP
#define BRANCHRULE_PRIORITY
static SCIP_DECL_BRANCHEXECEXT(branchExecextSdpmostinf)
#define BRANCHRULE_MAXDEPTH
static SCIP_DECL_BRANCHCOPY(branchCopySdpmostinf)