Dip-All  0.91.0
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 // Author: Matthew Galati, SAS Institute Inc. (matthew.galati@sas.com) //
8 // //
9 // Conceptual Design: Matthew Galati, SAS Institute Inc. //
10 // Ted Ralphs, Lehigh University //
11 // //
12 // Copyright (C) 2002-2015, Lehigh University, Matthew Galati, Ted Ralphs //
13 // All Rights Reserved. //
14 //===========================================================================//
15 
16 //===========================================================================//
17 #ifndef DecompStats_h_
18 #define DecompStats_h_
19 
20 //===========================================================================//
21 #include "Decomp.h"
22 #include "UtilTimer.h"
23 //===========================================================================//
24 
25 //===========================================================================//
27 public:
31  int phase;
35  int cutPass;
39  int pricePass;
43  double timeStamp;
47  double thisBound;
51  double thisBoundUB;
56  double bestBound;
60  double thisBoundIP;
65  double bestBoundIP;
66 
70  bool operator<(const DecompObjBound& objBound) const {
71  if (timeStamp < objBound.timeStamp) {
72  return true;
73  } else {
74  return false;
75  }
76  }
77 
78 public:
80  phase (0),
81  cutPass (0),
82  pricePass (0),
83  timeStamp (0.0),
84  thisBound (-DecompInf),
85  thisBoundUB( DecompInf),
86  bestBound (-DecompInf),
87  thisBoundIP( DecompInf),
88  bestBoundIP( DecompInf) {
89  }
90 
91 };
92 
93 //===========================================================================//
95 public:
96 
97  //---
98  //--- Storage for the bound history for a node.
99  //--- NOTE: we always assume a minimization problem
100  //---
101 
115  std::vector< DecompObjBound > objHistoryBound;
116 
120  std::pair<double, double> objBest;
121 
126 
131 
136 
141 
146 
151 
156 
161 
166 
167 public:
168  void init() {
169  objHistoryBound.clear();
170  objBest.first = -DecompInf;
171  objBest.second = DecompInf;
172  nodeIndex = 0;
173  cutsThisRound = 0;
174  varsThisRound = 0;
175  cutsThisCall = 0;
176  varsThisCall = 0;
177  cutCallsTotal = 0;
178  priceCallsTotal = 0;
179  cutCallsRound = 0;
180  priceCallsRound = 0;
181  }
182 
183 public:
184  void printObjHistoryBound (std::ostream* os = &std::cout) const;
185  inline void resetCutRound() {
186  cutCallsRound = 0;
187  cutsThisRound = 0;
188  }
189  inline void resetPriceRound() {
190  priceCallsRound = 0;
191  varsThisRound = 0;
192  }
193  inline void resetBestLB() {
194  objBest.first = -DecompInf;
195  }
197  int nHistorySize = static_cast<int>(objHistoryBound.size());
198 
199  if (nHistorySize > 0) {
200  return &(objHistoryBound[nHistorySize - 1]);
201  } else {
202  return 0;
203  }
204  }
205  inline double getLastBoundThis() {
206  double thisBound = -DecompInf;
207  DecompObjBound* lastBound = getLastBound();
208 
209  if (lastBound) {
210  thisBound = lastBound->thisBound;
211  }
212 
213  return thisBound;
214  }
215 
216 public:
218  objHistoryBound(),
219  objBest () {
220  init();
221  }
222 };
223 
224 
225 //===========================================================================//
226 class DecompStats {
227 
228 public:
233 
234 public:
235  double totalOverall;
236 
237  double totalDecomp;
241  double totalGenCuts;
243  double totalGenVars;
245 
246  double maxDecomp;
249  double maxSolUpdate;
250  double maxGenCuts;
251  double maxGenVars;
253 
254 public:
255  std::vector<double> thisDecomp;
256  std::vector<double> thisSolveRelax;
257  std::vector<double> thisSolveRelaxApp;
258  std::vector<double> thisSolUpdate;
259  std::vector<double> thisGenCuts;
260  std::vector<double> thisGenCutsApp;
261  std::vector<double> thisGenVars;
262  std::vector<double> thisCompressCols;
263 
264 public:
265  void calculateStats();
266  void printOverallStats (std::ostream* os = &std::cout); //ostream?
267  void printDetailedStats(std::ostream* os = &std::cout); //ostream?
268 
269 public:
271 
272  totalOverall (0.0),
273 
274  totalDecomp (0.0),
275  totalSolveRelax (0.0),
276  totalSolveRelaxApp(0.0),
277  totalSolUpdate (0.0),
278  totalGenCuts (0.0),
279  totalGenCutsApp (0.0),
280  totalGenVars (0.0),
281  totalCompressCols (0.0),
282 
283  maxDecomp (0.0),
284  maxSolveRelax (0.0),
285  maxSolveRelaxApp (0.0),
286  maxSolUpdate (0.0),
287  maxGenCuts (0.0),
288  maxGenVars (0.0),
289  maxCompressCols (0.0)
290 
291  {
292  }
293 
295 
296 };
297 //===========================================================================//
298 
299 #endif
300 
std::vector< double > thisDecomp
Definition: DecompStats.h:255
double thisBoundUB
The recorded continuous upper bound.
Definition: DecompStats.h:51
std::vector< double > thisCompressCols
Definition: DecompStats.h:262
double maxCompressCols
Definition: DecompStats.h:252
bool operator<(const DecompObjBound &objBound) const
Comparison operator for sorting on time.
Definition: DecompStats.h:70
std::vector< DecompObjBound > objHistoryBound
Storage of the bounds.
Definition: DecompStats.h:115
int nodeIndex
The node index (in the branch-and-bound tree).
Definition: DecompStats.h:125
double thisBoundIP
The recorded integer upper bound.
Definition: DecompStats.h:60
double maxSolveRelaxApp
Definition: DecompStats.h:248
UtilTimer timerOverall
Definition: DecompStats.h:229
double totalSolveRelax
Definition: DecompStats.h:238
double totalSolUpdate
Definition: DecompStats.h:240
int cutsThisRound
Number of cuts generated in this round of cut calls.
Definition: DecompStats.h:130
std::vector< double > thisSolUpdate
Definition: DecompStats.h:258
double maxGenVars
Definition: DecompStats.h:251
UtilTimer timerDecomp
Definition: DecompStats.h:230
std::vector< double > thisGenCutsApp
Definition: DecompStats.h:260
double totalGenCuts
Definition: DecompStats.h:241
int cutCallsTotal
Number of cut calls in this node in total.
Definition: DecompStats.h:150
int cutPass
The cut pass when bound was recorded.
Definition: DecompStats.h:35
std::vector< double > thisSolveRelaxApp
Definition: DecompStats.h:257
void printDetailedStats(std::ostream *os=&std::cout)
int cutsThisCall
Number of cuts generated in this particular cut call.
Definition: DecompStats.h:140
void printObjHistoryBound(std::ostream *os=&std::cout) const
std::vector< double > thisSolveRelax
Definition: DecompStats.h:256
UtilTimer timerOther2
Definition: DecompStats.h:232
void resetCutRound()
Definition: DecompStats.h:185
double bestBoundIP
The best recorded integer upper bound.
Definition: DecompStats.h:65
int varsThisRound
Number of vars generated in this round of pricing calls.
Definition: DecompStats.h:135
int phase
The phase when bound was recorded.
Definition: DecompStats.h:31
int priceCallsTotal
Number of price calls in this node in total.
Definition: DecompStats.h:155
double bestBound
The best recorded continuous lower bound.
Definition: DecompStats.h:56
std::pair< double, double > objBest
The global lower (.first) and upper (.second) bound.
Definition: DecompStats.h:120
int pricePass
The price pass when bound was recorded.
Definition: DecompStats.h:39
int priceCallsRound
Number of price calls in this round.
Definition: DecompStats.h:165
double totalCompressCols
Definition: DecompStats.h:244
double maxGenCuts
Definition: DecompStats.h:250
double maxDecomp
Definition: DecompStats.h:246
double getLastBoundThis()
Definition: DecompStats.h:205
double timeStamp
The time stamp (from start) when bound was recorded.
Definition: DecompStats.h:43
UtilTimer timerOther1
Definition: DecompStats.h:231
int cutCallsRound
Number of cut calls in this round.
Definition: DecompStats.h:160
std::vector< double > thisGenVars
Definition: DecompStats.h:261
void printOverallStats(std::ostream *os=&std::cout)
double maxSolUpdate
Definition: DecompStats.h:249
int varsThisCall
Number of vars generated in this particular price call.
Definition: DecompStats.h:145
void resetBestLB()
Definition: DecompStats.h:193
std::vector< double > thisGenCuts
Definition: DecompStats.h:259
DecompObjBound * getLastBound()
Definition: DecompStats.h:196
double thisBound
The recorded continuous lower bound.
Definition: DecompStats.h:47
void resetPriceRound()
Definition: DecompStats.h:189
double totalGenCutsApp
Definition: DecompStats.h:242
void calculateStats()
double totalSolveRelaxApp
Definition: DecompStats.h:239
double totalGenVars
Definition: DecompStats.h:243
double maxSolveRelax
Definition: DecompStats.h:247
double totalOverall
Definition: DecompStats.h:235
double totalDecomp
Definition: DecompStats.h:237