37 #ifndef __SCIP_PARA_INSTANCE_MPI_H__ 38 #define __SCIP_PARA_INSTANCE_MPI_H__ 72 : dummyToKeepStartPos(0), fileName(0)
82 if( method == 2 && SCIPgetStage(scip) != SCIP_STAGE_SOLVED )
85 SCIP_Bool success = TRUE;
86 SCIP_CALL_ABORT( SCIPcreate(&tempScip) );
89 #if SCIP_VERSION == 211 && SCIP_SUBVERSION == 0 90 SCIP_CALL_ABORT( SCIPcopyPlugins(scip, tempScip, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
91 TRUE, TRUE, TRUE, TRUE, &success) );
93 #if SCIP_APIVERSION >= 100 94 #if SCIP_APIVERSION >= 101 95 SCIP_CALL_ABORT( SCIPcopyPlugins(scip, tempScip, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
96 TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, &success) );
98 SCIP_CALL_ABORT( SCIPcopyPlugins(scip, tempScip, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
99 TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, &success) );
101 #elif SCIP_APIVERSION >= 17 102 SCIP_CALL_ABORT( SCIPcopyPlugins(scip, tempScip, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
103 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, &success) );
105 SCIP_CALL_ABORT( SCIPcopyPlugins(scip, tempScip, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
106 TRUE, TRUE, TRUE, TRUE, FALSE, &success) );
109 SCIP_CALL_ABORT( SCIPcopyParamSettings(scip, tempScip) );
112 SCIP_HASHMAP* varmap = 0;
113 if( SCIPgetNVars(scip) > 0 )
115 SCIP_CALL_ABORT( SCIPhashmapCreate(&varmap, SCIPblkmem(tempScip), SCIPgetNVars(scip)) );
117 SCIP_HASHMAP* conssmap = 0;
118 if( SCIPgetNConss(scip) > 0 )
120 SCIP_CALL_ABORT( SCIPhashmapCreate(&conssmap, SCIPblkmem(tempScip), SCIPgetNConss(scip)) );
124 SCIP_CALL_ABORT( SCIPcopyProb(scip, tempScip, varmap, conssmap, TRUE,
"") );
128 if( SCIPgetNVars(scip) > 0 )
130 #if (SCIP_VERSION < 321 || ( SCIP_VERSION == 321 && SCIP_SUBVERSION < 2) ) 131 SCIP_CALL_ABORT( SCIPcopyVars(scip, tempScip, varmap, conssmap, TRUE) );
133 SCIP_CALL_ABORT( SCIPcopyVars(scip, tempScip, varmap, conssmap, NULL, NULL, 0, TRUE) );
136 if( SCIPgetNConss(scip) > 0 )
138 SCIP_CALL_ABORT( SCIPcopyConss(scip, tempScip, varmap, conssmap, TRUE, FALSE, &success) );
141 #if SCIP_APIVERSION > 39 147 SCIP_CALL_ABORT( SCIPcopyBenders(scip, tempScip, NULL, TRUE, &valid) );
153 if( SCIPgetNConss(scip) > 0 )
155 SCIPhashmapFree(&conssmap);
157 if( SCIPgetNVars(scip) > 0 )
159 SCIPhashmapFree(&varmap);
162 std::cerr <<
"Some constraint handler did not perform a valid copy. Cannot solve this instance." << std::endl;
166 nVars = SCIPgetNVars(scip);
168 int n = SCIPgetNVars(tempScip);
173 if( SCIPgetNConss(scip) > 0 )
175 SCIPhashmapFree(&conssmap);
177 if( SCIPgetNVars(scip) > 0 )
179 SCIPhashmapFree(&varmap);
182 paraInstanceScip =
scip;
184 std::cout <<
"** ParaScipInstance copy does not increase the number of variables. **" << std::endl;
189 std::cout <<
"** ParaScipInstance copy increased the number of variables. **" << std::endl;
228 nVars = SCIPgetNVars(paraInstanceScip);
229 SCIP_VAR **vars = SCIPgetVars(paraInstanceScip);
232 posVarNames =
new int[
nVars];
233 objCoefs =
new SCIP_Real[
nVars];
237 for(
int v = 0; v <
nVars; ++v)
239 posVarNames[v] = lVarNames;
240 objCoefs[v] = SCIPvarGetObj(vars[v]);
241 assert(SCIPvarGetProbindex(vars[v])!=-1);
242 assert(SCIPvarGetProbindex(vars[v]) == v);
243 lVarNames += strlen(SCIPvarGetName(vars[v])) + 1;
245 varNames =
new char[lVarNames];
246 varLbs =
new SCIP_Real[
nVars];
247 varUbs =
new SCIP_Real[
nVars];
248 varTypes =
new int[
nVars];
249 for(
int v = 0; v <
nVars; ++v )
251 SCIP_VAR *var = vars[v];
252 strcpy (&varNames[posVarNames[v]], SCIPvarGetName(var) );
253 varLbs[SCIPvarGetProbindex(var)] = SCIPvarGetLbLocal(var);
254 varUbs[SCIPvarGetProbindex(var)] = SCIPvarGetUbLocal(var);
255 varTypes[SCIPvarGetProbindex(var)] = SCIPvarGetType(var);
266 SCIPfree(¶InstanceScip);
288 fileName = inFileName;
312 #endif // __SCIP_PARA_INSTANCE_MPI_H__
MPI_Datatype createDatatype1()
void allocateMemoryForDatatype3()
MPI_Datatype createDatatype3(bool memAllocNecessary)
ParaInstance extenstion for SCIP solver.
static ScipParaCommTh * comm
bool copyIncreasedVariables
MPI_Datatype createDatatype2(bool memAllocNecessary)
void allocateMemoryForDatatype2()
int bcast(UG::ParaComm *comm, int rank, int method)
Defines for UG Framework.
void setFileName(const char *inFileName)
Base class of communicator for UG Framework.
bool isCopyIncreasedVariables()
ScipParaInstanceMpi * ScipParaInstanceMpiPtr
ScipParaInstanceMpi(SCIP *scip, int method)
const char * getFileName()
Base class of communicator object.
void copyIncrasedVariables()
void copyScipEnvironment(SCIP **scip)