33 #ifndef __SCIP_PARA_OBJPROP_H__ 34 #define __SCIP_PARA_OBJPROP_H__ 40 #include "objscip/objprop.h" 42 #ifdef UG_DEBUG_SOLUTION 43 #ifndef WITH_DEBUG_SOLUTION 44 #define WITH_DEBUG_SOLUTION 46 #include "scip/debug.h" 79 ) : scip::ObjProp::ObjProp(
82 "Propagator for updating variable bounds",
86 SCIP_PROPTIMING_ALWAYS,
89 SCIP_PRESOLTIMING_FAST
91 , solver(inSolver), ntotaltightened(0), ntotaltightenedint(0)
98 std::list<BoundChange *>::iterator it = boundChanges.begin();
99 while( it != boundChanges.end() )
102 it = boundChanges.erase(it);
111 SCIP_RETCODE
applyBoundChanges(SCIP *scip,
int& ntightened,
int& ntightenedint, SCIP_RESULT *result )
117 *result = SCIP_DIDNOTFIND;
119 std::list<BoundChange *>::iterator it = boundChanges.begin();
120 while( it != boundChanges.end() )
123 SCIP_Var **orgVars = SCIPgetOrigVars(scip);
124 SCIP_Var *var = SCIPvarGetTransVar(orgVars[bc->
index]);
125 if ( *result != SCIP_CUTOFF && var && SCIPvarGetStatus(var) != SCIP_VARSTATUS_FIXED && SCIPvarGetStatus(var) != SCIP_VARSTATUS_MULTAGGR && SCIPvarGetStatus(var) != SCIP_VARSTATUS_AGGREGATED )
127 if( SCIPvarGetStatus(var) == SCIP_VARSTATUS_NEGATED )
129 SCIP_Var *varNeg = 0;
130 SCIP_CALL_ABORT ( SCIPgetNegatedVar(scip, var, &varNeg) );
131 if( SCIPvarIsActive(varNeg) )
133 #ifdef UG_DEBUG_SOLUTION 134 SCIP_Real solvalue = 0.0;
135 SCIP_CALL(SCIPdebugGetSolVal(scip,orgVars[bc->
index], &solvalue));
136 std::cout <<
"Receiver side SolValue: " << SCIPvarGetName(orgVars[bc->
index]) <<
" = " << solvalue << std::endl;
137 if( bc->
boundType == SCIP_BOUNDTYPE_LOWER )
139 std::cout <<
"Receiver side (SCIP_BOUNDTYPE_LOWER): " << SCIPvarGetName(orgVars[bc->
index]) <<
" = " << bc->
bound << std::endl;
140 SCIP_CALL_ABORT( SCIPdebugCheckLbGlobal(scip,orgVars[bc->
index],bc->
bound) );
144 std::cout <<
"Receiver side (SCIP_BOUNDTYPE_UPPER): " << SCIPvarGetName(orgVars[bc->
index]) <<
" = " << bc->
bound << std::endl;
145 SCIP_CALL_ABORT( SCIPdebugCheckUbGlobal(scip,orgVars[bc->
index],bc->
bound) );
148 SCIP_CALL( tryToTightenBound(scip, bc->
boundType, orgVars[bc->
index], bc->
bound, result, ntightened, ntightenedint ) );
153 #ifdef UG_DEBUG_SOLUTION 154 SCIP_Real solvalue = 0.0;
155 SCIP_CALL(SCIPdebugGetSolVal(scip,orgVars[bc->
index], &solvalue));
156 std::cout <<
"Receiver side SolValue: " << SCIPvarGetName(orgVars[bc->
index]) <<
" = " << solvalue << std::endl;
157 if( bc->
boundType == SCIP_BOUNDTYPE_LOWER )
159 std::cout <<
"Receiver side (SCIP_BOUNDTYPE_LOWER): " << SCIPvarGetName(orgVars[bc->
index]) <<
" = " << bc->
bound << std::endl;
160 SCIP_CALL_ABORT( SCIPdebugCheckLbGlobal(scip,orgVars[bc->
index],bc->
bound) );
164 std::cout <<
"Receiver side (SCIP_BOUNDTYPE_UPPER): " << SCIPvarGetName(orgVars[bc->
index]) <<
" = " << bc->
bound << std::endl;
165 SCIP_CALL_ABORT( SCIPdebugCheckUbGlobal(scip,orgVars[bc->
index],bc->
bound) );
168 SCIP_CALL( tryToTightenBound(scip, bc->
boundType, orgVars[bc->
index], bc->
bound, result, ntightened, ntightenedint ) );
171 it = boundChanges.erase(it);
186 *result = SCIP_DIDNOTRUN;
188 if( boundChanges.empty() || SCIPinProbing(scip) )
197 applyBoundChanges(scip, ntightened, ntightenedint, result);
201 *nchgbds += ntightened;
202 ntotaltightened += ntightened;
203 ntotaltightenedint += ntightenedint;
204 if( *result != SCIP_CUTOFF )
205 *result = SCIP_SUCCESS;
208 SCIPpropSetFreq(prop, -1);
221 *result = SCIP_DIDNOTRUN;
223 if( SCIPinProbing(scip) || SCIPinRepropagation(scip) )
232 applyBoundChanges(scip, ntightened, ntightenedint, result);
236 ntotaltightened += ntightened;
237 ntotaltightenedint += ntightenedint;
238 if( *result != SCIP_CUTOFF )
239 *result = SCIP_REDUCEDDOM;
242 SCIPpropSetFreq(prop, -1);
248 SCIP_Bool infeas, tightened;
249 if( boundType == SCIP_BOUNDTYPE_LOWER )
252 SCIP_CALL( SCIPtightenVarLbGlobal(scip, var, bound, FALSE, &infeas, &tightened) );
256 assert(boundType == SCIP_BOUNDTYPE_UPPER);
258 SCIP_CALL( SCIPtightenVarUbGlobal(scip, var, bound, FALSE, &infeas, &tightened) );
266 *result = SCIP_CUTOFF;
272 if( SCIPvarGetType(var) == SCIP_VARTYPE_BINARY
273 || SCIPvarGetType(var) == SCIP_VARTYPE_INTEGER )
285 boundChanges.push_back(bc);
286 SCIPsetIntParam(scip,
"propagating/ScipParaObjProp/freq", 1);
295 #endif // __SCIP_PARA_OBJPROP_H__ virtual SCIP_DECL_PROPPRESOL(scip_presol)
ScipParaObjProp(UG::ParaComm *comm, ScipParaSolver *inSolver)
static ScipParaCommTh * comm
C++ wrapper for propagators.
std::list< BoundChange * > boundChanges
SCIP_RETCODE tryToTightenBound(SCIP *scip, SCIP_BOUNDTYPE boundType, SCIP_VAR *var, SCIP_Real bound, SCIP_Result *result, int &ntightened, int &ntightenedint)
SCIP_RETCODE applyBoundChanges(SCIP *scip, int &ntightened, int &ntightenedint, SCIP_RESULT *result)
ParaSolver extension for SCIP: Parallelized solver implementation for SCIP.
Base class of communicator for UG Framework.
double getPendingIncumbentValue()
get pending incumbent value
void addBoundChange(SCIP *scip, SCIP_BOUNDTYPE boundType, int index, SCIP_Real bound)
virtual SCIP_DECL_PROPEXEC(scip_exec)
virtual ~ScipParaObjProp()
Base class of communicator object.