Scippy

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