53 #define PROP_NAME "sdp-obbt"
54 #define PROP_DESC "optimization-based bound tightening for SDPs"
55 #define PROP_PRIORITY -1100000
57 #define PROP_DELAY FALSE
58 #define PROP_TIMING SCIP_PROPTIMING_AFTERLPLOOP
60 #define DEFAULT_PROPBIN FALSE
61 #define DEFAULT_PROPCONT TRUE
73 long long int lastnode;
74 SCIP_Real sdpsolvergaptol;
83 #if ( (SCIP_VERSION > 321 || SCIP_SUBVERSION > 0) )
85 SCIP_RETCODE addObjCutoff(
91 char rowname[SCIP_MAXSTRLEN];
95 assert( scip != NULL );
96 assert( SCIPinProbing(scip) );
98 SCIPdebugMessage(
"create objective cutoff and add it to the LP-constraints\n");
100 nvars = SCIPgetNVars(scip);
101 vars = SCIPgetVars(scip);
104 (void) SCIPsnprintf(rowname, SCIP_MAXSTRLEN,
"obbtsdp_objcutoff");
105 SCIP_CALL( SCIPcreateEmptyRowUnspec(scip, &row, rowname, -SCIPinfinity(scip), SCIPgetCutoffbound(scip), FALSE, FALSE, FALSE) );
106 SCIP_CALL( SCIPcacheRowExtensions(scip, row) );
108 for( v = 0; v < nvars; v++ )
110 SCIP_CALL( SCIPaddVarToRow(scip, row, vars[v], SCIPvarGetObj(vars[v])) );
112 SCIP_CALL( SCIPflushRowExtensions(scip, row) );
115 SCIP_CALL( SCIPaddRowProbing(scip, row) );
117 SCIP_CALL( SCIPreleaseRow(scip, &row) );
132 assert( scip != NULL );
133 assert( prop != NULL );
134 assert( strcmp(SCIPpropGetName(prop),
PROP_NAME) == 0 );
147 SCIP_PROPDATA* propdata;
149 propdata = SCIPpropGetData(prop);
150 assert(propdata != NULL);
152 SCIPfreeMemory(scip, &propdata);
153 SCIPpropSetData(prop, NULL);
162 SCIP_PROPDATA* propdata;
164 assert( prop != NULL );
166 propdata = SCIPpropGetData(prop);
168 propdata->lastnode = -1;
177 SCIP_PROPDATA* propdata;
179 assert( prop != NULL );
181 propdata = SCIPpropGetData(prop);
183 SCIP_CALL( SCIPgetRealParam(scip,
"relaxing/SDP/sdpsolvergaptol", &(propdata->sdpsolvergaptol)) );
193 #if ( (SCIP_VERSION > 321 || SCIP_SUBVERSION > 0) )
197 SCIP_PROPDATA* propdata;
200 SCIP_Bool oldobjlimitparam;
201 SCIP_Real probingval;
203 SCIP_RELAX* relaxsdp;
206 SCIP_Real* newbounds;
211 assert( scip != NULL );
212 assert( prop != NULL );
213 assert( result != NULL );
215 *result = SCIP_DIDNOTRUN;
217 SCIPdebugMessage(
"Executing propExecSdpObbt! \n");
220 if ( SCIPisInfinity(scip, SCIPgetCutoffbound(scip)) )
222 SCIPdebugMessage(
"Aborting propExecSdpObbt because of lack of cutoff-bound!\n");
227 if( SCIPgetStage(scip) != SCIP_STAGE_SOLVING || SCIPinRepropagation(scip) || SCIPinProbing(scip) || !SCIPallowObjProp(scip) )
229 SCIPdebugMessage(
"Aborting propExecSdpObbt because we are in presolving, repropagation, probing mode or no objective propagation is allowed!\n");
233 vars = SCIPgetVars(scip);
234 nvars = SCIPgetNVars(scip);
235 propdata = SCIPpropGetData(prop);
237 assert( propdata != NULL );
239 if ( SCIPnodeGetNumber(SCIPgetCurrentNode(scip)) == propdata->lastnode )
241 SCIPdebugMessage(
"Not running again for node %lld!\n", propdata->lastnode);
246 propdata->lastnode = SCIPnodeGetNumber(SCIPgetCurrentNode(scip));
250 SCIP_CALL( SCIPstartProbing(scip) );
251 SCIPdebugMessage(
"start probing\n");
253 SCIP_CALL( addObjCutoff(scip) );
256 SCIP_CALL( SCIPgetBoolParam(scip,
"relaxing/SDP/objlimit", &oldobjlimitparam) );
257 SCIP_CALL( SCIPsetBoolParam(scip,
"relaxing/SDP/objlimit", FALSE) );
260 SCIP_CALL( SCIPallocBufferArray(scip, &newbounds, 2*nvars) );
261 SCIP_CALL( SCIPallocBufferArray(scip, &newboundinds, 2*nvars) );
263 *result = SCIP_DIDNOTFIND;
266 for( v = 0; v < nvars; ++v )
268 SCIP_CALL( SCIPchgVarObjProbing(scip, vars[v], 0.0) );
273 for (v = 0; v < nvars; v++)
276 if ( (( ! propdata->propbin ) && SCIPvarIsBinary(vars[v])) || (( ! propdata->propcont ) && ( ! SCIPvarIsIntegral(vars[v]))) )
278 #ifdef SCIP_MORE_DEBUG
279 if ( SCIPvarIsBinary(vars[v]) )
281 SCIPdebugMessage(
"Skipping binary variable %s\n", SCIPvarGetName(vars[v]));
285 SCIPdebugMessage(
"Skipping continuous variable %s\n", SCIPvarGetName(vars[v]));
292 relaxval = SCIPgetRelaxSolVal(scip, vars[v]);
295 if ( SCIPisFeasGT(scip, relaxval, SCIPvarGetLbLocal(vars[v])) )
298 SCIP_CALL( SCIPchgVarObjProbing(scip, vars[v], 1.0) );
301 SCIP_CALL( SCIPsolveProbingRelax(scip, &cutoff) );
305 relaxsdp = SCIPfindRelax(scip,
"SDP");
309 SCIPdebugMessage(
"Aborting sdp-obbt, as we were unable to solve a probing sdp!\n");
310 if ( *result != SCIP_REDUCEDDOM )
311 *result = SCIP_DIDNOTRUN;
318 SCIPdebugMessage(
"Probing sdp infeasible, so there can't be a better solution for this problem!\n");
319 *result = SCIP_CUTOFF;
328 if ( SCIPisGT(scip, probingval - propdata->sdpsolvergaptol, SCIPvarGetLbLocal(vars[v])) )
331 SCIPdebugMessage(
"Obbt-Sdp tightened lower bound of variable %s from %f to %f !\n",
332 SCIPvarGetName(vars[v]), SCIPvarGetLbLocal(vars[v]), probingval - propdata->sdpsolvergaptol);
334 newbounds[nnewbounds] = probingval;
335 newboundinds[nnewbounds] = -1 * (v+1);
337 *result = SCIP_REDUCEDDOM;
339 #ifdef SCIP_MORE_DEBUG
342 SCIPdebugMessage(
"Obbt-Sdp found lower bound of %f for variable %s, worse than old bound %f !\n",
343 probingval, SCIPvarGetName(vars[v]), SCIPvarGetLbLocal(vars[v]));
347 #ifdef SCIP_MORE_DEBUG
350 SCIPdebugMessage(
"Skipping obbt for lower bound %f of variable %s, as current relaxation's solution is tight.\n",
351 SCIPvarGetLbLocal(vars[v]), SCIPvarGetName(vars[v]));
356 if ( SCIPisFeasLT(scip, relaxval, SCIPvarGetUbLocal(vars[v])) )
359 SCIP_CALL( SCIPchgVarObjProbing(scip, vars[v], -1.0) );
362 SCIP_CALL( SCIPsolveProbingRelax(scip, &cutoff) );
366 relaxsdp = SCIPfindRelax(scip,
"SDP");
370 SCIPdebugMessage(
"Aborting sdp-obbt, as we were unable to solve a probing sdp!\n");
371 if ( *result != SCIP_REDUCEDDOM )
372 *result = SCIP_DIDNOTRUN;
379 SCIPdebugMessage(
"Probing sdp infeasible, so there can't be a better solution for this problem!\n");
380 *result = SCIP_CUTOFF;
389 if ( SCIPisLT(scip, -probingval + propdata->sdpsolvergaptol, SCIPvarGetUbLocal(vars[v])) )
391 SCIPdebugMessage(
"Obbt-Sdp tightened upper bound of variable %s from %f to %f !\n",
392 SCIPvarGetName(vars[v]), SCIPvarGetUbLocal(vars[v]), -probingval + propdata->sdpsolvergaptol);
394 newbounds[nnewbounds] = -probingval;
395 newboundinds[nnewbounds] = v + 1;
397 *result = SCIP_REDUCEDDOM;
399 #ifdef SCIP_MORE_DEBUG
402 SCIPdebugMessage(
"Obbt-Sdp found upper bound of %f for variable %s, worse than old bound %f !\n",
403 -probingval, SCIPvarGetName(vars[v]), SCIPvarGetUbLocal(vars[v]));
407 #ifdef SCIP_MORE_DEBUG
410 SCIPdebugMessage(
"Skipping obbt for upper bound %f of variable %s, as current relaxation's solution is tight.\n",
411 SCIPvarGetUbLocal(vars[v]), SCIPvarGetName(vars[v]));
416 SCIP_CALL( SCIPchgVarObjProbing(scip, vars[v], 0.0) );
419 SCIP_CALL( SCIPendProbing(scip) );
420 SCIPdebugMessage(
"end probing\n");
421 SCIP_CALL( SCIPsetBoolParam(scip,
"relaxing/SDP/objlimit", oldobjlimitparam) );
423 for (i = 0; i < nnewbounds; i++)
425 if ( newboundinds[i] < 0)
427 SCIP_CALL( SCIPchgVarLb(scip, vars[-1 * newboundinds[i] - 1], newbounds[i]) );
431 SCIP_CALL( SCIPchgVarUb(scip, vars[newboundinds[i] - 1], newbounds[i]) );
435 SCIPfreeBufferArray(scip, &newboundinds);
436 SCIPfreeBufferArray(scip, &newbounds);
441 *result = SCIP_DIDNOTRUN;
458 SCIP_PROPDATA* propdata;
463 SCIP_CALL( SCIPallocMemory(scip, &propdata) );
464 propdata->lastnode = -1;
471 propExecSdpObbt, propdata) );
473 assert(prop != NULL);
476 SCIP_CALL( SCIPsetPropCopy(scip, prop, propCopySdpObbt) );
477 SCIP_CALL( SCIPsetPropFree(scip, prop, propFreeSdpObbt) );
478 SCIP_CALL( SCIPsetPropExit(scip, prop, propExitSdpObbt) );
479 SCIP_CALL( SCIPsetPropInitsol(scip, prop, propInitsolSdpObbt) );
482 SCIP_CALL( SCIPaddBoolParam(scip,
"propagating/" PROP_NAME "/propbin",
483 "Should optimization-based bound tightening be performed for binary variables?",
486 SCIP_CALL( SCIPaddBoolParam(scip,
"propagating/" PROP_NAME "/propcont",
487 "Should optimization-based bound tightening be performed for continuous variables?",
SCIP_RETCODE SCIPincludePropSdpObbt(SCIP *scip)
static SCIP_DECL_PROPEXIT(propExitSdpObbt)
static SCIP_DECL_PROPEXEC(propExecSdpObbt)
static SCIP_DECL_PROPCOPY(propCopySdpObbt)
optimization-based bound tightening propagator for semidefinite programs
SCIP_RETCODE SCIPrelaxSdpRelaxVal(SCIP_RELAX *relax, SCIP_Bool *success, SCIP_Real *objval)
static SCIP_DECL_PROPINITSOL(propInitsolSdpObbt)
static SCIP_DECL_PROPFREE(propFreeSdpObbt)
SCIP_Bool SCIPrelaxSdpSolvedProbing(SCIP_RELAX *relax)
SCIP_Bool SCIPrelaxSdpIsFeasible(SCIP_RELAX *relax)