37 #define PROP_NAME "stp" 38 #define PROP_DESC "stp propagator" 39 #define PROP_TIMING SCIP_PROPTIMING_DURINGLPLOOP | SCIP_PROPTIMING_AFTERLPLOOP 40 #define PROP_PRIORITY +1000000 42 #define PROP_DELAY FALSE 51 #define DEFAULT_MAXNWAITINGROUNDS 3 82 assert(SCIPvarGetLbLocal(edgevar) < 0.5);
83 if( SCIPvarGetUbLocal(edgevar) > 0.5 && SCIPvarGetLbLocal(edgevar) < 0.5 )
85 SCIP_CALL( SCIPchgVarUb(scip, edgevar, 0.0) );
102 assert(scip != NULL);
103 assert(prop != NULL);
104 assert(strcmp(SCIPpropGetName(prop),
PROP_NAME) == 0);
117 SCIP_PROPDATA* propdata;
120 propdata = SCIPpropGetData(prop);
121 assert(propdata != NULL);
123 SCIPfreeMemory(scip, &propdata);
125 SCIPpropSetData(prop, NULL);
135 SCIP_PROPDATA* propdata;
136 SCIP_PROBDATA* probdata;
145 SCIP_Real cutoffbound;
146 SCIP_Real minpathcost;
155 *result = SCIP_DIDNOTRUN;
158 if( SCIPgetStage(scip) < SCIP_STAGE_SOLVING )
162 if( !SCIPhasCurrentNodeLP(scip) )
166 if( SCIPgetLPSolstat(scip) != SCIP_LPSOLSTAT_OPTIMAL )
170 if( !SCIPisLPRelax(scip) )
174 if( !SCIPisLPSolBasic(scip) )
177 cutoffbound = SCIPgetCutoffbound(scip);
180 if( SCIPisInfinity(scip, cutoffbound) )
184 probdata = SCIPgetProbData(scip);
185 assert(probdata != NULL);
188 assert(graph != NULL);
190 nedges = graph->
edges;
191 nnodes = graph->
knots;
200 if( SCIPgetNPseudoBranchCands(scip) == 0 )
204 propdata = SCIPpropGetData(prop);
205 assert(propdata != NULL);
211 && (propdata->nlastcall + propdata->nfails > propdata->ncalls) )
214 propdata->nlastcall = propdata->ncalls;
217 lpobjval = SCIPgetLPObjval(scip);
219 if( SCIPisEQ(scip, lpobjval, 0.0) )
222 *result = SCIP_DIDNOTFIND;
225 minpathcost = cutoffbound - lpobjval;
226 SCIPdebugMessage(
"cutoffbound %f, lpobjval %f\n", cutoffbound, lpobjval);
228 SCIP_CALL( SCIPallocBufferArray(scip, &cost, nedges) );
229 SCIP_CALL( SCIPallocBufferArray(scip, &costrev, nedges) );
230 SCIP_CALL( SCIPallocBufferArray(scip, &pathdist, nnodes) );
231 SCIP_CALL( SCIPallocBufferArray(scip, &vbase, nnodes) );
232 SCIP_CALL( SCIPallocBufferArray(scip, &pathedge, nnodes) );
233 SCIP_CALL( SCIPallocBufferArray(scip, &vnoi, nnodes) );
235 for( e = 0; e < nedges; ++e )
237 assert(SCIPvarIsBinary(vars[e]));
240 if( SCIPvarGetLbLocal(vars[e]) + 0.5 > SCIPvarGetUbLocal(vars[e]) )
242 if( SCIPvarGetLbLocal(vars[e]) > 0.5 )
246 assert(SCIPvarGetUbLocal(vars[e]) < 0.5);
252 if( SCIPisFeasZero(scip, SCIPgetSolVal(scip, NULL, vars[e])) )
254 assert(!SCIPisDualfeasNegative(scip, SCIPgetVarRedcost(scip, vars[e])));
255 cost[e] = SCIPgetVarRedcost(scip, vars[e]);
259 assert(!SCIPisDualfeasPositive(scip, SCIPgetVarRedcost(scip, vars[e])));
260 assert(SCIPisFeasEQ(scip, SCIPgetSolVal(scip, NULL, vars[e]), 1.0) || SCIPisDualfeasZero(scip, SCIPgetVarRedcost(scip, vars[e])));
265 costrev[e + 1] = cost[e];
267 costrev[e - 1] = cost[e];
270 for( k = 0; k < nnodes; k++ )
271 graph->
mark[k] = (graph->
grad[k] > 0);
283 for( k = 0; k < nnodes; k++ )
289 if( !
Is_term(graph->
term[k]) && SCIPisGT(scip, pathdist[k] + vnoi[k].dist, minpathcost) )
294 SCIP_CALL(
fixedgevar(scip, vars[e], &nfixed) );
304 if( SCIPisGT(scip, pathdist[k] + cost[e] + vnoi[graph->
head[e]].
dist, minpathcost) )
308 SCIP_CALL(
fixedgevar(scip, edgevar, &nfixed) );
313 SCIPdebugMessage(
"fixed by STP propagator: %d \n", nfixed );
317 propdata->nfails = 0;
318 *result = SCIP_REDUCEDDOM;
325 SCIPfreeBufferArray(scip, &vnoi);
326 SCIPfreeBufferArray(scip, &pathedge);
327 SCIPfreeBufferArray(scip, &vbase);
328 SCIPfreeBufferArray(scip, &pathdist);
329 SCIPfreeBufferArray(scip, &costrev);
330 SCIPfreeBufferArray(scip, &cost);
347 SCIP_PROPDATA* propdata;
350 SCIP_CALL( SCIPallocMemory(scip, &propdata) );
354 propExecStp, propdata) );
356 assert(prop != NULL);
359 SCIP_CALL( SCIPsetPropCopy(scip, prop, propCopyStp) );
360 SCIP_CALL( SCIPsetPropFree(scip, prop, propFreeStp) );
361 propdata->nfails = 0;
362 propdata->ncalls = 0;
363 propdata->nlastcall = 0;
SCIP_RETCODE fixedgevar(SCIP *scip, SCIP_VAR *edgevar, int *nfixed)
static SCIP_DECL_PROPCOPY(propCopyStp)
SCIP_VAR ** SCIPprobdataGetVars(SCIP *scip)
GRAPH * SCIPprobdataGetGraph(SCIP_PROBDATA *probdata)
void graph_path_execX(SCIP *, const GRAPH *, int, SCIP_Real *, SCIP_Real *, int *)
#define STP_MAX_NODE_WEIGHT
void voronoi_terms(SCIP *, const GRAPH *, SCIP_Real *, PATH *, int *, int *, int *)
SCIP_RETCODE SCIPincludePropStp(SCIP *scip)
propagator for Steiner tree problems, using the LP reduced costs
static SCIP_DECL_PROPFREE(propFreeStp)
#define STP_PRIZE_COLLECTING
#define STP_ROOTED_PRIZE_COLLECTING
#define DEFAULT_MAXNWAITINGROUNDS
static SCIP_DECL_PROPEXEC(propExecStp)