Scippy

UG

Ubiquity Generator framework

bbParaSolverState.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 paraSolverState.h
27  * @brief This class has solver state to be transferred.
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_SOLVER_STATE_H__
38 #define __BB_PARA_SOLVER_STATE_H__
39 
40 #include <cfloat>
41 #include "ug/paraComm.h"
42 #include "ug/paraSolverState.h"
43 
44 namespace UG
45 {
46 
47 ///
48 /// class BbParaSolverState
49 /// (ParaSolver state object for notification message)
50 ///
52 {
53 
54 protected:
55 
56 // int racingStage; ///< if this value is 1, solver is in racing stage
57 // unsigned int notificationId; ///< id for this notification
58 // int lcId; ///< lc id of current ParaNode
59 // int globalSubtreeIdInLc; ///< global subtree id of current ParaNode
60  long long nNodesSolved; ///< number of nodes solved
61  int nNodesLeft; ///< number of remaining nodes
62  double bestDualBoundValue; ///< best dual bound value in that of remaining nodes
63  double globalBestPrimalBoundValue; ///< global best primal bound value
64 // double detTime; ///< deterministic time, -1: should be non-deterministic
65  double averageDualBoundGain; ///< average dual bound gain received
66 
67 public:
68 
69  ///
70  /// default constructor
71  ///
73  )
74  : ParaSolverState(),
75  nNodesSolved(0),
76  nNodesLeft(-1),
77  bestDualBoundValue(0.0),
78  globalBestPrimalBoundValue(DBL_MAX),
79  // detTime(-1.0),
80  averageDualBoundGain(0.0)
81  {
82  }
83 
84  ///
85  /// constructor
86  ///
88  int inRacingStage, ///< indicate if Solver is in racing stage or not
89  unsigned int inNotificationId, ///< id for this notification
90  int inLcId, ///< lc id of current ParaNode
91  int inGlobalSubtreeId, ///< global subtree id of current ParaNode
92  long long inNodesSolved, ///< number of nodes solved
93  int inNodesLeft, ///< number of remaining nodes
94  double inBestDualBoundValue, ///< best dual bound value in that of remaining nodes
95  double inGlobalBestPrimalBoundValue, ///< global best primal bound value
96  double inDetTime, ///< deterministic time, -1: should be non-deterministic
97  double inAverageDualBoundGain ///< average dual bound gain received
98  )
99  : ParaSolverState(inRacingStage, inNotificationId, inLcId, inGlobalSubtreeId, inDetTime),
100  nNodesSolved(inNodesSolved),
101  nNodesLeft(inNodesLeft),
102  bestDualBoundValue(inBestDualBoundValue),
103  globalBestPrimalBoundValue(inGlobalBestPrimalBoundValue),
104  averageDualBoundGain(inAverageDualBoundGain)
105  {
106  }
107 
108  ///
109  /// destractor
110  ///
112  )
113  {
114  }
115 
116  ///
117  /// getter of isRacingStage
118  /// @return true if the Solver notified this message is in racing stage, false otherwise
119  ///
121  )
122  {
123  return (racingStage == 1);
124  }
125 
126  ///
127  /// getter of notification id
128  /// @return notification id
129  ///
130  unsigned int getNotificaionId(
131  )
132  {
133  return notificationId;
134  }
135 
136  ///
137  /// getter of LoadCoordintor id
138  /// @return LoadCoordinator id
139  ///
140  int getLcId(
141  )
142  {
143  return lcId;
144  }
145 
146  ///
147  /// getter of global subtree id
148  /// @return global subtree id
149  ///
151  )
152  {
153  return globalSubtreeIdInLc;
154  }
155 
156  ///
157  /// gettter of best dual bound value
158  /// @return best dual bound value
159  ///
161  )
162  {
163  return bestDualBoundValue;
164  }
165 
166  ///
167  /// get global best primal bound value that the notification Solver has
168  /// @return global best primal bound value
169  ///
171  )
172  {
174  }
175 
176  ///
177  /// getter of number of nodes solved by the notification Solver
178  /// @return number of nodes solved
179  ///
180  long long getNNodesSolved(
181  )
182  {
183  return nNodesSolved;
184  }
185 
186 
187  ///
188  /// getter of number of nodes left by the notification Solver
189  /// @return number of nodes left
190  ///
192  )
193  {
194  return nNodesLeft;
195  }
196 
197  ///
198  /// getter of deterministic time
199  /// @return deterministic time
200  ///
202  )
203  {
204  return detTime;
205  }
206 
207  ///
208  /// getter of average dual bound gain received
209  /// @return average dual bound gain
210  ///
212  )
213  {
214  return averageDualBoundGain;
215  }
216 
217  ///
218  /// stringfy BbParaSolverState
219  /// @return string to show inside of BbParaSolverState
220  ///
221  std::string toString(
222  )
223  {
224  std::ostringstream s;
225  s << "racingStage = " << racingStage << ", notificationId = " << notificationId << ": ";
226  s << "[" << lcId << ":" << globalSubtreeIdInLc << "]"
227  << " Best dual bound value = " << bestDualBoundValue
228  << " number of nodes solved = " << nNodesSolved
229  << ", number of nodes left = " << nNodesLeft;
230  return s.str();
231  }
232 
233 };
234 
235 }
236 
237 #endif // __BB_PARA_SOLVER_STATE_H__
class ParaSolverState (ParaSolver state object for notification message)
This class has solver state to be transferred.
double getSolverLocalBestDualBoundValue()
gettter of best dual bound value
BbParaSolverState()
default constructor
int getGlobalSubtreeId()
getter of global subtree id
double getAverageDualBoundGain()
getter of average dual bound gain received
int globalSubtreeIdInLc
global subtree id of current ParaTask
int getNNodesLeft()
getter of number of nodes left by the notification Solver
virtual ~BbParaSolverState()
destractor
unsigned int getNotificaionId()
getter of notification id
Base class of communicator for UG Framework.
double detTime
deterministic time, -1: should be non-deterministic
double averageDualBoundGain
average dual bound gain received
int nNodesLeft
number of remaining nodes
bool isRacingStage()
getter of isRacingStage
int getLcId()
getter of LoadCoordintor id
int lcId
lc id of current ParaTask
double globalBestPrimalBoundValue
global best primal bound value
double getDeterministicTime()
getter of deterministic time
long long getNNodesSolved()
getter of number of nodes solved by the notification Solver
double getGlobalBestPrimalBoundValue()
get global best primal bound value that the notification Solver has
std::string toString()
stringfy BbParaSolverState
long long nNodesSolved
number of nodes solved
BbParaSolverState(int inRacingStage, unsigned int inNotificationId, int inLcId, int inGlobalSubtreeId, long long inNodesSolved, int inNodesLeft, double inBestDualBoundValue, double inGlobalBestPrimalBoundValue, double inDetTime, double inAverageDualBoundGain)
constructor
class BbParaSolverState (ParaSolver state object for notification message)
int racingStage
if this value is 1, solver is in racing stage
unsigned int notificationId
id for this notification
double bestDualBoundValue
best dual bound value in that of remaining nodes