28 #include "scip/branch_fullstrong.h" 29 #include "scip/cons_linear.h" 32 #include "scip/pub_tree.h" 33 #include "scip/struct_scip.h" 34 #include "scip/clock.h" 39 #define BRANCHRULE_NAME "stp" 40 #define BRANCHRULE_DESC "stp branching on vertices" 41 #define BRANCHRULE_PRIORITY -1000000 42 #define BRANCHRULE_MAXDEPTH -1 43 #define BRANCHRULE_MAXBOUNDDIST 1.0 67 SCIP_PROBDATA* probdata;
78 probdata = SCIPgetProbData(scip);
79 assert(probdata != NULL);
86 if( !SCIPhasCurrentNodeLP(scip) || SCIPgetLPSolstat(scip) != SCIP_LPSOLSTAT_OPTIMAL )
93 assert(edgevars != NULL);
97 SCIP_CALL( SCIPallocBufferArray(scip, &inflow, nnodes) );
101 for( k = 0; k < nnodes; k++ )
105 inflow[k] += SCIPvarGetLPSol(edgevars[a]);
107 if( !
Is_term(g->
term[k]) && SCIPisLT(scip, inflow[k], 1.0) && SCIPisLT(scip, fabs(inflow[k] - 0.5), maxflow) )
110 maxflow = fabs(inflow[k] - 0.5);
111 SCIPdebugMessage(
"new maxflow %f on vertex %d \n", inflow[k], branchvert );
114 SCIPdebugMessage(
"maxflow %f on vertex %d, term? %d \n", maxflow, branchvert,
Is_term(g->
term[branchvert]) );
115 (*vertex) = branchvert;
117 SCIPfreeBufferArray(scip, &inflow);
130 assert(scip != NULL);
131 assert(branchrule != NULL);
132 assert(strcmp(SCIPbranchruleGetName(branchrule),
BRANCHRULE_NAME) == 0);
144 SCIP_BRANCHRULEDATA* branchruledata;
147 branchruledata = SCIPbranchruleGetData(branchrule);
148 assert(branchruledata != NULL);
150 SCIPfreeMemory(scip, &branchruledata);
151 SCIPbranchruleSetData(branchrule, NULL);
160 SCIP_BRANCHRULEDATA* branchruledata;
162 branchruledata = SCIPbranchruleGetData(branchrule);
163 assert(branchruledata != NULL);
165 branchruledata->lastcand = 0;
175 SCIP_BRANCHRULEDATA* branchruledata;
177 SCIPstatistic(
int j = 0);
181 branchruledata = SCIPbranchruleGetData(branchrule);
182 assert(branchruledata != NULL);
191 SCIP_PROBDATA* probdata;
195 SCIP_NODE* vertexout;
197 SCIP_Real estimatein;
198 SCIP_Real estimateout;
203 assert(branchrule != NULL);
204 assert(strcmp(SCIPbranchruleGetName(branchrule),
BRANCHRULE_NAME) == 0);
205 assert(scip != NULL);
206 assert(result != NULL);
208 SCIPdebugMessage(
"Execlp method of Stp branching\n ");
209 estimatein = SCIPgetUpperbound(scip);
210 estimateout = SCIPgetUpperbound(scip);
211 *result = SCIP_DIDNOTRUN;
214 probdata = SCIPgetProbData(scip);
215 assert(probdata != NULL);
227 SCIPdebugMessage(
"Branching did not run \n");
234 SCIP_CALL( SCIPcreateConsLinear(scip, &consin,
"consin", 0,
235 NULL, NULL, 1.0, 1.0,
238 SCIP_CALL( SCIPcreateConsLinear(scip, &consout,
"consout", 0,
239 NULL, NULL, 0.0, 0.0,
244 SCIP_CALL( SCIPaddCoefLinear(scip, consin, edgevars[e], 1.0) );
245 SCIP_CALL( SCIPaddCoefLinear(scip, consout, edgevars[e], 1.0) );
246 SCIP_CALL( SCIPaddCoefLinear(scip, consout, edgevars[
flipedge(e)], 1.0) );
250 SCIP_CALL( SCIPcreateChild(scip, &vertexin, 1.0, estimatein) );
252 SCIP_CALL( SCIPcreateChild(scip, &vertexout, 1.0, estimateout) );
254 assert(vertexin != NULL);
255 assert(vertexout != NULL);
257 SCIP_CALL( SCIPaddConsNode(scip, vertexin, consin, NULL) );
258 SCIP_CALL( SCIPaddConsNode(scip, vertexout, consout, NULL) );
261 SCIP_CALL( SCIPreleaseCons(scip, &consin) );
262 SCIP_CALL( SCIPreleaseCons(scip, &consout) );
264 SCIPdebugMessage(
"Branched on stp vertex %d \n", branchvertex);
266 *result = SCIP_BRANCHED;
281 SCIP_BRANCHRULEDATA* branchruledata;
282 SCIP_BRANCHRULE* branchrule;
285 SCIP_CALL( SCIPallocMemory(scip, &branchruledata) );
286 branchruledata->lastcand = 0;
292 assert(branchrule != NULL);
295 SCIP_CALL( SCIPsetBranchruleCopy(scip, branchrule, branchCopyStp) );
296 SCIP_CALL( SCIPsetBranchruleFree(scip, branchrule, branchFreeStp) );
297 SCIP_CALL( SCIPsetBranchruleInit(scip, branchrule, branchInitStp) );
298 SCIP_CALL( SCIPsetBranchruleExit(scip, branchrule, branchExitStp) );
299 SCIP_CALL( SCIPsetBranchruleExecLp(scip, branchrule, branchExeclpStp) );
#define BRANCHRULE_PRIORITY
static SCIP_DECL_BRANCHEXECLP(branchExeclpStp)
SCIP_RETCODE SCIPincludeBranchruleStp(SCIP *scip)
Problem data for stp problem.
static SCIP_DECL_BRANCHEXIT(branchExitStp)
GRAPH * SCIPprobdataGetGraph(SCIP_PROBDATA *probdata)
static SCIP_DECL_BRANCHCOPY(branchCopyStp)
#define BRANCHRULE_MAXBOUNDDIST
static SCIP_DECL_BRANCHINIT(branchInitStp)
SCIP_VAR ** SCIPprobdataGetEdgeVars(SCIP *scip)
static SCIP_DECL_BRANCHFREE(branchFreeStp)
includes various files containing graph methods used for Steiner problems
#define BRANCHRULE_MAXDEPTH
Steiner vertex branching rule.
static SCIP_RETCODE selectBranchingVertex(SCIP *scip, int *vertex)