55 #define PROP_NAME "sdpredcost"
56 #define PROP_DESC "sdp reduced cost strengthening propagator"
57 #define PROP_TIMING (SCIP_PROPTIMING_DURINGLPLOOP | SCIP_PROPTIMING_AFTERLPLOOP)
58 #define PROP_PRIORITY +1000000
60 #define PROP_DELAY FALSE
61 #define DEFAULT_SDPRCBIN TRUE
62 #define DEFAULT_SDPRCINTCONT TRUE
74 SCIP_Bool forintconts;
87 SCIP_Real primallbval,
88 SCIP_Real primalubval,
89 SCIP_Real cutoffbound,
94 assert( scip != NULL );
95 assert( var != NULL );
96 assert( result != NULL );
99 if (SCIPvarGetLbLocal(var) > 0.5 || SCIPvarGetUbLocal(var) < 0.5)
101 *result = SCIP_DIDNOTRUN;
106 if ( SCIPisGT(scip, primallbval, cutoffbound - relaxval) )
108 SCIP_CALL( SCIPchgVarUb(scip, var, 0.0) );
109 SCIPdebugMessage(
"Variable %s fixed to zero by reduced cost fixing ! \n", SCIPvarGetName(var));
110 *result = SCIP_REDUCEDDOM;
113 if ( SCIPisGT(scip, primalubval, cutoffbound - relaxval) )
115 *result = SCIP_CUTOFF;
122 if ( SCIPisGT(scip, primalubval, cutoffbound - relaxval) )
124 SCIP_CALL( SCIPchgVarLb(scip, var, 1.0) );
125 SCIPdebugMessage(
"Variable %s fixed to one by reduced cost fixing ! \n", SCIPvarGetName(var));
126 *result = SCIP_REDUCEDDOM;
130 *result = SCIP_DIDNOTFIND;
149 SCIP_Real primallbval,
150 SCIP_Real primalubval,
151 SCIP_Real cutoffbound,
159 assert( scip != NULL );
160 assert( var != NULL );
161 assert( result != NULL );
163 *result = SCIP_DIDNOTFIND;
166 ub = SCIPisGT(scip, primallbval, 0.0) ? SCIPvarGetLbLocal(var) + (cutoffbound - relaxval) / primallbval : SCIPinfinity(scip);
167 lb = SCIPisGT(scip, primalubval, 0.0) ? SCIPvarGetUbLocal(var) - (cutoffbound - relaxval) / primalubval : -SCIPinfinity(scip);
170 if ( SCIPisInfinity(scip, ub) )
171 ub = SCIPinfinity(scip);
172 else if ( SCIPisInfinity(scip, -ub) )
173 ub = -SCIPinfinity(scip);
174 if ( SCIPisInfinity(scip, lb) )
175 lb = SCIPinfinity(scip);
176 else if ( SCIPisInfinity(scip, -lb) )
177 lb = -SCIPinfinity(scip);
181 if ( SCIPisLT(scip, ub, lb) || SCIPisLT(scip, ub, SCIPvarGetLbLocal(var)) || SCIPisLT(scip, SCIPvarGetUbLocal(var), lb) )
183 SCIPdebugMessage(
"Infeasibility of current node detected by prop_sdpredcost! Updated bounds for variable %s: lb = %f > %f = ub !\n",
184 SCIPvarGetName(var), SCIPisGT(scip, lb, SCIPvarGetLbLocal(var))? lb : SCIPvarGetLbLocal(var),
185 SCIPisLT(scip, ub, SCIPvarGetLbLocal(var)) ? ub : SCIPvarGetUbLocal(var) );
186 *result = SCIP_CUTOFF;
191 if ( SCIPisLT(scip, ub, SCIPvarGetUbLocal(var)) )
193 SCIPdebugMessage(
"Changing upper bound of variable %s from %f to %f because of prop_sdpredcost \n",
194 SCIPvarGetName(var), SCIPvarGetUbLocal(var), ub);
195 SCIP_CALL( SCIPchgVarUb(scip, var, ub) );
196 *result = SCIP_REDUCEDDOM;
200 if ( SCIPisGT(scip, lb, SCIPvarGetLbLocal(var)) )
202 SCIPdebugMessage(
"Changing lower bound of variable %s from %f to %f because of prop_sdpredcost \n",
203 SCIPvarGetName(var), SCIPvarGetLbLocal(var), lb);
204 SCIP_CALL( SCIPchgVarLb(scip, var, lb) );
205 *result = SCIP_REDUCEDDOM;
219 SCIP_RESULT varresult;
220 SCIP_Real cutoffbound;
223 SCIP_PROPDATA* propdata;
226 SCIPdebugMessage(
"Calling propExecSdpredcost \n");
228 assert( scip != NULL );
229 assert( prop != NULL );
230 assert( result != NULL );
232 if ( SCIPgetStage(scip) == SCIP_STAGE_PRESOLVING )
235 *result = SCIP_DIDNOTRUN;
239 relax = SCIPfindRelax(scip,
"SDP");
240 assert( relax != NULL );
245 SCIPdebugMessage(
"Stopped propExecRedcost because current SDP-relaxation doesn't belong to the node the propagator was called for!\n");
246 *result = SCIP_DIDNOTRUN;
253 SCIPdebugMessage(
"Stopped propExecRedcost because current SDP-relaxation was solved using a penalty formulation!\n");
254 *result = SCIP_DIDNOTRUN;
261 SCIPdebugMessage(
"Stopped propExecRedcost because SDP-relaxation wasn't properly solved!\n");
262 *result = SCIP_DIDNOTRUN;
266 propdata = SCIPpropGetData(prop);
267 assert( propdata != NULL );
269 *result = SCIP_DIDNOTFIND;
271 nvars = SCIPgetNVars(scip);
272 vars = SCIPgetVars(scip);
274 cutoffbound = SCIPgetCutoffbound(scip);
280 assert( length == nvars );
282 for (v = 0; v < nvars; v++)
284 if ( SCIPvarIsBinary(vars[v]) && propdata->forbins )
286 SCIP_CALL(
sdpRedcostFixingBinary(scip, vars[v], propdata->lbvarvals[v], propdata->ubvarvals[v], cutoffbound, relaxval, &varresult) );
288 if ( varresult == SCIP_REDUCEDDOM )
289 *result = SCIP_REDUCEDDOM;
291 else if ( (! SCIPvarIsBinary(vars[v])) && propdata->forintconts )
293 SCIP_CALL(
sdpRedcostFixingIntCont(scip, vars[v], propdata->lbvarvals[v], propdata->ubvarvals[v], cutoffbound, relaxval, &varresult) );
295 if ( varresult == SCIP_REDUCEDDOM )
296 *result = SCIP_REDUCEDDOM;
307 SCIP_PROPDATA* propdata;
309 propdata = SCIPpropGetData(prop);
310 assert( propdata != NULL );
312 if ( propdata->nvars > 0 )
314 SCIPfreeBlockMemoryArrayNull(scip, &(propdata->lbvarvals), propdata->nvars);
315 SCIPfreeBlockMemoryArrayNull(scip, &(propdata->ubvarvals), propdata->nvars);
318 SCIPfreeMemory(scip, &propdata);
320 SCIPpropSetData(prop, NULL);
329 SCIP_PROPDATA* propdata;
332 propdata = SCIPpropGetData(prop);
333 assert(propdata != NULL);
334 nvars = SCIPgetNVars(scip);
336 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(propdata->lbvarvals), nvars) );
337 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(propdata->ubvarvals), nvars) );
338 propdata->nvars = nvars;
347 assert( scip != NULL );
348 assert( prop != NULL );
349 assert( strcmp(SCIPpropGetName(prop),
PROP_NAME) == 0 );
362 SCIP_PROPDATA* propdata = NULL;
366 SCIP_CALL( SCIPallocMemory(scip, &propdata) );
371 propExecSdpredcost, propdata) );
372 assert( prop != NULL );
375 SCIP_CALL( SCIPsetPropCopy(scip, prop, propCopySdpredcost) );
376 SCIP_CALL( SCIPsetPropInitsol(scip, prop, propInitsolSdpredcost) );
377 SCIP_CALL( SCIPsetPropFree(scip, prop, propFreeSdpredcost) );
380 SCIP_CALL( SCIPaddBoolParam(scip,
"propagating/sdpredcost/forbins",
"Should SDP reduced cost fixing be executed for binary variables?",
382 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)
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