Scippy

UG

Ubiquity Generator framework

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