UG

Ubiquity Generator framework

bbParaCalculationState.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 bbParaCalculationState.h
27 * @brief Base class for calculation state.
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_CALCULATION_STATE_H__
38#define __BB_PARA_CALCULATION_STATE_H__
39
40#include <climits>
41#include <cfloat>
42#include "ug/paraComm.h"
44
45namespace UG
46{
47
48///
49/// \class BbParaCalculationState
50/// Base class of Calculation state in a ParaSolver
51///
53{
54protected:
55 double compTime; ///< computation time of this ParaTask
56 int nSolved; ///< the number of tasks solved
57 int terminationState; ///< indicate whether if this computation is terminationState or not. 0: no, 1: terminationState
58 ///< meaning can be defined in derived class
59 double rootTime; ///< computation time of the root node
60 int nSent; ///< the number of ParaNodes sent
61 int nImprovedIncumbent; ///< the number of improved solution generated in this ParaSolver
62 int nSolvedWithNoPreprocesses; ///< number of nodes solved when it is solved with no preprocesses
63 int nSimplexIterRoot; ///< number of simplex iteration at root node
64 double averageSimplexIter; ///< average number of simplex iteration except root node
65 int nTransferredLocalCuts; ///< number of local cuts transferred from a ParaNode
66 int minTransferredLocalCuts; ///< minimum number of local cuts transferred from a ParaNode
67 int maxTransferredLocalCuts; ///< maximum number of local cuts transferred from a ParaNode
68 int nTransferredBendersCuts; ///< number of benders cuts transferred from a ParaNode
69 int minTransferredBendersCuts; ///< minimum number of benders cuts transferred from a ParaNode
70 int maxTransferredBendersCuts; ///< maximum number of benders cuts transferred from a ParaNode
71 int nRestarts; ///< number of restarts
72 double minIisum; ///< minimum sum of integer infeasibility
73 double maxIisum; ///< maximum sum of integer infeasibility
74 int minNii; ///< minimum number of integer infeasibility
75 int maxNii; ///< maximum number of integer infeasibility
76 double dualBound; ///< final dual bound value
77 int nSelfSplitNodesLeft; ///< number of self-split nodes left
78public:
79
80 ///
81 /// Default Constructor
82 ///
84 )
86 compTime(0.0),
87 nSolved(-1),
89 rootTime(0.0),
90 nSent(-1),
101 nRestarts(0),
102 minIisum(0.0),
103 maxIisum(0.0),
104 minNii(0),
105 maxNii(0),
106 dualBound(-DBL_MAX),
108 {
109 }
110
111 ///
112 /// Constructor
113 ///
115 double inCompTime, ///< computation time of this ParaNode
116 double inRootTime, ///< computation time of the root node
117 int inNSolved, ///< the number of nodes solved
118 int inNSent, ///< the number of ParaNodes sent
119 int inNImprovedIncumbent, ///< the number of improved solution generated in this ParaSolver
120 int inTerminationState, ///< indicate whether if this computation is terminationState or not. 0: no, 1: terminationState
121 int inNSolvedWithNoPreprocesses, ///< number of nodes solved when it is solved with no preprocesses
122 int inNSimplexIterRoot, ///< number of simplex iteration at root node
123 double inAverageSimplexIter, ///< average number of simplex iteration except root node
124 int inNTransferredLocalCuts, ///< number of local cuts transferred from a ParaNode
125 int inMinTransferredLocalCuts, ///< minimum number of local cuts transferred from a ParaNode
126 int inMaxTransferredLocalCuts, ///< maximum number of local cuts transferred from a ParaNode
127 int inNTransferredBendersCuts, ///< number of benders cuts transferred from a ParaNode
128 int inMinTransferredBendersCuts, ///< minimum number of benders cuts transferred from a ParaNode
129 int inMaxTransferredBendersCuts, ///< maximum number of benders cuts transferred from a ParaNode
130 int inNRestarts, ///< number of restarts
131 double inMinIisum, ///< minimum sum of integer infeasibility
132 double inMaxIisum, ///< maximum sum of integer infeasibility
133 int inMinNii, ///< minimum number of integer infeasibility
134 int inMaxNii, ///< maximum number of integer infeasibility
135 double inDualBound, ///< final dual Bound value
136 int inNSelfSplitNodesLeft ///< number of self-split nodes left
137 )
139 compTime(inCompTime),
140 nSolved(inNSolved),
141 terminationState(inTerminationState),
142 rootTime(inRootTime),
143 nSent(inNSent),
144 nImprovedIncumbent(inNImprovedIncumbent),
145 nSolvedWithNoPreprocesses(inNSolvedWithNoPreprocesses),
146 nSimplexIterRoot(inNSimplexIterRoot),
147 averageSimplexIter(inAverageSimplexIter),
148 nTransferredLocalCuts(inNTransferredLocalCuts),
149 minTransferredLocalCuts(inMaxTransferredLocalCuts),
150 maxTransferredLocalCuts(inMaxTransferredLocalCuts),
151 nTransferredBendersCuts(inNTransferredBendersCuts),
152 minTransferredBendersCuts(inMaxTransferredBendersCuts),
153 maxTransferredBendersCuts(inMaxTransferredBendersCuts),
154 nRestarts(inNRestarts),
155 minIisum(inMinIisum),
156 maxIisum(inMaxIisum),
157 minNii(inMinNii),
158 maxNii(inMaxNii),
159 dualBound(inDualBound),
160 nSelfSplitNodesLeft(inNSelfSplitNodesLeft)
161 {
162 }
163
164 ///
165 /// Destructor
166 ///
167 virtual
169 )
170 {
171 }
172
173 ///
174 /// getter of computing time of a subproblem
175 /// @return subroblem computing time
176 ///
178 )
179 {
180 return compTime;
181 }
182
183 ///
184 /// getter of the number of tasks solved in a subproblem
185 /// @return the number of tasks
186 ///
188 )
189 {
190 return nSolved;
191 }
192
193 ///
194 /// getter of root node computing time
195 /// @return root node computing time
196 ///
198 )
199 {
200 return rootTime;
201 }
202
203 ///
204 /// getter of the number of restart occurred in solving a subproblem
205 /// @return the number of restarts
206 ///
208 )
209 {
210 return nRestarts;
211 }
212
213 ///
214 /// getter of average computing time of a node except root node
215 /// @return the average computing time
216 ///
218 )
219 {
220 if( nSolved > 1 )
221 {
222 return ((compTime - rootTime)/(nSolved - 1));
223 }
224 else
225 {
226 return 0.0;
227 }
228 }
229
230 ///
231 /// getter of the number of nodes transferred from the subproblem solving
232 /// @return the number of nodes sent
233 ///
235 )
236 {
237 return nSent;
238 }
239
240 ///
241 /// getter of the number of improved incumbents during solving the subproblem
242 /// @return the number of the improved incumbents
243 ///
245 )
246 {
247 return nImprovedIncumbent;
248 }
249
250 ///
251 /// getter of the termination state for solving the subproblem
252 /// @return the termination state
253 ///
255 )
256 {
257 return terminationState;
258 }
259
260 ///
261 /// getter of the number of solved nodes in the case that a node is solved without
262 /// presolving. This is an experimental routine only used for SCIP parallelization
263 /// @return the number of solved node without presolving
264 ///
266 )
267 {
269 }
270
271 ///
272 /// getter of the final dual bound value
273 /// @return the final dual bound value
274 ///
276 )
277 {
278 return dualBound;
279 }
280
281 ///
282 /// getter of the number of self-split nodes left
283 /// @return the number of self-split nodes left
284 ///
286 )
287 {
288 return nSelfSplitNodesLeft;
289 }
290
291 ///
292 /// stringfy BbParaCalculationState
293 /// @return string to show this object
294 ///
295 std::string toString(
296 )
297 {
298 std::ostringstream s;
299 if( terminationState )
300 {
301 s << "Termination state of this computation was " << terminationState << " : [ "
302 << compTime << " sec. computed ]"
303 << nSolved << " nodes were solved, "
304 << nSent << " nodes were sent, "
305 << nImprovedIncumbent << " improved solutions were found";
306 }
307 else
308 {
309 s << "Computation was normally terminated: [ "
310 << compTime << " sec. computed ]"
311 << nSolved << " nodes were solved, "
312 << nSent << " nodes were sent, "
313 << nImprovedIncumbent << " improved solutions were found";
314 }
315 return s.str();
316 }
317
318 ///
319 /// stringfy BbParaCalculationState (simple string version)
320 /// @return simple string to show this object
321 ///
322 std::string toSimpleString(
323 )
324 {
325 std::ostringstream s;
326
327 s << compTime
328 << ", "
329 << rootTime
330 << ", "
331 << nSolved
332 << ", "
333 << nSent
334 << ", "
336 << ", "
338 << ", "
340 << ", "
341 << nRestarts
342 << ", ";
343
344 if( maxNii > 0 )
345 {
346 s << minIisum
347 << ", "
348 << maxIisum
349 << ", "
350 << minNii
351 << ", "
352 << maxNii;
353 }
354 else
355 {
356 s << ", -, -, -, -";
357 }
358 s << ", " << dualBound;
359 s << ", " << nSelfSplitNodesLeft;
360
361 return s.str();
362 }
363
364};
365
366}
367
368#endif // __BB_PARA_CALCULATION_STATE_H__
Base class of Calculation state in a ParaSolver.
int minTransferredLocalCuts
minimum number of local cuts transferred from a ParaNode
int nTransferredBendersCuts
number of benders cuts transferred from a ParaNode
double rootTime
computation time of the root node
int nSolved
the number of tasks solved
int terminationState
indicate whether if this computation is terminationState or not. 0: no, 1: terminationState meaning c...
double dualBound
final dual bound value
int maxTransferredLocalCuts
maximum number of local cuts transferred from a ParaNode
int maxTransferredBendersCuts
maximum number of benders cuts transferred from a ParaNode
BbParaCalculationState(double inCompTime, double inRootTime, int inNSolved, int inNSent, int inNImprovedIncumbent, int inTerminationState, int inNSolvedWithNoPreprocesses, int inNSimplexIterRoot, double inAverageSimplexIter, int inNTransferredLocalCuts, int inMinTransferredLocalCuts, int inMaxTransferredLocalCuts, int inNTransferredBendersCuts, int inMinTransferredBendersCuts, int inMaxTransferredBendersCuts, int inNRestarts, double inMinIisum, double inMaxIisum, int inMinNii, int inMaxNii, double inDualBound, int inNSelfSplitNodesLeft)
Constructor.
int nSelfSplitNodesLeft
number of self-split nodes left
int nSimplexIterRoot
number of simplex iteration at root node
int maxNii
maximum number of integer infeasibility
int minTransferredBendersCuts
minimum number of benders cuts transferred from a ParaNode
int getNSolved()
getter of the number of tasks solved in a subproblem
int getNImprovedIncumbent()
getter of the number of improved incumbents during solving the subproblem
double compTime
computation time of this ParaTask
double getCompTime()
getter of computing time of a subproblem
int nSolvedWithNoPreprocesses
number of nodes solved when it is solved with no preprocesses
int getNSent()
getter of the number of nodes transferred from the subproblem solving
int nRestarts
number of restarts
double getRootTime()
getter of root node computing time
double averageSimplexIter
average number of simplex iteration except root node
int getNSolvedWithNoPreprocesses()
getter of the number of solved nodes in the case that a node is solved without presolving....
double maxIisum
maximum sum of integer infeasibility
std::string toString()
stringfy BbParaCalculationState
std::string toSimpleString()
stringfy BbParaCalculationState (simple string version)
int nImprovedIncumbent
the number of improved solution generated in this ParaSolver
double getAverageNodeCompTimeExcpetRoot()
getter of average computing time of a node except root node
int getNRestarts()
getter of the number of restart occurred in solving a subproblem
double minIisum
minimum sum of integer infeasibility
BbParaCalculationState()
Default Constructor.
int minNii
minimum number of integer infeasibility
virtual ~BbParaCalculationState()
Destructor.
int nSent
the number of ParaNodes sent
int nTransferredLocalCuts
number of local cuts transferred from a ParaNode
double getDualBoundValue()
getter of the final dual bound value
double getNSelfSplitNodesLeft()
getter of the number of self-split nodes left
int getTerminationState()
getter of the termination state for solving the subproblem
Abstract interface for calculation state in a ParaSolver. Holds no data; derived classes own the fiel...
Base class for calculation state.
Base class of communicator for UG Framework.