59 #define PROP_NAME "sdpredcost"
60 #define PROP_DESC "sdp reduced cost strengthening propagator"
61 #define PROP_TIMING SCIP_PROPTIMING_AFTERLPLOOP
62 #define PROP_PRIORITY +1000000
64 #define PROP_DELAY FALSE
65 #define DEFAULT_SDPRCBIN TRUE
66 #define DEFAULT_SDPRCINTCONT TRUE
78 SCIP_Bool forintconts;
91 SCIP_Real primallbval,
92 SCIP_Real primalubval,
93 SCIP_Real cutoffbound,
98 assert( scip != NULL );
99 assert( var != NULL );
100 assert( result != NULL );
103 if (SCIPvarGetLbLocal(var) > 0.5 || SCIPvarGetUbLocal(var) < 0.5)
105 *result = SCIP_DIDNOTRUN;
110 if ( SCIPisGT(scip, primallbval, cutoffbound - relaxval) )
112 SCIP_CALL( SCIPchgVarUb(scip, var, 0.0) );
113 SCIPdebugMessage(
"Variable %s fixed to zero by reduced cost fixing ! \n", SCIPvarGetName(var));
114 *result = SCIP_REDUCEDDOM;
117 if ( SCIPisGT(scip, primalubval, cutoffbound - relaxval) )
119 *result = SCIP_CUTOFF;
126 if ( SCIPisGT(scip, primalubval, cutoffbound - relaxval) )
128 SCIP_CALL( SCIPchgVarLb(scip, var, 1.0) );
129 SCIPdebugMessage(
"Variable %s fixed to one by reduced cost fixing ! \n", SCIPvarGetName(var));
130 *result = SCIP_REDUCEDDOM;
134 *result = SCIP_DIDNOTFIND;
153 SCIP_Real primallbval,
154 SCIP_Real primalubval,
155 SCIP_Real cutoffbound,
163 assert( scip != NULL );
164 assert( var != NULL );
165 assert( result != NULL );
167 *result = SCIP_DIDNOTFIND;
170 ub = SCIPisGT(scip, primallbval, 0.0) ? SCIPvarGetLbLocal(var) + (cutoffbound - relaxval) / primallbval : SCIPinfinity(scip);
171 lb = SCIPisGT(scip, primalubval, 0.0) ? SCIPvarGetUbLocal(var) - (cutoffbound - relaxval) / primalubval : -SCIPinfinity(scip);
174 if ( SCIPisInfinity(scip, ub) )
175 ub = SCIPinfinity(scip);
176 else if ( SCIPisInfinity(scip, -ub) )
177 ub = -SCIPinfinity(scip);
178 if ( SCIPisInfinity(scip, lb) )
179 lb = SCIPinfinity(scip);
180 else if ( SCIPisInfinity(scip, -lb) )
181 lb = -SCIPinfinity(scip);
185 if ( SCIPisFeasLT(scip, ub, lb) || SCIPisFeasLT(scip, ub, SCIPvarGetLbLocal(var)) || SCIPisFeasLT(scip, SCIPvarGetUbLocal(var), lb) )
187 SCIPdebugMessage(
"Infeasibility of current node detected by prop_sdpredcost! Updated bounds for variable %s: lb = %f > %f = ub !\n",
188 SCIPvarGetName(var), SCIPisFeasGT(scip, lb, SCIPvarGetLbLocal(var))? lb : SCIPvarGetLbLocal(var),
189 SCIPisFeasLT(scip, ub, SCIPvarGetLbLocal(var)) ? ub : SCIPvarGetUbLocal(var) );
190 *result = SCIP_CUTOFF;
195 if ( SCIPisFeasLT(scip, ub, SCIPvarGetUbLocal(var)) )
197 SCIPdebugMessage(
"Changing upper bound of variable %s from %f to %f because of prop_sdpredcost \n",
198 SCIPvarGetName(var), SCIPvarGetUbLocal(var), ub);
199 SCIP_CALL( SCIPchgVarUb(scip, var, ub) );
200 *result = SCIP_REDUCEDDOM;
204 if ( SCIPisFeasGT(scip, lb, SCIPvarGetLbLocal(var)) )
206 SCIPdebugMessage(
"Changing lower bound of variable %s from %f to %f because of prop_sdpredcost \n",
207 SCIPvarGetName(var), SCIPvarGetLbLocal(var), lb);
208 SCIP_CALL( SCIPchgVarLb(scip, var, lb) );
209 *result = SCIP_REDUCEDDOM;
223 SCIP_RESULT varresult;
224 SCIP_Real cutoffbound;
227 SCIP_PROPDATA* propdata;
230 SCIPdebugMessage(
"Calling propExecSdpredcost \n");
232 assert( scip != NULL );
233 assert( prop != NULL );
234 assert( result != NULL );
237 if( !SCIPallowObjProp(scip) )
240 if ( SCIPgetStage(scip) == SCIP_STAGE_PRESOLVING )
243 *result = SCIP_DIDNOTRUN;
247 relax = SCIPfindRelax(scip,
"SDP");
248 assert( relax != NULL );
253 SCIPdebugMessage(
"Stopped propExecRedcost because current SDP-relaxation doesn't belong to the node the propagator was called for!\n");
254 *result = SCIP_DIDNOTRUN;
261 SCIPdebugMessage(
"Stopped propExecRedcost because current SDP-relaxation was solved using a penalty formulation!\n");
262 *result = SCIP_DIDNOTRUN;
269 SCIPdebugMessage(
"Stopped propExecRedcost because SDP-relaxation wasn't properly solved!\n");
270 *result = SCIP_DIDNOTRUN;
274 propdata = SCIPpropGetData(prop);
275 assert( propdata != NULL );
277 *result = SCIP_DIDNOTFIND;
279 nvars = SCIPgetNVars(scip);
280 vars = SCIPgetVars(scip);
282 cutoffbound = SCIPgetCutoffbound(scip);
288 assert( length == nvars );
290 for (v = 0; v < nvars; v++)
292 if ( SCIPvarIsBinary(vars[v]) && propdata->forbins )
294 SCIP_CALL(
sdpRedcostFixingBinary(scip, vars[v], propdata->lbvarvals[v], propdata->ubvarvals[v], cutoffbound, relaxval, &varresult) );
296 if ( varresult == SCIP_REDUCEDDOM )
297 *result = SCIP_REDUCEDDOM;
299 else if ( (! SCIPvarIsBinary(vars[v])) && propdata->forintconts )
301 SCIP_CALL(
sdpRedcostFixingIntCont(scip, vars[v], propdata->lbvarvals[v], propdata->ubvarvals[v], cutoffbound, relaxval, &varresult) );
303 if ( varresult == SCIP_REDUCEDDOM )
304 *result = SCIP_REDUCEDDOM;
315 SCIP_PROPDATA* propdata;
317 propdata = SCIPpropGetData(prop);
318 assert( propdata != NULL );
319 SCIPfreeMemory(scip, &propdata);
321 SCIPpropSetData(prop, NULL);
330 SCIP_PROPDATA* propdata;
332 propdata = SCIPpropGetData(prop);
333 assert( propdata != NULL );
335 if ( propdata->lbvarvals != NULL )
337 SCIPfreeBlockMemoryArrayNull(scip, &(propdata->lbvarvals), propdata->nvars);
338 propdata->lbvarvals = NULL;
339 SCIPfreeBlockMemoryArrayNull(scip, &(propdata->ubvarvals), propdata->nvars);
340 propdata->ubvarvals = NULL;
350 SCIP_PROPDATA* propdata;
353 propdata = SCIPpropGetData(prop);
354 assert(propdata != NULL);
355 nvars = SCIPgetNVars(scip);
357 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(propdata->lbvarvals), nvars) );
358 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(propdata->ubvarvals), nvars) );
359 propdata->nvars = nvars;
368 assert( scip != NULL );
369 assert( prop != NULL );
370 assert( strcmp(SCIPpropGetName(prop),
PROP_NAME) == 0 );
383 SCIP_PROPDATA* propdata = NULL;
387 SCIP_CALL( SCIPallocMemory(scip, &propdata) );
389 propdata->lbvarvals = NULL;
390 propdata->ubvarvals = NULL;
394 propExecSdpredcost, propdata) );
395 assert( prop != NULL );
398 SCIP_CALL( SCIPsetPropCopy(scip, prop, propCopySdpredcost) );
399 SCIP_CALL( SCIPsetPropInitsol(scip, prop, propInitsolSdpredcost) );
400 SCIP_CALL( SCIPsetPropExit(scip, prop, propExitSdpredcost) );
401 SCIP_CALL( SCIPsetPropFree(scip, prop, propFreeSdpredcost) );
404 SCIP_CALL( SCIPaddBoolParam(scip,
"propagating/sdpredcost/forbins",
"Should SDP reduced cost fixing be executed for binary variables?",
406 SCIP_CALL( SCIPaddBoolParam(scip,
"propagating/sdpredcost/forintconts",
"Should SDP reduced cost fixing be executed for integer and continuous variables?",
static SCIP_DECL_PROPFREE(propFreeSdpredcost)
static SCIP_DECL_PROPINITSOL(propInitsolSdpredcost)
static SCIP_DECL_PROPEXIT(propExitSdpredcost)
SCIP_RETCODE SCIPrelaxSdpRelaxVal(SCIP_RELAX *relax, SCIP_Bool *success, SCIP_Real *objval)
General interface methods for SDP-preprocessing (mainly fixing variables and removing empty rows/cols...
static SCIP_DECL_PROPEXEC(propExecSdpredcost)
static SCIP_DECL_PROPCOPY(propCopySdpredcost)
long int SCIPrelaxSdpGetSdpNode(SCIP_RELAX *relax)
SCIP_Bool SCIPrelaxSdpSolvedOrig(SCIP_RELAX *relax)
SCIP_RETCODE SCIPrelaxSdpGetPrimalBoundVars(SCIP_RELAX *relax, SCIP_Real *lbvars, SCIP_Real *ubvars, int *arraylength)
reduced cost / dual fixing for SDPs
static SCIP_RETCODE sdpRedcostFixingIntCont(SCIP *scip, SCIP_VAR *var, SCIP_Real primallbval, SCIP_Real primalubval, SCIP_Real cutoffbound, SCIP_Real relaxval, SCIP_RESULT *result)
static SCIP_RETCODE sdpRedcostFixingBinary(SCIP *scip, SCIP_VAR *var, SCIP_Real primallbval, SCIP_Real primalubval, SCIP_Real cutoffbound, SCIP_Real relaxval, SCIP_RESULT *result)
SCIP_RETCODE SCIPincludePropSdpredcost(SCIP *scip)
#define DEFAULT_SDPRCINTCONT