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