Scippy

UG

Ubiquity Generator framework

bbParaCommCPP11.h
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.h
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 #ifndef __BB_PARA_COMM_CPP11_H__
38 #define __BB_PARA_COMM_CPP11_H__
39 
40 #include <stdexcept>
41 #include <iostream>
42 #include <ostream>
43 #include <fstream>
44 #include <sstream>
45 #include <string>
46 #include <iomanip>
47 #include <cassert>
48 #include "bbParaNodeTh.h"
50 #include "bbParaSolverStateTh.h"
52 #include "ug/paraCommCPP11.h"
53 
54 namespace UG
55 {
56 
57 ///
58 /// bb user defined transfer data types
59 ///
60 static const int BB_USER_TYPE_FIRST = UG_USER_TYPE_LAST + 1;
61 static const int ParaSolverDiffParamType = BB_USER_TYPE_FIRST + 0;
62 static const int BB_USER_TYPE_LAST = BB_USER_TYPE_FIRST + 0;
63 
65 class BbParaParamSet;
66 class BbParaSolverState;
68 class BbParaInstance;
70 class BbParaSolution;
71 class BbParaInitialStat;
73 class BbParaNode;
74 
75 ///
76 /// Communicator object for C++11 thread communications
77 ///
79 {
80 protected:
81 
82  static const char *tagStringTable[]; ///< tag name string table
83 
84  // std::mutex applicationLockMutex; ///< mutex for applications
85 
86  ///
87  /// check if tag string table (for debugging) set up correctly
88  /// @return true if tag string table is set up correctly, false otherwise
89  ///
90  virtual bool tagStringTableIsSetUpCoorectly(
91  );
92 
93  ///
94  /// get Tag string for debugging
95  /// @return string which shows Tag
96  ///
97  virtual const char *getTagString(
98  int tag /// tag to be converted to string
99  );
100 
101 public:
102 
103  ///
104  /// constructor of ParaComCPP11
105  ///
107  )
108  : ParaCommCPP11()
109  {
110  }
111 
112  ///
113  /// destructor of this communicator
114  ///
116  )
117  {
118  }
119 
120 // ///
121 // /// lock UG application to synchronize with other threads
122 // ///
123 // void lockApp(
124 // )
125 // {
126 // applicationLockMutex.lock();
127 // }
128 //
129 // ///
130 // /// unlock UG application to synchronize with other threads
131 // ///
132 // void unlockApp(
133 // )
134 // {
135 // applicationLockMutex.unlock();
136 // }
137 
138  ///
139  /// create ParaCalculationState object by default constructor
140  /// @return pointer to ParaCalculationState object
141  ///
143  );
144 
145  ///
146  /// create ParaCalculationState object
147  /// @return pointer to ParaCalculationState object
148  ///
150  double compTime, ///< computation time of this ParaNode
151  double rootTime, ///< computation time of the root node
152  int nSolved, ///< the number of nodes solved
153  int nSent, ///< the number of ParaNodes sent
154  int nImprovedIncumbent, ///< the number of improved solution generated in this ParaSolver
155  int terminationState, ///< indicate whether if this computation is terminationState or not. 0: no, 1: terminationState
156  int nSolvedWithNoPreprocesses, ///< number of nodes solved when it is solved with no preprocesses
157  int nSimplexIterRoot, ///< number of simplex iteration at root node
158  double averageSimplexIter, ///< average number of simplex iteration except root node
159  int nTransferredLocalCuts, ///< number of local cuts transferred from a ParaNode
160  int minTransferredLocalCuts, ///< minimum number of local cuts transferred from a ParaNode
161  int maxTransferredLocalCuts, ///< maximum number of local cuts transferred from a ParaNode
162  int nTransferredBendersCuts, ///< number of benders cuts transferred from a ParaNode
163  int minTransferredBendersCuts, ///< minimum number of benders cuts transferred from a ParaNode
164  int maxTransferredBendersCuts, ///< maximum number of benders cuts transferred from a ParaNode
165  int nRestarts, ///< number of restarts
166  double minIisum, ///< minimum sum of integer infeasibility
167  double maxIisum, ///< maximum sum of integer infeasibility
168  int minNii, ///< minimum number of integer infeasibility
169  int maxNii, ///< maximum number of integer infeasibility
170  double dualBound, ///< final dual bound value
171  int nSelfSplitNodesLeft ///< number of self-split nodes left
172  );
173 
174  ///
175  /// create ParaNode object by default constructor
176  /// @return pointer to ParaNode object
177  ///
178  virtual ParaTask *createParaTask(
179  );
180 
181  ///
182  /// create ParaNode object
183  /// @return pointer to ParaNode object
184  ///
185  virtual ParaTask *createParaNode(
186  TaskId inNodeId, ///< node id
187  TaskId inGeneratorNodeId, ///< generator node id
188  int inDepth, ///< node depth in global search tree
189  double inDualBoundValue, ///< dual bound value
190  double inOriginalDualBoundValue, ///< original dual bound value
191  double inEstimatedValue, ///< estimated value
192  ParaDiffSubproblem *inDiffSubproblem ///< diff subproblem info. from the original problem
193  );
194 
195  ///
196  /// create ParaSolverState object by default constructor
197  /// @return pointer to ParaSolverState object
198  ///
200  );
201 
202  ///
203  /// create ParaSolverState object
204  /// @return pointer to ParaSolverState object
205  ///
207  int racingStage, ///< if this value is 1, solver is in racing stage
208  unsigned int notificationId, ///< id for this notification
209  int lcId, ///< lc id of current ParaNode
210  int globalSubtreeId, ///< global subtree id of current ParaNode
211  long long nodesSolved, ///< number of nodes solved
212  int nodesLeft, ///< number of remaining nodes
213  double bestDualBoundValue, ///< best dual bound value in that of remaining nodes
214  double globalBestPrimalBoundValue, ///< global best primal bound value
215  double detTime, ///< deterministic time, -1: should be non-deterministic
216  double averageDualBoundGain ///< average dual bound gain received
217  );
218 
219  ///
220  /// create ParaSolverTerminationState object by default constructor
221  /// @return pointer to ParaSolverTerminationState object
222  ///
224  );
225 
226  ///
227  /// create ParaSolverTerminationState object
228  /// @return pointer to ParaSolverTerminationState object
229  ///
231  int interrupted, ///< indicate that this solver is interrupted or not. 0: not interrupted, 1: interrupted
232  ///< 2: checkpoint, 3: racing-ramp up
233  int rank, ///< rank of this solver
234  int totalNSolved, ///< accumulated number of nodes solved in this ParaSolver
235  int minNSolved, ///< minimum number of subtree nodes rooted from ParaNode
236  int maxNSolved, ///< maximum number of subtree nodes rooted from ParaNode
237  int totalNSent, ///< accumulated number of nodes sent from this ParaSolver
238  int totalNImprovedIncumbent, ///< accumulated number of improvements of incumbent value in this ParaSolver
239  int nParaNodesReceived, ///< number of ParaNodes received in this ParaSolver
240  int nParaNodesSolved, ///< number of ParaNodes solved ( received ) in this ParaSolver
241  int nParaNodesSolvedAtRoot, ///< number of ParaNodes solved at root node before sending
242  int nParaNodesSolvedAtPreCheck, ///< number of ParaNodes solved at pre-checking of root node solvability
243  int nTransferredLocalCutsFromSolver, ///< number of local cuts transferred from this Solver
244  int minTransferredLocalCutsFromSolver, ///< minimum number of local cuts transferred from this Solver
245  int maxTransferredLocalCutsFromSolver, ///< maximum number of local cuts transferred from this Solver
246  int nTransferredBendersCutsFromSolver, ///< number of benders cuts transferred from this Solver
247  int minTransferredBendersCutsFromSolver, ///< minimum number of benders cuts transferred from this Solver
248  int maxTransferredBendersCutsFromSolver, ///< maximum number of benders cuts transferred from this Solver
249  int nTotalRestarts, ///< number of total restarts
250  int minRestarts, ///< minimum number of restarts
251  int maxRestarts, ///< maximum number of restarts
252  int nTightened, ///< number of tightened variable bounds during racing stage
253  int nTightenedInt, ///< number of tightened integral variable bounds during racing stage
254  int calcTerminationState, ///< termination sate of a calculation in a Solver
255  double runningTime, ///< this solver running time
256  double idleTimeToFirstParaNode, ///< idle time to start solving the first ParaNode
257  double idleTimeBetweenParaNodes, ///< idle time between ParaNodes processing
258  double iddleTimeAfterLastParaNode, ///< idle time after the last ParaNode was solved
259  double idleTimeToWaitNotificationId, ///< idle time to wait notification Id messages
260  double idleTimeToWaitAckCompletion, ///< idle time to wait ack completion message
261  double idleTimeToWaitToken, ///< idle time to wait token
262  double totalRootNodeTime, ///< total time consumed by root node processes
263  double minRootNodeTime, ///< minimum time consumed by root node processes
264  double maxRootNodeTime, ///< maximum time consumed by root node processes
265  double detTime ///< deterministic time, -1: should be non-deterministic
266  );
267 
268  ///
269  /// create ParaRacingRampUpParamSet object by default constructor
270  /// @return pointer to ParaRacingRampUpParamSet object
271  ///
273  )
274  {
275  THROW_LOGICAL_ERROR1("*** createParaRacingRampUpParamSet() is called in BbParaComm class ***");
276  }
277 
278 };
279 
280 #define DEF_BB_PARA_COMM( para_comm, comm ) UG::BbParaCommCPP11 *para_comm = dynamic_cast< UG::BbParaCommCPP11* >(comm)
281 
282 }
283 
284 #endif // __BB_PARA_COMM_CPP11_H__
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
Communicator object for C++11 thread communications.
BbParaCommCPP11()
constructor of ParaComCPP11
class BbParaRacingRampUpParamSet (parameter set for racing ramp-up)
virtual ~BbParaCommCPP11()
destructor of this communicator
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
Base class of Calculation state in a ParaSolver.
class for solution
virtual ParaSolverState * createParaSolverState()
create ParaSolverState object by default constructor
Base class of Calculation state in a ParaSolver.
TaskId class.
Definition: paraTask.h:222
static const int BB_USER_TYPE_FIRST
bb user defined transfer data types
static const int BB_USER_TYPE_LAST
static bool interrupted
Definition: fscip.cpp:78
static const int ParaSolverDiffParamType
#define THROW_LOGICAL_ERROR1(msg1)
Definition: paraDef.h:52
virtual ParaRacingRampUpParamSet * createParaRacingRampUpParamSet()
create ParaRacingRampUpParamSet object by default constructor
class ParaSolverTerminationState (Solver termination state in a ParaSolver)
virtual ParaTask * createParaTask()
create ParaNode object by default constructor
Class for the difference between instance and subproblem.
Class for the difference between instance and subproblem.
class BbParaNode
Definition: bbParaNode.h:61
class for instance data
static const int UG_USER_TYPE_LAST
ParaComm extension for C++11 thread communication.
class ParaRacingRampUpParamSet (parameter set for racing ramp-up)
class BbParaSolverState (ParaSolver state object for notification message)
class BbParaSolverTerminationState (Solver termination state in a ParaSolver)
Communicator object for C++11 thread communications.
virtual ParaTask * createParaNode(TaskId inNodeId, TaskId inGeneratorNodeId, int inDepth, double inDualBoundValue, double inOriginalDualBoundValue, double inEstimatedValue, ParaDiffSubproblem *inDiffSubproblem)
create ParaNode object
class ParaTask
Definition: paraTask.h:541