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;
82 #if ( (SCIP_VERSION > 321 || SCIP_SUBVERSION > 0) )
84 SCIP_RETCODE addObjCutoff(
90 char rowname[SCIP_MAXSTRLEN];
94 assert( scip != NULL );
95 assert( SCIPinProbing(scip) );
97 SCIPdebugMessage(
"create objective cutoff and add it to the LP-constraints\n");
99 nvars = SCIPgetNVars(scip);
100 vars = SCIPgetVars(scip);
103 (void) SCIPsnprintf(rowname, SCIP_MAXSTRLEN,
"obbtsdp_objcutoff");
104 SCIP_CALL( SCIPcreateEmptyRowUnspec(scip, &row, rowname, -SCIPinfinity(scip), SCIPgetCutoffbound(scip), FALSE, FALSE, FALSE) );
105 SCIP_CALL( SCIPcacheRowExtensions(scip, row) );
107 for( v = 0; v < nvars; v++ )
109 SCIP_CALL( SCIPaddVarToRow(scip, row, vars[v], SCIPvarGetObj(vars[v])) );
111 SCIP_CALL( SCIPflushRowExtensions(scip, row) );
114 SCIP_CALL( SCIPaddRowProbing(scip, row) );
129 assert( scip != NULL );
130 assert( prop != NULL );
131 assert( strcmp(SCIPpropGetName(prop),
PROP_NAME) == 0 );
144 SCIP_PROPDATA* propdata;
146 propdata = SCIPpropGetData(prop);
147 assert(propdata != NULL);
149 SCIPfreeMemory(scip, &propdata);
150 SCIPpropSetData(prop, NULL);
159 SCIP_PROPDATA* propdata;
161 assert( prop != NULL );
163 propdata = SCIPpropGetData(prop);
165 propdata->lastnode = -1;
176 #if ( (SCIP_VERSION > 321 || SCIP_SUBVERSION > 0) )
180 SCIP_PROPDATA* propdata;
183 SCIP_Bool oldobjlimitparam;
184 SCIP_Real probingval;
186 SCIP_RELAX* relaxsdp;
189 SCIP_Real* newbounds;
194 assert( scip != NULL );
195 assert( prop != NULL );
196 assert( result != NULL );
198 *result = SCIP_DIDNOTRUN;
200 SCIPdebugMessage(
"Executing propExecSdpObbt! \n");
203 if ( SCIPisInfinity(scip, SCIPgetCutoffbound(scip)) )
205 SCIPdebugMessage(
"Aborting propExecSdpObbt because of lack of cutoff-bound!\n");
210 if( SCIPgetStage(scip) != SCIP_STAGE_SOLVING || SCIPinRepropagation(scip) || SCIPinProbing(scip) || !SCIPallowObjProp(scip) )
212 SCIPdebugMessage(
"Aborting propExecSdpObbt because we are in presolving, repropagation, probing mode or no objective propagation is allowed!\n");
216 vars = SCIPgetVars(scip);
217 nvars = SCIPgetNVars(scip);
218 propdata = SCIPpropGetData(prop);
220 assert( propdata != NULL );
222 if ( SCIPnodeGetNumber(SCIPgetCurrentNode(scip)) == propdata->lastnode )
224 SCIPdebugMessage(
"Not running again for node %lld!\n", propdata->lastnode);
229 propdata->lastnode = SCIPnodeGetNumber(SCIPgetCurrentNode(scip));
233 SCIP_CALL( SCIPstartProbing(scip) );
234 SCIPdebugMessage(
"start probing\n");
236 SCIP_CALL( addObjCutoff(scip) );
239 SCIP_CALL( SCIPgetBoolParam(scip,
"relaxing/SDP/objlimit", &oldobjlimitparam) );
240 SCIP_CALL( SCIPsetBoolParam(scip,
"relaxing/SDP/objlimit", FALSE) );
243 SCIP_CALL( SCIPallocBufferArray(scip, &newbounds, 2*nvars) );
244 SCIP_CALL( SCIPallocBufferArray(scip, &newboundinds, 2*nvars) );
246 *result = SCIP_DIDNOTFIND;
249 for( v = 0; v < nvars; ++v )
251 SCIP_CALL( SCIPchgVarObjProbing(scip, vars[v], 0.0) );
256 for (v = 0; v < nvars; v++)
259 if ( (( ! propdata->propbin ) && SCIPvarIsBinary(vars[v])) || (( ! propdata->propcont ) && ( ! SCIPvarIsIntegral(vars[v]))) )
261 #ifdef SCIP_MORE_DEBUG
262 if ( SCIPvarIsBinary(vars[v]) )
264 SCIPdebugMessage(
"Skipping binary variable %s\n", SCIPvarGetName(vars[v]));
268 SCIPdebugMessage(
"Skipping continuous variable %s\n", SCIPvarGetName(vars[v]));
275 relaxval = SCIPgetRelaxSolVal(scip, vars[v]);
278 if ( SCIPisFeasGT(scip, relaxval, SCIPvarGetLbLocal(vars[v])) )
281 SCIP_CALL( SCIPchgVarObjProbing(scip, vars[v], 1.0) );
284 SCIP_CALL( SCIPsolveProbingRelax(scip, &cutoff) );
288 relaxsdp = SCIPfindRelax(scip,
"SDP");
292 SCIPdebugMessage(
"Aborting sdp-obbt, as we were unable to solve a probing sdp!\n");
293 if ( *result != SCIP_REDUCEDDOM )
294 *result = SCIP_DIDNOTRUN;
301 SCIPdebugMessage(
"Probing sdp infeasible, so there can't be a better solution for this problem!\n");
302 *result = SCIP_CUTOFF;
310 if ( SCIPisGT(scip, probingval, SCIPvarGetLbLocal(vars[v])) )
313 SCIPdebugMessage(
"Obbt-Sdp tightened lower bound of variable %s from %f to %f !\n",
314 SCIPvarGetName(vars[v]), SCIPvarGetLbLocal(vars[v]), probingval);
316 newbounds[nnewbounds] = probingval;
317 newboundinds[nnewbounds] = -1 * (v+1);
319 *result = SCIP_REDUCEDDOM;
321 #ifdef SCIP_MORE_DEBUG
324 SCIPdebugMessage(
"Obbt-Sdp found lower bound of %f for variable %s, worse than old bound %f !\n",
325 probingval, SCIPvarGetName(vars[v]), SCIPvarGetLbLocal(vars[v]));
329 #ifdef SCIP_MORE_DEBUG
332 SCIPdebugMessage(
"Skipping obbt for lower bound %f of variable %s, as current relaxation's solution is tight.\n",
333 SCIPvarGetLbLocal(vars[v]), SCIPvarGetName(vars[v]));
338 if ( SCIPisFeasLT(scip, relaxval, SCIPvarGetUbLocal(vars[v])) )
341 SCIP_CALL( SCIPchgVarObjProbing(scip, vars[v], -1.0) );
344 SCIP_CALL( SCIPsolveProbingRelax(scip, &cutoff) );
348 relaxsdp = SCIPfindRelax(scip,
"SDP");
352 SCIPdebugMessage(
"Aborting sdp-obbt, as we were unable to solve a probing sdp!\n");
353 if ( *result != SCIP_REDUCEDDOM )
354 *result = SCIP_DIDNOTRUN;
361 SCIPdebugMessage(
"Probing sdp infeasible, so there can't be a better solution for this problem!\n");
362 *result = SCIP_CUTOFF;
370 if ( SCIPisLT(scip, -probingval, SCIPvarGetUbLocal(vars[v])) )
373 SCIPdebugMessage(
"Obbt-Sdp tightened upper bound of variable %s from %f to %f !\n",
374 SCIPvarGetName(vars[v]), SCIPvarGetUbLocal(vars[v]), -probingval);
376 newbounds[nnewbounds] = -probingval;
377 newboundinds[nnewbounds] = v + 1;
379 *result = SCIP_REDUCEDDOM;
381 #ifdef SCIP_MORE_DEBUG
384 SCIPdebugMessage(
"Obbt-Sdp found upper bound of %f for variable %s, worse than old bound %f !\n",
385 -probingval, SCIPvarGetName(vars[v]), SCIPvarGetUbLocal(vars[v]));
389 #ifdef SCIP_MORE_DEBUG
392 SCIPdebugMessage(
"Skipping obbt for upper bound %f of variable %s, as current relaxation's solution is tight.\n",
393 SCIPvarGetUbLocal(vars[v]), SCIPvarGetName(vars[v]));
398 SCIP_CALL( SCIPchgVarObjProbing(scip, vars[v], 0.0) );
401 SCIP_CALL( SCIPendProbing(scip) );
402 SCIPdebugMessage(
"end probing\n");
403 SCIP_CALL( SCIPsetBoolParam(scip,
"relaxing/SDP/objlimit", oldobjlimitparam) );
405 for (i = 0; i < nnewbounds; i++)
407 if ( newboundinds[i] < 0)
409 SCIP_CALL( SCIPchgVarLb(scip, vars[-1 * newboundinds[i] - 1], newbounds[i]) );
413 SCIP_CALL( SCIPchgVarUb(scip, vars[newboundinds[i] - 1], newbounds[i]) );
417 SCIPfreeBufferArray(scip, &newbounds);
418 SCIPfreeBufferArray(scip, &newboundinds);
423 *result = SCIP_DIDNOTRUN;
440 SCIP_PROPDATA* propdata;
445 SCIP_CALL( SCIPallocMemory(scip, &propdata) );
446 propdata->lastnode = -1;
453 propExecSdpObbt, propdata) );
455 assert(prop != NULL);
458 SCIP_CALL( SCIPsetPropCopy(scip, prop, propCopySdpObbt) );
459 SCIP_CALL( SCIPsetPropFree(scip, prop, propFreeSdpObbt) );
460 SCIP_CALL( SCIPsetPropExit(scip, prop, propExitSdpObbt) );
463 SCIP_CALL( SCIPaddBoolParam(scip,
"propagating/" PROP_NAME "/propbin",
464 "Should optimization-based bound tightening be performed for binary variables?",
467 SCIP_CALL( SCIPaddBoolParam(scip,
"propagating/" PROP_NAME "/propcont",
468 "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_PROPFREE(propFreeSdpObbt)
SCIP_Bool SCIPrelaxSdpSolvedProbing(SCIP_RELAX *relax)
SCIP_Bool SCIPrelaxSdpIsFeasible(SCIP_RELAX *relax)