54 #define BRANCHRULE_NAME "sdpmostfrac" 55 #define BRANCHRULE_DESC "branch on the most fractional variable of the SDP" 56 #define BRANCHRULE_PRIORITY 500000 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 mostfracfrac;
100 SCIP_Real mostfracscore;
101 SCIP_Real mostfracobj;
102 SCIP_Real mostfracval;
103 SCIP_VAR* mostfracvar = NULL;
105 assert(
scip != NULL );
106 assert( result != NULL );
108 SCIPdebugMsg(
scip,
"Executing External Branching method of SDP-mostfrac!\n");
112 SCIP_CALL( SCIPgetExternBranchCands(
scip, &cands, &candssol, &candsscore, &ncands, NULL, NULL, NULL, NULL) );
114 assert( ncands > 0 );
117 SCIPdebugMsg(
scip,
"branching candidates for SDP-mostfrac:\n");
118 for (i = 0; i < ncands; i++)
119 SCIPdebugMsg(
scip,
"%s, value = %f, score = %f\n", SCIPvarGetName(cands[i]), candssol[i], candsscore[i]);
128 for (i = 0; i < ncands; i++)
131 if ( SCIPvarGetType(cands[i]) == SCIP_VARTYPE_CONTINUOUS )
133 SCIPdebugMsg(
scip,
"skipping continuous variable %s\n", SCIPvarGetName(cands[i]));
142 if ( SCIPisFeasGT(
scip, SCIPfeasFrac(
scip, candssol[i]), mostfracfrac) ||
143 (SCIPisFeasEQ(
scip, SCIPfeasFrac(
scip, candssol[i]), mostfracfrac) && SCIPisGT(
scip, candsscore[i], mostfracscore)) ||
144 (SCIPisFeasEQ(
scip, SCIPfeasFrac(
scip, candssol[i]), mostfracfrac) && SCIPisEQ(
scip, candsscore[i], mostfracscore)
145 && SCIPisGT(
scip, SCIPvarGetObj(cands[i]), mostfracobj)) ||
146 (SCIPisFeasEQ(
scip, SCIPfeasFrac(
scip, candssol[i]), mostfracfrac) && SCIPisEQ(
scip, candsscore[i], mostfracscore)
147 && SCIPisEQ(
scip, SCIPvarGetObj(cands[i]), mostfracobj) && SCIPvarGetIndex(cands[i]) < SCIPvarGetIndex(mostfracvar)) )
150 mostfracfrac = SCIPfeasFrac(
scip, candssol[i]);
151 mostfracscore = candsscore[i];
152 mostfracobj = REALABS(SCIPvarGetObj(cands[i]));
153 mostfracval = candssol[i];
154 mostfracvar = cands[i];
159 if ( mostfracfrac == -1.0 )
161 SCIPdebugMsg(
scip,
"Skipping SDP-mostfrac branching rule since all branching variables are continuous\n");
162 *result = SCIP_DIDNOTFIND;
166 assert( mostfracvar != NULL );
167 assert( SCIPisFeasGT(
scip, mostfracfrac, 0.0) );
170 SCIPdebugMsg(
scip,
"branching on variable %s with value %f and score %f\n", SCIPvarGetName(mostfracvar), mostfracval, mostfracscore);
171 SCIP_CALL( SCIPbranchVarVal(
scip, mostfracvar, mostfracval, NULL, NULL, NULL) );
173 *result = SCIP_BRANCHED;
187 SCIP_BRANCHRULEDATA* branchruledata;
188 SCIP_BRANCHRULE* branchrule;
191 branchruledata = NULL;
199 assert(branchrule != NULL);
202 SCIP_CALL( SCIPsetBranchruleCopy(scip, branchrule, branchCopySdpmostfrac) );
203 SCIP_CALL( SCIPsetBranchruleExecExt(scip, branchrule, branchExecextSdpmostfrac) );
#define BRANCHRULE_MAXBOUNDDIST
most fractional branching rule for SCIP-SDP
SCIP_RETCODE SCIPincludeBranchruleSdpmostfrac(SCIP *scip)
#define BRANCHRULE_PRIORITY
#define BRANCHRULE_MAXDEPTH
static SCIP_DECL_BRANCHCOPY(branchCopySdpmostfrac)
static SCIP_DECL_BRANCHEXECEXT(branchExecextSdpmostfrac)