Dip  0.92.4
DecompStats.h
Go to the documentation of this file.
1 //===========================================================================//
2 // This file is part of the DIP Solver Framework. //
3 // //
4 // DIP is distributed under the Eclipse Public License as part of the //
5 // COIN-OR repository (http://www.coin-or.org). //
6 // //
7 // Authors: Matthew Galati, SAS Institute Inc. (matthew.galati@sas.com) //
8 // Ted Ralphs, Lehigh University (ted@lehigh.edu) //
9 // Jiadong Wang, Lehigh University (jiw408@lehigh.edu) //
10 // //
11 // Copyright (C) 2002-2019, Lehigh University, Matthew Galati, Ted Ralphs //
12 // All Rights Reserved. //
13 //===========================================================================//
14 
15 //===========================================================================//
16 #ifndef DecompStats_h_
17 #define DecompStats_h_
18 
19 //===========================================================================//
20 #include "Decomp.h"
21 #include "UtilTimer.h"
22 //===========================================================================//
23 
24 //===========================================================================//
26 public:
30  int phase;
34  int cutPass;
38  int pricePass;
42  double timeStamp;
46  double thisBound;
50  double thisBoundUB;
55  double bestBound;
59  double thisBoundIP;
64  double bestBoundIP;
65 
69  bool operator<(const DecompObjBound& objBound) const {
70  if (timeStamp < objBound.timeStamp) {
71  return true;
72  } else {
73  return false;
74  }
75  }
76 
77 public:
78  DecompObjBound(double infinity) :
79  phase (0),
80  cutPass (0),
81  pricePass (0),
82  timeStamp (0.0),
83  thisBound (-infinity),
84  thisBoundUB( infinity),
85  bestBound (-infinity),
86  thisBoundIP( infinity),
87  bestBoundIP( infinity) {
88  }
89 
90 };
91 
92 //===========================================================================//
94 public:
95 
96  //---
97  //--- Storage for the bound history for a node.
98  //--- NOTE: we always assume a minimization problem
99  //---
100 
114  std::vector< DecompObjBound > objHistoryBound;
115 
119  std::pair<double, double> objBest;
120 
125 
130 
135 
140 
145 
150 
155 
160 
165 
169  double m_infinity;
170 
171 public:
172  void init() {
173  objHistoryBound.clear();
174  objBest.first = -m_infinity;
175  objBest.second = m_infinity;
176  nodeIndex = 0;
177  cutsThisRound = 0;
178  varsThisRound = 0;
179  cutsThisCall = 0;
180  varsThisCall = 0;
181  cutCallsTotal = 0;
182  priceCallsTotal = 0;
183  cutCallsRound = 0;
184  priceCallsRound = 0;
185  }
186 
187 public:
188  void printObjHistoryBound (std::ostream* os = &std::cout) const;
189  inline void resetCutRound() {
190  cutCallsRound = 0;
191  cutsThisRound = 0;
192  }
193  inline void resetPriceRound() {
194  priceCallsRound = 0;
195  varsThisRound = 0;
196  }
197  inline void resetBestLB() {
198  objBest.first = -m_infinity;
199  }
201  int nHistorySize = static_cast<int>(objHistoryBound.size());
202 
203  if (nHistorySize > 0) {
204  return &(objHistoryBound[nHistorySize - 1]);
205  } else {
206  return 0;
207  }
208  }
209  inline double getLastBoundThis() {
210  double thisBound = -m_infinity;
211  DecompObjBound* lastBound = getLastBound();
212 
213  if (lastBound) {
214  thisBound = lastBound->thisBound;
215  }
216 
217  return thisBound;
218  }
219 
220 public:
222  objHistoryBound(),
223  objBest (),
225  init();
226  }
227 };
228 
229 
230 //===========================================================================//
231 class DecompStats {
232 
233 public:
238 
239 public:
240  double totalOverall;
241 
242  double totalDecomp;
246  double totalGenCuts;
248  double totalGenVars;
250 
251  double maxDecomp;
254  double maxSolUpdate;
255  double maxGenCuts;
256  double maxGenVars;
258 
259 public:
260  std::vector<double> thisDecomp;
261  std::vector<double> thisSolveRelax;
262  std::vector<double> thisSolveRelaxApp;
263  std::vector<double> thisSolUpdate;
264  std::vector<double> thisGenCuts;
265  std::vector<double> thisGenCutsApp;
266  std::vector<double> thisGenVars;
267  std::vector<double> thisCompressCols;
268 
269 public:
270  void calculateStats();
271  void printOverallStats (std::ostream* os = &std::cout); //ostream?
272  void printDetailedStats(std::ostream* os = &std::cout); //ostream?
273 
274 public:
276 
277  totalOverall (0.0),
278 
279  totalDecomp (0.0),
280  totalSolveRelax (0.0),
281  totalSolveRelaxApp(0.0),
282  totalSolUpdate (0.0),
283  totalGenCuts (0.0),
284  totalGenCutsApp (0.0),
285  totalGenVars (0.0),
286  totalCompressCols (0.0),
287 
288  maxDecomp (0.0),
289  maxSolveRelax (0.0),
290  maxSolveRelaxApp (0.0),
291  maxSolUpdate (0.0),
292  maxGenCuts (0.0),
293  maxGenVars (0.0),
294  maxCompressCols (0.0)
295 
296  {
297  }
298 
300 
301 };
302 //===========================================================================//
303 
304 #endif
305 
std::vector< double > thisDecomp
Definition: DecompStats.h:260
double thisBoundUB
The recorded continuous upper bound.
Definition: DecompStats.h:50
std::vector< double > thisCompressCols
Definition: DecompStats.h:267
double maxCompressCols
Definition: DecompStats.h:257
bool operator<(const DecompObjBound &objBound) const
Comparison operator for sorting on time.
Definition: DecompStats.h:69
std::vector< DecompObjBound > objHistoryBound
Storage of the bounds.
Definition: DecompStats.h:114
int nodeIndex
The node index (in the branch-and-bound tree).
Definition: DecompStats.h:124
double thisBoundIP
The recorded integer upper bound.
Definition: DecompStats.h:59
double maxSolveRelaxApp
Definition: DecompStats.h:253
UtilTimer timerOverall
Definition: DecompStats.h:234
double totalSolveRelax
Definition: DecompStats.h:243
double totalSolUpdate
Definition: DecompStats.h:245
int cutsThisRound
Number of cuts generated in this round of cut calls.
Definition: DecompStats.h:129
std::vector< double > thisSolUpdate
Definition: DecompStats.h:263
double maxGenVars
Definition: DecompStats.h:256
UtilTimer timerDecomp
Definition: DecompStats.h:235
std::vector< double > thisGenCutsApp
Definition: DecompStats.h:265
double totalGenCuts
Definition: DecompStats.h:246
int cutCallsTotal
Number of cut calls in this node in total.
Definition: DecompStats.h:149
int cutPass
The cut pass when bound was recorded.
Definition: DecompStats.h:34
std::vector< double > thisSolveRelaxApp
Definition: DecompStats.h:262
void printDetailedStats(std::ostream *os=&std::cout)
int cutsThisCall
Number of cuts generated in this particular cut call.
Definition: DecompStats.h:139
void printObjHistoryBound(std::ostream *os=&std::cout) const
std::vector< double > thisSolveRelax
Definition: DecompStats.h:261
UtilTimer timerOther2
Definition: DecompStats.h:237
void resetCutRound()
Definition: DecompStats.h:189
double bestBoundIP
The best recorded integer upper bound.
Definition: DecompStats.h:64
int varsThisRound
Number of vars generated in this round of pricing calls.
Definition: DecompStats.h:134
int phase
The phase when bound was recorded.
Definition: DecompStats.h:30
int priceCallsTotal
Number of price calls in this node in total.
Definition: DecompStats.h:154
double bestBound
The best recorded continuous lower bound.
Definition: DecompStats.h:55
std::pair< double, double > objBest
The global lower (.first) and upper (.second) bound.
Definition: DecompStats.h:119
int pricePass
The price pass when bound was recorded.
Definition: DecompStats.h:38
int priceCallsRound
Number of price calls in this round.
Definition: DecompStats.h:164
double m_infinity
Value of infinity.
Definition: DecompStats.h:169
double totalCompressCols
Definition: DecompStats.h:249
double maxGenCuts
Definition: DecompStats.h:255
double maxDecomp
Definition: DecompStats.h:251
double getLastBoundThis()
Definition: DecompStats.h:209
const double COIN_DBL_MAX
Definition: CoinFinite.hpp:18
double timeStamp
The time stamp (from start) when bound was recorded.
Definition: DecompStats.h:42
UtilTimer timerOther1
Definition: DecompStats.h:236
DecompObjBound(double infinity)
Definition: DecompStats.h:78
int cutCallsRound
Number of cut calls in this round.
Definition: DecompStats.h:159
std::vector< double > thisGenVars
Definition: DecompStats.h:266
void printOverallStats(std::ostream *os=&std::cout)
double maxSolUpdate
Definition: DecompStats.h:254
int varsThisCall
Number of vars generated in this particular price call.
Definition: DecompStats.h:144
void resetBestLB()
Definition: DecompStats.h:197
std::vector< double > thisGenCuts
Definition: DecompStats.h:264
DecompObjBound * getLastBound()
Definition: DecompStats.h:200
double thisBound
The recorded continuous lower bound.
Definition: DecompStats.h:46
void resetPriceRound()
Definition: DecompStats.h:193
double totalGenCutsApp
Definition: DecompStats.h:247
void calculateStats()
double totalSolveRelaxApp
Definition: DecompStats.h:244
double totalGenVars
Definition: DecompStats.h:248
double maxSolveRelax
Definition: DecompStats.h:252
double totalOverall
Definition: DecompStats.h:240
double totalDecomp
Definition: DecompStats.h:242