Scippy

UG

Ubiquity Generator framework

bbParaCommPth.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 paraCommPth.cpp
27  * @brief ParaComm extension for Pthreads 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 "bbParaCommPth.h"
43 
44 using namespace UG;
45 
46 const char *
81 };
82 
83 bool
85  )
86 {
88  // std::cout << "size = " << sizeof(tagStringTable)/sizeof(char*)
89  // << ", (N_BB_TH_TAGS - N_TH_TAGS) = " << (N_BB_TH_TAGS - N_TH_TAGS) << std::endl;
90  return ( sizeof(tagStringTable)/sizeof(char*) == (N_BB_TH_TAGS - N_TH_TAGS) );
91 }
92 
93 const char *
95  int tag /// tag to be converted to string
96  )
97 {
98  assert( tag >= 0 && tag < N_BB_TH_TAGS );
99  if( tag >= 0 && tag < TAG_BB_FIRST )
100  {
101  return ParaCommPth::getTagString(tag);
102  }
103  else
104  {
105  return tagStringTable[(tag - TAG_BB_FIRST)];
106  }
107 }
108 
111  )
112 {
113  return new BbParaCalculationStateTh();
114 }
115 
118  double compTime, ///< computation time of this ParaNode
119  double rootTime, ///< computation time of the root node
120  int nSolved, ///< the number of nodes solved
121  int nSent, ///< the number of ParaNodes sent
122  int nImprovedIncumbent, ///< the number of improved solution generated in this ParaSolver
123  int terminationState, ///< indicate whether if this computation is terminationState or not. 0: no, 1: terminationState
124  int nSolvedWithNoPreprocesses, ///< number of nodes solved when it is solved with no preprocesses
125  int nSimplexIterRoot, ///< number of simplex iteration at root node
126  double averageSimplexIter, ///< average number of simplex iteration except root node
127  int nTransferredLocalCuts, ///< number of local cuts transferred from a ParaNode
128  int minTransferredLocalCuts, ///< minimum number of local cuts transferred from a ParaNode
129  int maxTransferredLocalCuts, ///< maximum number of local cuts transferred from a ParaNode
130  int nTransferredBendersCuts, ///< number of benders cuts transferred from a ParaNode
131  int minTransferredBendersCuts, ///< minimum number of benders cuts transferred from a ParaNode
132  int maxTransferredBendersCuts, ///< maximum number of benders cuts transferred from a ParaNode
133  int nRestarts, ///< number of restarts
134  double minIisum, ///< minimum sum of integer infeasibility
135  double maxIisum, ///< maximum sum of integer infeasibility
136  int minNii, ///< minimum number of integer infeasibility
137  int maxNii, ///< maximum number of integer infeasibility
138  double dualBound, ///< final dual bound value
139  int nSelfSplitNodesLeft ///< number of self-split nodes left
140  )
141 {
142  return new BbParaCalculationStateTh(
143  compTime,
144  rootTime,
145  nSolved,
146  nSent,
147  nImprovedIncumbent,
148  terminationState,
149  nSolvedWithNoPreprocesses,
150  nSimplexIterRoot,
151  averageSimplexIter,
152  nTransferredLocalCuts,
153  minTransferredLocalCuts,
154  maxTransferredLocalCuts,
155  nTransferredBendersCuts,
156  minTransferredBendersCuts,
157  maxTransferredBendersCuts,
158  nRestarts,
159  minIisum,
160  maxIisum,
161  minNii,
162  maxNii,
163  dualBound,
164  nSelfSplitNodesLeft
165  );
166 }
167 
168 ParaTask *
170  )
171 {
172  return new BbParaNodeTh();
173 }
174 
175 ParaTask *
177  TaskId inNodeId,
178  TaskId inGeneratorNodeId,
179  int inDepth,
180  double inDualBoundValue,
181  double inOriginalDualBoundValue,
182  double inEstimatedValue,
183  ParaDiffSubproblem *inDiffSubproblem
184  )
185 {
186  return new BbParaNodeTh(
187  inNodeId,
188  inGeneratorNodeId,
189  inDepth,
190  inDualBoundValue,
191  inOriginalDualBoundValue,
192  inEstimatedValue,
193  inDiffSubproblem
194  );
195 }
196 
199  )
200 {
201  return new BbParaSolverStateTh();
202 }
203 
206  int racingStage,
207  unsigned int notificationId,
208  int lcId,
209  int globalSubtreeId,
210  long long nodesSolved,
211  int nodesLeft,
212  double bestDualBoundValue,
213  double globalBestPrimalBoundValue,
214  double detTime,
215  double averageDualBoundGain
216  )
217 {
218  return new BbParaSolverStateTh(
219  racingStage,
220  notificationId,
221  lcId,
222  globalSubtreeId,
223  nodesSolved,
224  nodesLeft,
225  bestDualBoundValue,
226  globalBestPrimalBoundValue,
227  detTime,
228  averageDualBoundGain
229  );
230 }
231 
234  )
235 {
236  return new BbParaSolverTerminationStateTh();
237 }
238 
241  int interrupted, ///< indicate that this solver is interrupted or not. 0: not interrupted, 1: interrputed
242  ///< 2: checkpoint, 3: racing-ramp up
243  int rank, ///< rankLocal of this solver
244  int totalNSolved, ///< accumulated number of nodes solved in this ParaSolver
245  int minNSolved, ///< minimum number of subtree nodes rooted from ParaNode
246  int maxNSolved, ///< maximum number of subtree nodes rooted from ParaNode
247  int totalNSent, ///< accumulated number of nodes sent from this ParaSolver
248  int totalNImprovedIncumbent, ///< accumulated number of improvements of incumbent value in this ParaSolver
249  int nParaNodesReceived, ///< number of ParaNodes received in this ParaSolver
250  int nParaNodesSolved, ///< number of ParaNodes solved ( received ) in this ParaSolver
251  int nParaNodesSolvedAtRoot, ///< number of ParaNodes solved at root node before sending
252  int nParaNodesSolvedAtPreCheck, ///< number of ParaNodes solved at pre-checking of root node solvability
253  int nTransferredLocalCutsFromSolver, ///< number of local cuts transferred from this Solver
254  int minTransferredLocalCutsFromSolver, ///< minimum number of local cuts transferred from this Solver
255  int maxTransferredLocalCutsFromSolver, ///< maximum number of local cuts transferred from this Solver
256  int nTransferredBendersCutsFromSolver, ///< number of benders cuts transferred from this Solver
257  int minTransferredBendersCutsFromSolver, ///< minimum number of benders cuts transferred from this Solver
258  int maxTransferredBendersCutsFromSolver, ///< maximum number of benders cuts transferred from this Solver
259  int nTotalRestarts, ///< number of total restarts
260  int minRestarts, ///< minimum number of restarts
261  int maxRestarts, ///< maximum number of restarts
262  int nTightened, ///< number of tightened variable bounds during racing stage
263  int nTightenedInt, ///< number of tightened integral variable bounds during racing stage
264  int calcTerminationState, ///< termination sate of a calculation in a Solver
265  double runningTime, ///< this solver running time
266  double idleTimeToFirstParaNode, ///< idle time to start solving the first ParaNode
267  double idleTimeBetweenParaNodes, ///< idle time between ParaNodes processing
268  double iddleTimeAfterLastParaNode, ///< idle time after the last ParaNode was solved
269  double idleTimeToWaitNotificationId, ///< idle time to wait notification Id messages
270  double idleTimeToWaitAckCompletion, ///< idle time to wait ack completion message
271  double idleTimeToWaitToken, ///< idle time to wait token
272  double totalRootNodeTime, ///< total time consumed by root node processes
273  double minRootNodeTime, ///< minimum time consumed by root node processes
274  double maxRootNodeTime, ///< maximum time consumed by root node processes
275  double detTime ///< deterministic time, -1: should be non-deterministic
276  )
277 {
279  interrupted,
280  rank,
281  totalNSolved,
282  minNSolved,
283  maxNSolved,
284  totalNSent,
285  totalNImprovedIncumbent,
286  nParaNodesReceived,
287  nParaNodesSolved,
288  nParaNodesSolvedAtRoot,
289  nParaNodesSolvedAtPreCheck,
290  nTransferredLocalCutsFromSolver,
291  minTransferredLocalCutsFromSolver,
292  maxTransferredLocalCutsFromSolver,
293  nTransferredBendersCutsFromSolver,
294  minTransferredBendersCutsFromSolver,
295  maxTransferredBendersCutsFromSolver,
296  nTotalRestarts,
297  minRestarts,
298  maxRestarts,
299  nTightened,
300  nTightenedInt,
301  calcTerminationState,
302  runningTime,
303  idleTimeToFirstParaNode,
304  idleTimeBetweenParaNodes,
305  iddleTimeAfterLastParaNode,
306  idleTimeToWaitNotificationId,
307  idleTimeToWaitAckCompletion,
308  idleTimeToWaitToken,
309  totalRootNodeTime,
310  minRootNodeTime,
311  maxRootNodeTime,
312  detTime
313  );
314 }
class ParaSolverState (ParaSolver state object for notification message)
static const int TagReassignSelfSplitSubtreeRootNode
Definition: bbParaTagDef.h:75
static const int TagNewSubtreeRootNode
Definition: bbParaTagDef.h:72
static const int TagCutOffValue
Definition: bbParaTagDef.h:66
virtual bool tagStringTableIsSetUpCoorectly()
check if tag string table (for debugging) set up correctly
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 const char * getTagString(int tag)
get Tag string for debugging
static const int TagLCBestBoundValue
Definition: bbParaTagDef.h:53
Base class of Calculation state in a ParaSolver.
virtual ParaTask * createParaTask()
create ParaNode object by default constructor
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)
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.
virtual ParaSolverState * createParaSolverState()
create ParaSolverState object by default constructor
virtual bool tagStringTableIsSetUpCoorectly()
check if tag string table (for debugging) set up correctly
static const int TagTerminateSolvingToRestart
Definition: bbParaTagDef.h:70
Calculation state object for thread communications.
virtual ParaCalculationState * createParaCalculationState()
create ParaCalculationState object by default constructor
virtual ParaSolverTerminationState * createParaSolverTerminationState()
create ParaSolverTerminationState object by default constructor
static const int TagSelfSplitTermStateForInterruption
Definition: bbParaTagDef.h:78
static const char * tagStringTable[]
tag name string table
Definition: bbParaCommPth.h:83
static const int TagNoNodes
Definition: bbParaTagDef.h:49
#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
virtual const char * getTagString(int tag)
get Tag string for debugging
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