Scippy

UG

Ubiquity Generator framework

scipParaCommMpi.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and software framework */
4 /* UG --- Ubquity Generator Framework */
5 /* */
6 /* Copyright Written by Yuji Shinano <shinano@zib.de>, */
7 /* Copyright (C) 2021 by Zuse Institute Berlin, */
8 /* licensed under LGPL version 3 or later. */
9 /* Commercial licenses are available through <licenses@zib.de> */
10 /* */
11 /* This code is free software; you can redistribute it and/or */
12 /* modify it under the terms of the GNU Lesser General Public License */
13 /* as published by the Free Software Foundation; either version 3 */
14 /* of the License, or (at your option) any later version. */
15 /* */
16 /* This program is distributed in the hope that it will be useful, */
17 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
19 /* GNU Lesser General Public License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public License */
22 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 /* */
24 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
25 
26 /**@file scipParaCommMpi.cpp
27  * @brief SCIP ParaComm extension for MPI communication.
28  * @author Yuji Shinano
29  *
30  *
31  *
32  */
33 
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35 
36 
37 #include "scipParaCommMpi.h"
38 #include "scipParaInstanceMpi.h"
40 #include "scipParaSolutionMpi.h"
41 #include "scipParaInitialStatMpi.h"
43 #include "scipDiffParamSetMpi.h"
44 #include "scipParaParamSet.h"
45 
46 using namespace ParaSCIP;
47 
48 
49 const char *
51  TAG_STR(TagInitialStat1),
52  TAG_STR(TagSolverDiffParamSet1),
53  TAG_STR(TagDiffSubproblem1),
54  TAG_STR(TagDiffSubproblem2),
55  TAG_STR(TagDiffSubproblem3),
56  TAG_STR(TagDiffSubproblem4),
57  TAG_STR(TagDiffSubproblem5),
58  TAG_STR(TagDiffSubproblem6),
59  TAG_STR(TagDiffSubproblem7),
60  TAG_STR(TagDiffSubproblem8),
61  TAG_STR(TagDiffSubproblem9),
62  TAG_STR(TagDiffSubproblem10),
63  TAG_STR(TagDiffSubproblem11),
64  TAG_STR(TagDiffSubproblem12),
65  TAG_STR(TagDiffSubproblem13),
66  TAG_STR(TagDiffSubproblem14),
67  TAG_STR(TagSolution1)
68 };
69 
70 bool
72  )
73 {
74  return ( sizeof(tagStringTable)/sizeof(char*) == (N_SCIP_MPI_TAGS - UG::N_BB_MPI_TAGS) );
75 }
76 
77 const char *
79  int tag /// tag to be converted to string
80  )
81 {
82  assert( tag >= 0 && tag < N_SCIP_MPI_TAGS );
83  if( tag >= 0 && tag < TAG_SCIP_FIRST )
84  {
85  return BbParaCommMpi::getTagString(tag);
86  }
87  else
88  {
89  return tagStringTable[(tag - TAG_SCIP_FIRST)];
90  }
91 }
92 
93 /*******************************************************************************
94 * transfer object factory
95 *******************************************************************************/
98  )
99 {
100  return new ScipParaDiffSubproblemMpi();
101 }
102 
105  )
106 {
107  return new ScipParaInitialStatMpi();
108 }
109 
112  )
113 {
114  return new ScipParaRacingRampUpParamSetMpi();
115 }
116 
119  )
120 {
121  return new ScipParaInstanceMpi();
122 }
123 
126  )
127 {
128  return new ScipParaSolutionMpi();
129 }
130 
133  SCIP *scip,
134  int method
135  )
136 {
137  return new ScipParaInstanceMpi(scip, method);
138 }
139 
142  ScipParaSolver *solver,
143  SCIP_Real objval,
144  int inNvars,
145  SCIP_VAR ** vars,
146  SCIP_Real *vals
147  )
148 {
149  return new ScipParaSolutionMpi(solver, objval, inNvars, vars, vals);
150 }
151 
154  )
155 {
156  return new ScipParaParamSet();
157 }
158 
161  SCIP_Real objval,
162  int inNvars,
163  int *inIndicesAmongSolvers,
164  SCIP_Real *vals
165  )
166 {
167  return new ScipParaSolutionMpi(objval, inNvars, inIndicesAmongSolvers, vals);
168 }
169 
172  SCIP *scip,
173  ScipParaSolver *scipParaSolver,
174  int nNewBranchVars,
175  SCIP_VAR **newBranchVars,
176  SCIP_Real *newBranchBounds,
177  SCIP_BOUNDTYPE *newBoundTypes,
178  int nAddedConss,
179  SCIP_CONS **addedConss
180  )
181 {
182  return new ScipParaDiffSubproblemMpi(
183  scip,
184  scipParaSolver,
185  nNewBranchVars,
186  newBranchVars,
187  newBranchBounds,
188  newBoundTypes,
189  nAddedConss,
190  addedConss
191  );
192 }
193 
196  SCIP *scip
197  )
198 {
199  return new ScipParaInitialStatMpi(
200  scip
201  );
202 }
203 
206  int inMaxDepth,
207  int inMaxTotalDepth,
208  int inNVarBranchStatsDown,
209  int inNVarBranchStatsUp,
210  int *inIdxLBranchStatsVarsDown,
211  int *inNVarBranchingDown,
212  int *inIdxLBranchStatsVarsUp,
213  int *inNVarBranchingUp,
214  SCIP_Real *inDownpscost,
215  SCIP_Real *inDownvsids,
216  SCIP_Real *inDownconflen,
217  SCIP_Real *inDowninfer,
218  SCIP_Real *inDowncutoff,
219  SCIP_Real *inUppscost,
220  SCIP_Real *inUpvsids,
221  SCIP_Real *inUpconflen,
222  SCIP_Real *inUpinfer,
223  SCIP_Real *inUpcutoff
224  )
225 {
226  return new ScipParaInitialStatMpi(
227  inMaxDepth,
228  inMaxTotalDepth,
229  inNVarBranchStatsDown,
230  inNVarBranchStatsUp,
231  inIdxLBranchStatsVarsDown,
232  inNVarBranchingDown,
233  inIdxLBranchStatsVarsUp,
234  inNVarBranchingUp,
235  inDownpscost,
236  inDownvsids,
237  inDownconflen,
238  inDowninfer,
239  inDowncutoff,
240  inUppscost,
241  inUpvsids,
242  inUpconflen,
243  inUpinfer,
244  inUpcutoff
245  );
246 }
247 
250  int inTerminationCriteria,
251  int inNNodesLeft,
252  double inTimeLimit,
253  int inScipRacingParamSeed,
254  int inPermuteProbSeed,
255  int inGenerateBranchOrderSeed,
256  ScipDiffParamSet *inScipDiffParamSet
257  )
258 {
260  inTerminationCriteria,
261  inNNodesLeft,
262  inTimeLimit,
263  inScipRacingParamSeed,
264  inPermuteProbSeed,
265  inGenerateBranchOrderSeed,
266  inScipDiffParamSet
267  );
268 }
269 
272 {
273  return new ScipDiffParamSetMpi();
274 }
275 
278  SCIP *scip
279  )
280 {
281  return new ScipDiffParamSetMpi(scip);
282 }
283 
ScipParaInstance extension for MPI communication.
UG::ParaInstance * createParaInstance()
static const char * tagStringTable[]
tag name string table
UG::ParaDiffSubproblem * createParaDiffSubproblem()
ScipParaInitialStat * createScipParaInitialStat(SCIP *scip)
const char * getTagString(int tag)
get Tag string for debugging
SCIP ParaComm extension for MPI communication.
ScipParaInstance * createScipParaInstance(SCIP *scip, int method)
ScipParaSolution extension for MPI communication.
class BbParaParamSet
ScipParaRacingRampUpParamSet * createScipParaRacingRampUpParamSet(int inTerminationCriteria, int inNNodesLeft, double inTimeLimit, int inScipRacingParamSeed, int inPermuteProbSeed, int inGenerateBranchOrderSeed, ScipDiffParamSet *inScipDiffParamSet)
const char * getTagString(int tag)
get Tag string for debugging
ScipParaRacingRampUpParamSet extension for MPI communication.
ScipParaSolution * createScipParaSolution(ScipParaSolver *solver, SCIP_Real objval, int inNvars, SCIP_VAR **vars, SCIP_Real *vals)
bool tagStringTableIsSetUpCoorectly()
check if tag string table (for debugging) set up correctly
ScipDiffParamSet * createScipDiffParamSet()
UG::ParaRacingRampUpParamSet * createParaRacingRampUpParamSet()
class ParaParamSet
Definition: paraParamSet.h:850
class for instance data
Definition: paraInstance.h:50
Class for the difference between instance and subproblem.
ScipParaDiffSubproblem extension for MPI communication.
UG::ParaParamSet * createParaParamSet()
ScipParaInitialStat extension for MPI communication.
ScipParaDiffSubproblem * createScipParaDiffSubproblem(SCIP *scip, ScipParaSolver *scipParaSolver, int nNewBranchVars, SCIP_VAR **newBranchVars, SCIP_Real *newBranchBounds, SCIP_BOUNDTYPE *newBoundTypes, int nAddedConss, SCIP_CONS **addedConss)
class for initial statistics collecting after racing
#define TAG_STR(tag)
Definition: paraTagDef.h:40
static const int TAG_SCIP_FIRST
UG::ParaSolution * createParaSolution()
UG::ParaInitialStat * createParaInitialStat()
class ParaRacingRampUpParamSet (parameter set for racing ramp-up)
class for solution
Definition: paraSolution.h:53
ScipDiffParamSet extension for MPI communication.