37 #ifndef __SCIP_PARA_INSTANCE_H__ 38 #define __SCIP_PARA_INSTANCE_H__ 40 #if defined(_COMM_MPI_WORLD) 44 #include "scip/scip.h" 55 SCIP *paraInstanceScip;
88 int *idxLinearConsNames;
89 SCIP_Real *linearLhss;
90 SCIP_Real *linearRhss;
92 SCIP_Real **linearCoefs;
93 int **idxLinearCoefsVars;
99 int *idxSetppcConsNames;
108 int *idxLogicorConsNames;
109 int *nIdxLogicorVars;
110 int **idxLogicorVars;
116 int *idxKnapsackConsNames;
117 SCIP_Longint *capacities;
118 int *nLKnapsackCoefs;
119 SCIP_Longint **knapsackCoefs;
120 int **idxKnapsackCoefsVars;
126 int *idxVarboundConsNames;
127 SCIP_Real *varboundLhss;
128 SCIP_Real *varboundRhss;
129 int *idxVarboundCoefVar1s;
130 SCIP_Real *varboundCoef2s;
131 int *idxVarboundCoefVar2s;
136 int nVarBoundDisjunctionConss;
137 int *idxBoundDisjunctionConsNames;
138 int *nVarsBoundDisjunction;
139 int **idxVarBoundDisjunction;
140 SCIP_BOUNDTYPE **boundTypesBoundDisjunction;
141 SCIP_Real **boundsBoundDisjunction;
147 int *idxSos1ConsNames;
149 SCIP_Real **sos1Coefs;
150 int **idxSos1CoefsVars;
156 int *idxSos2ConsNames;
158 SCIP_Real **sos2Coefs;
159 int **idxSos2CoefsVars;
164 int nAggregatedConss;
165 int lAggregatedVarNames;
166 char *aggregatedVarNames;
167 int *posAggregatedVarNames;
169 int lAggregatedConsNames;
170 char *aggregatedConsNames;
171 int *posAggregatedConsNames;
172 SCIP_Real *aggregatedLhsAndLhss;
173 int *nAggregatedCoefs;
174 SCIP_Real **aggregatedCoefs;
175 int **idxAggregatedCoefsVars;
177 ScipUserPlugins *userPlugins;
182 void allocateMemoryForOrdinaryConstraints();
183 void addOrdinaryConstraintName(
int c, SCIP_CONS *cons );
184 void setLinearConstraint( SCIP *
scip,
int c, SCIP_CONS *cons );
185 void createLinearConstraintsInSCIP( SCIP *
scip );
186 void setSetppcConstraint( SCIP *
scip,
int c, SCIP_CONS *cons );
187 void createSetppcConstraintsInSCIP( SCIP *
scip );
188 void setLogicorConstraint( SCIP *
scip,
int c, SCIP_CONS *cons );
189 void createLogicorConstraintsInSCIP( SCIP *
scip );
190 void setKnapsackConstraint( SCIP *
scip,
int c, SCIP_CONS *cons );
191 void createKnapsackConstraintsInSCIP( SCIP *
scip );
192 void setVarboundConstraint( SCIP *
scip,
int c, SCIP_CONS *cons );
193 void createVarboundConstraintsInSCIP( SCIP *
scip );
194 void setBoundDisjunctionConstraint( SCIP *
scip,
int c, SCIP_CONS *cons );
195 void createBoundDisjunctionConstraintInSCIP( SCIP *
scip );
196 void setSos1Constraint( SCIP *
scip,
int c, SCIP_CONS *cons, SCIP_CONS** consSOS1 );
197 void createSos1ConstraintsInSCIP( SCIP *
scip );
198 void setSos2Constraint( SCIP *
scip,
int c, SCIP_CONS *cons, SCIP_CONS** consSOS2 );
199 void createSos2ConstraintsInSCIP( SCIP *
scip );
200 void getActiveVariables( SCIP *
scip, SCIP_VAR **vars, SCIP_Real *scalars,
int *nvars,
201 SCIP_Real *constant, SCIP_Bool transformed );
202 void collectAggregatedVars(SCIP *
scip,
int nvars, SCIP_VAR** vars,
int* nAggregatedVars,
203 SCIP_VAR*** aggregatedVars, SCIP_HASHTABLE** varAggregated );
204 void setAggregatedConstraint(
207 const char* constName,
213 void setAggregatedConstrains(
217 SCIP_VAR** aggregatedVars
219 void createAggregatedVarsAndConstrainsInSCIP( SCIP *
scip );
221 bool addRootNodeCuts(SCIP *
scip, ScipDiffParamSet *scipDiffParamSetRoot);
225 ) : orgScip(0), paraInstanceScip(0), lProbName(0), probName(0), nCopies(0), origObjSense(0), objScale(0.0),
226 objOffset(0.0), nVars(0), varIndexRange(0),
227 varLbs(0), varUbs(0), objCoefs(0), varTypes(0), lVarNames(0), varNames(0),
228 posVarNames(0), mapToOriginalIndecies(0), mapToSolverLocalIndecies(0),
229 nConss(0), lConsNames(0), consNames(0),
230 posConsNames(0),copyIncreasedVariables(false),
231 nLinearConss(0), idxLinearConsNames(0), linearLhss(0),
232 linearRhss(0), nLinearCoefs(0), linearCoefs(0), idxLinearCoefsVars(0),
233 nSetppcConss(0), idxSetppcConsNames(0), nIdxSetppcVars(0), setppcTypes(0),
234 idxSetppcVars(0), nLogicorConss(0), idxLogicorConsNames(0), nIdxLogicorVars(0), idxLogicorVars(0),
235 nKnapsackConss(0), idxKnapsackConsNames(0), capacities(0), nLKnapsackCoefs(0),
236 knapsackCoefs(0), idxKnapsackCoefsVars(0),
237 nVarboundConss(0), idxVarboundConsNames(0), varboundLhss(0),varboundRhss(0), idxVarboundCoefVar1s(0),
238 varboundCoef2s(0), idxVarboundCoefVar2s(0),
239 nVarBoundDisjunctionConss(0),idxBoundDisjunctionConsNames(0),nVarsBoundDisjunction(0),
240 idxVarBoundDisjunction(0),boundTypesBoundDisjunction(0), boundsBoundDisjunction(0),
241 nSos1Conss(0),idxSos1ConsNames(0), nSos1Coefs(0), sos1Coefs(0), idxSos1CoefsVars(0),
242 nSos2Conss(0), idxSos2ConsNames(0), nSos2Coefs(0), sos2Coefs(0), idxSos2CoefsVars(0),
243 nAggregatedConss(0), lAggregatedVarNames(0), aggregatedVarNames(0), posAggregatedVarNames(0),
244 lAggregatedConsNames(0), aggregatedConsNames(0), posAggregatedConsNames(0),
245 aggregatedLhsAndLhss(0), nAggregatedCoefs(0), aggregatedCoefs(0), idxAggregatedCoefsVars(0),
278 return SCIPretransformObj(orgScip, SCIPretransformObj(paraInstanceScip, internalValue) );
282 return SCIPretransformObj(paraInstanceScip, internalValue);
291 return SCIPtransformObj(paraInstanceScip, SCIPtransformObj(orgScip, externalValue));
295 return SCIPtransformObj(paraInstanceScip, externalValue);
304 assert( mapToOriginalIndecies );
306 SCIP_CALL_ABORT( SCIPcreateSol(paraInstanceScip, &newsol, 0) );
307 SCIP_VAR **vars = SCIPgetVars(paraInstanceScip);
308 assert( SCIPgetNVars(paraInstanceScip) == sol->getNVars() );
310 for(
int i = 0; i < sol->getNVars(); i++ )
312 if( mapToOriginalIndecies[i] >= 0 )
315 if( sol->indexAmongSolvers(j) == mapToOriginalIndecies[i] )
317 SCIP_CALL_ABORT( SCIPsetSolVal(paraInstanceScip, newsol, vars[sol->indexAmongSolvers(j)], sol->getValues()[j]) );
336 SCIP_CALL_ABORT(SCIPgetSolVals(paraInstanceScip, newsol, SCIPgetNVars(paraInstanceScip), SCIPgetVars(paraInstanceScip), vals) );
338 SCIP_CALL_ABORT( SCIPaddSolFree(paraInstanceScip, &newsol, &success) );
345 bool noPreprocessingInLC,
346 bool usetRootNodeCuts,
347 ScipDiffParamSet *scipDiffParamSetRoot,
348 ScipDiffParamSet *scipDiffParamSet,
349 char *settingsNameLC,
363 assert(mapToOriginalIndecies);
364 return mapToOriginalIndecies[index];
373 SCIP_Real
getVarLb(
int i){
return varLbs[i]; }
374 SCIP_Real
getVarUb(
int i){
return varUbs[i]; }
375 SCIP_Real
getObjCoef(
int i){
return objCoefs[i]; }
377 const char*
getVarName(
int i){
return &varNames[posVarNames[i]]; }
385 return idxLinearCoefsVars[i][j];
389 return linearCoefs[i];
393 return const_cast<const char*
>(&consNames[posConsNames[i]]);
399 void setUserPlugins(ScipUserPlugins *inUi) { userPlugins = inUi; }
406 (*userPlugins)(inScip);
410 virtual void setFileName(
const char *fileName) = 0;
414 assert(mapToOriginalIndecies);
416 mapToOriginalIndecies = 0;
422 assert(mapToSolverLocalIndecies);
424 mapToSolverLocalIndecies = 0;
431 return paraInstanceScip;
449 #if defined(_COMM_PTH) 453 #endif // __SCIP_PARA_INSTANCE_H__ ScipParaInstance extension for MPI communication.
virtual void setFileName(const char *file)=0
SCIP_Real getLhsLinear(int i)
int getOrigProbIndex(int index)
virtual const char * getFileName()=0
const char * getConsName(int i)
bool copyIncreasedVariables
ParaSolution extension for SCIP solver.
void createProblem(SCIP *scip, int method, bool noPreprocessingInLC, bool usetRootNodeCuts, ScipDiffParamSet *scipDiffParamSetRoot, ScipDiffParamSet *scipDiffParamSet, char *settingsNameLC, char *isolname)
Defines for UG Framework.
void getSolValuesForOriginalProblem(ScipParaSolution *sol, SCIP_Real *vals)
SCIP_Real * getLinearCoefs(int i)
SCIP * getParaInstanceScip()
SCIP_Real getRhsLinear(int i)
bool isSolverLocalIndeciesMap()
SCIP_Real getVarLb(int i)
#define THROW_LOGICAL_ERROR1(msg1)
int getNVarsLinear(int i)
const char * getProbName()
SCIP parameter set to be transferred ( Only keep difference between default settings )...
int * mapToSolverLocalIndecies
void setUserPlugins(ScipUserPlugins *inUi)
void includeUserPlugins(SCIP *inScip)
ScipParaInstance extension for threads communication.
bool isOriginalIndeciesMap()
int * extractSolverLocalIndexMap()
virtual ~ScipParaInstance()
int * mapToOriginalIndecies
int * extractOrigProbIndexMap()
int getIdxLinearCoefVar(int i, int j)
bool isCopyIncreasedVariables()
const char * getVarName(int i)
const std::string toString()
void copyIncrasedVariables()
SCIP_Real getObjCoef(int i)
double convertToInternalValue(double externalValue)
SCIP_Real getVarUb(int i)
double convertToExternalValue(double internalValue)