Dip  0.95.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 // 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 
DecompStats::timerDecomp
UtilTimer timerDecomp
Definition: DecompStats.h:235
DecompStats::thisGenVars
std::vector< double > thisGenVars
Definition: DecompStats.h:266
COIN_DBL_MAX
const double COIN_DBL_MAX
DecompNodeStats::varsThisRound
int varsThisRound
Number of vars generated in this round of pricing calls.
Definition: DecompStats.h:134
DecompStats::timerOverall
UtilTimer timerOverall
Definition: DecompStats.h:234
DecompNodeStats::resetPriceRound
void resetPriceRound()
Definition: DecompStats.h:193
DecompStats::maxSolveRelax
double maxSolveRelax
Definition: DecompStats.h:252
DecompNodeStats::cutCallsTotal
int cutCallsTotal
Number of cut calls in this node in total.
Definition: DecompStats.h:149
DecompStats
Definition: DecompStats.h:231
DecompStats::maxDecomp
double maxDecomp
Definition: DecompStats.h:251
DecompObjBound::timeStamp
double timeStamp
The time stamp (from start) when bound was recorded.
Definition: DecompStats.h:42
DecompNodeStats::resetCutRound
void resetCutRound()
Definition: DecompStats.h:189
DecompNodeStats::objBest
std::pair< double, double > objBest
The global lower (.first) and upper (.second) bound.
Definition: DecompStats.h:119
DecompStats::totalGenCutsApp
double totalGenCutsApp
Definition: DecompStats.h:247
DecompNodeStats::DecompNodeStats
DecompNodeStats()
Definition: DecompStats.h:221
DecompStats::timerOther2
UtilTimer timerOther2
Definition: DecompStats.h:237
UtilTimer.h
DecompNodeStats
Definition: DecompStats.h:93
DecompStats::thisDecomp
std::vector< double > thisDecomp
Definition: DecompStats.h:260
DecompStats::thisCompressCols
std::vector< double > thisCompressCols
Definition: DecompStats.h:267
DecompStats::timerOther1
UtilTimer timerOther1
Definition: DecompStats.h:236
DecompNodeStats::m_infinity
double m_infinity
Value of infinity.
Definition: DecompStats.h:169
Decomp.h
DecompObjBound::bestBoundIP
double bestBoundIP
The best recorded integer upper bound.
Definition: DecompStats.h:64
DecompObjBound::thisBoundIP
double thisBoundIP
The recorded integer upper bound.
Definition: DecompStats.h:59
DecompStats::totalGenVars
double totalGenVars
Definition: DecompStats.h:248
DecompStats::thisSolveRelaxApp
std::vector< double > thisSolveRelaxApp
Definition: DecompStats.h:262
DecompStats::maxCompressCols
double maxCompressCols
Definition: DecompStats.h:257
UtilTimer
Definition: UtilTimer.h:23
DecompObjBound::pricePass
int pricePass
The price pass when bound was recorded.
Definition: DecompStats.h:38
DecompObjBound::thisBoundUB
double thisBoundUB
The recorded continuous upper bound.
Definition: DecompStats.h:50
DecompStats::~DecompStats
~DecompStats()
Definition: DecompStats.h:299
DecompObjBound::cutPass
int cutPass
The cut pass when bound was recorded.
Definition: DecompStats.h:34
DecompStats::totalDecomp
double totalDecomp
Definition: DecompStats.h:242
DecompNodeStats::cutsThisRound
int cutsThisRound
Number of cuts generated in this round of cut calls.
Definition: DecompStats.h:129
DecompStats::printOverallStats
void printOverallStats(std::ostream *os=&std::cout)
DecompNodeStats::priceCallsTotal
int priceCallsTotal
Number of price calls in this node in total.
Definition: DecompStats.h:154
DecompStats::calculateStats
void calculateStats()
DecompObjBound
Definition: DecompStats.h:25
DecompStats::totalSolveRelaxApp
double totalSolveRelaxApp
Definition: DecompStats.h:244
DecompStats::printDetailedStats
void printDetailedStats(std::ostream *os=&std::cout)
DecompObjBound::phase
int phase
The phase when bound was recorded.
Definition: DecompStats.h:30
DecompObjBound::DecompObjBound
DecompObjBound(double infinity)
Definition: DecompStats.h:78
DecompNodeStats::cutCallsRound
int cutCallsRound
Number of cut calls in this round.
Definition: DecompStats.h:159
DecompNodeStats::resetBestLB
void resetBestLB()
Definition: DecompStats.h:197
DecompStats::totalSolUpdate
double totalSolUpdate
Definition: DecompStats.h:245
DecompNodeStats::priceCallsRound
int priceCallsRound
Number of price calls in this round.
Definition: DecompStats.h:164
DecompNodeStats::varsThisCall
int varsThisCall
Number of vars generated in this particular price call.
Definition: DecompStats.h:144
DecompStats::totalCompressCols
double totalCompressCols
Definition: DecompStats.h:249
DecompNodeStats::objHistoryBound
std::vector< DecompObjBound > objHistoryBound
Storage of the bounds.
Definition: DecompStats.h:114
DecompObjBound::operator<
bool operator<(const DecompObjBound &objBound) const
Comparison operator for sorting on time.
Definition: DecompStats.h:69
DecompObjBound::bestBound
double bestBound
The best recorded continuous lower bound.
Definition: DecompStats.h:55
DecompStats::maxSolveRelaxApp
double maxSolveRelaxApp
Definition: DecompStats.h:253
DecompNodeStats::nodeIndex
int nodeIndex
The node index (in the branch-and-bound tree).
Definition: DecompStats.h:124
DecompStats::maxSolUpdate
double maxSolUpdate
Definition: DecompStats.h:254
DecompStats::DecompStats
DecompStats()
Definition: DecompStats.h:275
DecompStats::thisSolUpdate
std::vector< double > thisSolUpdate
Definition: DecompStats.h:263
DecompStats::thisGenCutsApp
std::vector< double > thisGenCutsApp
Definition: DecompStats.h:265
DecompStats::thisSolveRelax
std::vector< double > thisSolveRelax
Definition: DecompStats.h:261
DecompNodeStats::cutsThisCall
int cutsThisCall
Number of cuts generated in this particular cut call.
Definition: DecompStats.h:139
DecompObjBound::thisBound
double thisBound
The recorded continuous lower bound.
Definition: DecompStats.h:46
DecompStats::totalSolveRelax
double totalSolveRelax
Definition: DecompStats.h:243
DecompNodeStats::getLastBound
DecompObjBound * getLastBound()
Definition: DecompStats.h:200
DecompNodeStats::getLastBoundThis
double getLastBoundThis()
Definition: DecompStats.h:209
DecompStats::thisGenCuts
std::vector< double > thisGenCuts
Definition: DecompStats.h:264
DecompStats::totalGenCuts
double totalGenCuts
Definition: DecompStats.h:246
DecompStats::totalOverall
double totalOverall
Definition: DecompStats.h:240
DecompStats::maxGenVars
double maxGenVars
Definition: DecompStats.h:256
DecompStats::maxGenCuts
double maxGenCuts
Definition: DecompStats.h:255
DecompNodeStats::init
void init()
Definition: DecompStats.h:172
DecompNodeStats::printObjHistoryBound
void printObjHistoryBound(std::ostream *os=&std::cout) const