Scippy

UG

Ubiquity Generator framework

bbParaCommMpi.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-2024 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 bbParaCommMpi.cpp
27 * @brief 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 "bbParaTagDef.h"
38#include "bbParaCommMpi.h"
39
40using namespace UG;
41
42MPI_Datatype
43BbParaCommMpi::datatypes[TYPE_LIST_SIZE];
44
45const char *
46BbParaCommMpi::tagStringTable[] = {
80};
81
82bool
83BbParaCommMpi::tagStringTableIsSetUpCoorectly(
84 )
85{
86 return ( sizeof(tagStringTable)/sizeof(char*) == (N_BB_MPI_TAGS - N_MPI_TAGS) );
87}
88
89const char *
91 int tag /// tag to be converted to string
92 )
93{
94 assert( tag >= 0 && tag < N_BB_MPI_TAGS );
95 if( tag >= 0 && tag < TAG_BB_FIRST )
96 {
97 return ParaCommMpi::getTagString(tag);
98 }
99 else
100 {
101 return tagStringTable[(tag - TAG_BB_FIRST)];
102 }
103}
104
107 )
108{
109 return new BbParaCalculationStateMpi();
110}
111
114 double compTime, ///< computation time of this ParaNode
115 double rootTime, ///< computation time of the root node
116 int nSolved, ///< the number of nodes solved
117 int nSent, ///< the number of ParaNodes sent
118 int nImprovedIncumbent, ///< the number of improved solution generated in this ParaSolver
119 int terminationState, ///< indicate whether if this computation is terminationState or not. 0: no, 1: terminationState
120 int nSolvedWithNoPreprocesses, ///< number of nodes solved when it is solved with no preprocesses
121 int nSimplexIterRoot, ///< number of simplex iteration at root node
122 double averageSimplexIter, ///< average number of simplex iteration except root node
123 int nTransferredLocalCuts, ///< number of local cuts transferred from a ParaNode
124 int minTransferredLocalCuts, ///< minimum number of local cuts transferred from a ParaNode
125 int maxTransferredLocalCuts, ///< maximum number of local cuts transferred from a ParaNode
126 int nTransferredBendersCuts, ///< number of benders cuts transferred from a ParaNode
127 int minTransferredBendersCuts, ///< minimum number of benders cuts transferred from a ParaNode
128 int maxTransferredBendersCuts, ///< maximum number of benders cuts transferred from a ParaNode
129 int nRestarts, ///< number of restarts
130 double minIisum, ///< minimum sum of integer infeasibility
131 double maxIisum, ///< maximum sum of integer infeasibility
132 int minNii, ///< minimum number of integer infeasibility
133 int maxNii, ///< maximum number of integer infeasibility
134 double dualBound, ///< final dual bound value
135 int nSelfSplitNodesLeft ///< number of self-split nodes left
136 )
137{
138 return new BbParaCalculationStateMpi(
139 compTime,
140 rootTime,
141 nSolved,
142 nSent,
143 nImprovedIncumbent,
144 terminationState,
145 nSolvedWithNoPreprocesses,
146 nSimplexIterRoot,
147 averageSimplexIter,
148 nTransferredLocalCuts,
149 minTransferredLocalCuts,
150 maxTransferredLocalCuts,
151 nTransferredBendersCuts,
152 minTransferredBendersCuts,
153 maxTransferredBendersCuts,
154 nRestarts,
155 minIisum,
156 maxIisum,
157 minNii,
158 maxNii,
159 dualBound,
160 nSelfSplitNodesLeft
161 );
162}
163
164ParaTask *
166 )
167{
168 return new BbParaNodeMpi();
169}
170
171ParaTask *
173 TaskId inNodeId,
174 TaskId inGeneratorNodeId,
175 int inDepth,
176 double inDualBoundValue,
177 double inOriginalDualBoundValue,
178 double inEstimatedValue,
179 ParaDiffSubproblem *inDiffSubproblem
180 )
181{
182 return new BbParaNodeMpi(
183 inNodeId,
184 inGeneratorNodeId,
185 inDepth,
186 inDualBoundValue,
187 inOriginalDualBoundValue,
188 inEstimatedValue,
189 inDiffSubproblem
190 );
191}
192
195 )
196{
197 return new BbParaSolverStateMpi();
198}
199
202 int racingStage,
203 unsigned int notificationId,
204 int lcId,
205 int globalSubtreeId,
206 long long nodesSolved,
207 int nodesLeft,
208 double bestDualBoundValue,
209 double globalBestPrimalBoundValue,
210 double detTime,
211 double averageDualBoundGain
212 )
213{
214 return new BbParaSolverStateMpi(
215 racingStage,
216 notificationId,
217 lcId,
218 globalSubtreeId,
219 nodesSolved,
220 nodesLeft,
221 bestDualBoundValue,
222 globalBestPrimalBoundValue,
223 detTime,
224 averageDualBoundGain
225 );
226}
227
228
231 )
232{
234}
235
238 int interrupted, ///< indicate that this solver is interrupted or not. 0: not interrupted, 1: interrupted
239 ///< 2: checkpoint, 3: racing-ramp up
240 int rank, ///< rank of this solver */
241 int totalNSolved, ///< accumulated number of nodes solved in this ParaSolver
242 int minNSolved, ///< minimum number of subtree nodes rooted from ParaNode
243 int maxNSolved, ///< maximum number of subtree nodes rooted from ParaNode
244 int totalNSent, ///< accumulated number of nodes sent from this ParaSolver
245 int totalNImprovedIncumbent, ///< accumulated number of improvements of incumbent value in this ParaSolver
246 int nParaNodesReceived, ///< number of ParaNodes received in this ParaSolver
247 int nParaNodesSolved, ///< number of ParaNodes solved ( received ) in this ParaSolver
248 int nParaNodesSolvedAtRoot, ///< number of ParaNodes solved at root node before sending
249 int nParaNodesSolvedAtPreCheck, ///< number of ParaNodes solved at pre-checking of root node solvability
250 int nTransferredLocalCutsFromSolver, ///< number of local cuts transferred from this Solver
251 int minTransferredLocalCutsFromSolver, ///< minimum number of local cuts transferred from this Solver
252 int maxTransferredLocalCutsFromSolver, ///< maximum number of local cuts transferred from this Solver
253 int nTransferredBendersCutsFromSolver, ///< number of benders cuts transferred from this Solver
254 int minTransferredBendersCutsFromSolver, ///< minimum number of benders cuts transferred from this Solver
255 int maxTransferredBendersCutsFromSolver, ///< maximum number of benders cuts transferred from this Solver
256 int nTotalRestarts, ///< number of total restarts
257 int minRestarts, ///< minimum number of restarts
258 int maxRestarts, ///< maximum number of restarts
259 int nTightened, ///< number of tightened variable bounds during racing stage
260 int nTightenedInt, ///< number of tightened integral variable bounds during racing stage
261 int calcTerminationState, ///< termination sate of a calculation in a Solver
262 double runningTime, ///< this solver running time
263 double idleTimeToFirstParaNode, ///< idle time to start solving the first ParaNode
264 double idleTimeBetweenParaNodes, ///< idle time between ParaNodes processing
265 double iddleTimeAfterLastParaNode, ///< idle time after the last ParaNode was solved
266 double idleTimeToWaitNotificationId, ///< idle time to wait notification Id messages
267 double idleTimeToWaitAckCompletion, ///< idle time to wait ack completion message
268 double idleTimeToWaitToken, ///< idle time to wait token
269 double totalRootNodeTime, ///< total time consumed by root node processes
270 double minRootNodeTime, ///< minimum time consumed by root node processes
271 double maxRootNodeTime, ///< maximum time consumed by root node processes
272 double detTime ///< deterministic time, -1: should be non-deterministic
273 )
274{
277 rank,
278 totalNSolved,
279 minNSolved,
280 maxNSolved,
281 totalNSent,
282 totalNImprovedIncumbent,
283 nParaNodesReceived,
284 nParaNodesSolved,
285 nParaNodesSolvedAtRoot,
286 nParaNodesSolvedAtPreCheck,
287 nTransferredLocalCutsFromSolver,
288 minTransferredLocalCutsFromSolver,
289 maxTransferredLocalCutsFromSolver,
290 nTransferredBendersCutsFromSolver,
291 minTransferredBendersCutsFromSolver,
292 maxTransferredBendersCutsFromSolver,
293 nTotalRestarts,
294 minRestarts,
295 maxRestarts,
296 nTightened,
297 nTightenedInt,
298 calcTerminationState,
299 runningTime,
300 idleTimeToFirstParaNode,
301 idleTimeBetweenParaNodes,
302 iddleTimeAfterLastParaNode,
303 idleTimeToWaitNotificationId,
304 idleTimeToWaitAckCompletion,
305 idleTimeToWaitToken,
306 totalRootNodeTime,
307 minRootNodeTime,
308 maxRootNodeTime,
309 detTime
310 );
311}
ParaComm extension for MPI communication.
ug_bb Tag definitions
Calculation state object for MPI communications.
virtual ParaCalculationState * createParaCalculationState()
create ParaCalculationState object by default constructor
virtual ParaSolverState * createParaSolverState()
create ParaSolverState object by default constructor
virtual ParaTask * createParaTask()
create ParaNode object by default constructor
virtual ParaSolverTerminationState * createParaSolverTerminationState()
create ParaSolverTerminationState object by default constructor
virtual ParaTask * createParaNode(TaskId inNodeId, TaskId inGeneratorNodeId, int inDepth, double inDualBoundValue, double inOriginalDualBoundValue, double inEstimatedValue, ParaDiffSubproblem *inDiffSubproblem)
create ParaNode object
virtual const char * getTagString(int tag)
get Tag string for debugging
static const char * tagStringTable[]
table for tag name string
Definition: bbParaCommMpi.h:80
class BbParaNodeMpi
Definition: bbParaNodeMpi.h:53
class BbParaSolverStateMpi (ParaSolver state object for notification message communicated by MPI)
class BbParaSolverTerminationStateMpi (Solver termination state in a ParaSolver communicated by MPI)
Base class of Calculation state in a ParaSolver.
virtual const char * getTagString(int tag)
get Tag string for debugging
Class for the difference between instance and subproblem.
class ParaSolverState (ParaSolver state object for notification message)
class ParaSolverTerminationState (Solver termination state in a ParaSolver)
class ParaTask
Definition: paraTask.h:542
TaskId class.
Definition: paraTask.h:223
static bool interrupted
Definition: fscip.cpp:78
static const int TagLCBestBoundValue
Definition: bbParaTagDef.h:53
static const int TagAnotherNodeRequest
Definition: bbParaTagDef.h:48
static const int TagCutOffValue
Definition: bbParaTagDef.h:66
static const int TagLbBoundTightenedBound
Definition: bbParaTagDef.h:63
static const int TagLightWeightRootNodeProcess
Definition: bbParaTagDef.h:54
static const int TagAllowToBeInCollectingMode
Definition: bbParaTagDef.h:57
static const int TagTerminateSolvingToRestart
Definition: bbParaTagDef.h:70
static const int TAG_BB_FIRST
Definition: bbParaTagDef.h:44
static const int TagSelfSplitFinished
Definition: bbParaTagDef.h:71
static const int N_MPI_TAGS
-1 : no tag
Definition: paraTagDef.h:73
static const int TagLbBoundTightenedIndex
Definition: bbParaTagDef.h:62
static const int TagCollectAllNodes
Definition: bbParaTagDef.h:51
static const int TagRestart
Definition: bbParaTagDef.h:61
static const int TagGivenGapIsReached
Definition: bbParaTagDef.h:56
static const int TagGlobalBestDualBoundValueAtWarmStart
Definition: bbParaTagDef.h:47
static const int TagUbBoundTightenedIndex
Definition: bbParaTagDef.h:64
static const int TagSubtreeRootNodeToBeRemoved
Definition: bbParaTagDef.h:74
static const int TagNoWaitModeSend
Definition: bbParaTagDef.h:60
static const int N_BB_MPI_TAGS
Definition: bbParaTagDef.h:89
static const int TagTermStateForInterruption
Definition: bbParaTagDef.h:77
static const int TagReassignSelfSplitSubtreeRootNode
Definition: bbParaTagDef.h:75
static const int TagChangeSearchStrategy
Definition: bbParaTagDef.h:67
static const int TagNoTestDualBoundGain
Definition: bbParaTagDef.h:59
static const int TYPE_LIST_SIZE
Definition: paraComm.h:81
static const int TagUbBoundTightenedBound
Definition: bbParaTagDef.h:65
static const int TagBreaking
Definition: bbParaTagDef.h:55
static const int TagSelfSplitTermStateForInterruption
Definition: bbParaTagDef.h:78
static const int TagRetryRampUp
Definition: bbParaTagDef.h:46
static const int TagKeepRacing
Definition: bbParaTagDef.h:69
static const int TagOutCollectingMode
Definition: bbParaTagDef.h:52
static const int TagSubtreeRootNodeStartComputation
Definition: bbParaTagDef.h:73
static const int TagInCollectingMode
Definition: bbParaTagDef.h:50
static const int TagSelfSlpitNodeCalcuationState
Definition: bbParaTagDef.h:76
static const int TagTestDualBoundGain
Definition: bbParaTagDef.h:58
static const int TagNoNodes
Definition: bbParaTagDef.h:49
static const int TagSolverDiffParamSet
Definition: bbParaTagDef.h:68
static const int TagNewSubtreeRootNode
Definition: bbParaTagDef.h:72
#define TAG_STR(tag)
Definition: paraTagDef.h:40