DecompStats.h

Go to the documentation of this file.
00001 //===========================================================================//
00002 // This file is part of the DIP Solver Framework.                            //
00003 //                                                                           //
00004 // DIP is distributed under the Eclipse Public License as part of the        //
00005 // COIN-OR repository (http://www.coin-or.org).                              //
00006 //                                                                           //
00007 // Author: Matthew Galati, SAS Institute Inc. (matthew.galati@sas.com)       //
00008 //                                                                           //
00009 // Conceptual Design: Matthew Galati, SAS Institute Inc.                     //
00010 //                    Ted Ralphs, Lehigh University                          //
00011 //                                                                           //
00012 // Copyright (C) 2002-2015, Lehigh University, Matthew Galati, Ted Ralphs    //
00013 // All Rights Reserved.                                                      //
00014 //===========================================================================//
00015 
00016 //===========================================================================//
00017 #ifndef DecompStats_h_
00018 #define DecompStats_h_
00019 
00020 //===========================================================================//
00021 #include "Decomp.h"
00022 #include "UtilTimer.h"
00023 //===========================================================================//
00024 
00025 //===========================================================================//
00026 class DecompObjBound {
00027 public:
00031    int phase;
00035    int cutPass;
00039    int pricePass;
00043    double timeStamp;
00047    double thisBound;
00051    double thisBoundUB;
00056    double bestBound;
00060    double thisBoundIP;
00065    double bestBoundIP;
00066 
00070    bool operator<(const DecompObjBound& objBound) const {
00071       if (timeStamp < objBound.timeStamp) {
00072          return true;
00073       } else {
00074          return false;
00075       }
00076    }
00077 
00078 public:
00079    DecompObjBound() :
00080       phase      (0),
00081       cutPass    (0),
00082       pricePass  (0),
00083       timeStamp  (0.0),
00084       thisBound  (-DecompInf),
00085       thisBoundUB( DecompInf),
00086       bestBound  (-DecompInf),
00087       thisBoundIP( DecompInf),
00088       bestBoundIP( DecompInf) {
00089    }
00090 
00091 };
00092 
00093 //===========================================================================//
00094 class DecompNodeStats {
00095 public:
00096 
00097    //---
00098    //--- Storage for the bound history for a node.
00099    //---    NOTE: we always assume a minimization problem
00100    //---
00101 
00115    std::vector< DecompObjBound > objHistoryBound;
00116 
00120    std::pair<double, double> objBest;
00121 
00125    int    nodeIndex;
00126 
00130    int    cutsThisRound;
00131 
00135    int    varsThisRound;
00136 
00140    int    cutsThisCall;
00141 
00145    int    varsThisCall;
00146 
00150    int    cutCallsTotal;
00151 
00155    int    priceCallsTotal;
00156 
00160    int    cutCallsRound;
00161 
00165    int    priceCallsRound;
00166 
00167 public:
00168    void init() {
00169       objHistoryBound.clear();
00170       objBest.first   = -DecompInf;
00171       objBest.second  =  DecompInf;
00172       nodeIndex       =  0;
00173       cutsThisRound   =  0;
00174       varsThisRound   =  0;
00175       cutsThisCall    =  0;
00176       varsThisCall    =  0;
00177       cutCallsTotal   =  0;
00178       priceCallsTotal =  0;
00179       cutCallsRound   =  0;
00180       priceCallsRound =  0;
00181    }
00182 
00183 public:
00184    void printObjHistoryBound  (std::ostream* os = &std::cout) const;
00185    inline void resetCutRound() {
00186       cutCallsRound = 0;
00187       cutsThisRound = 0;
00188    }
00189    inline void resetPriceRound() {
00190       priceCallsRound = 0;
00191       varsThisRound   = 0;
00192    }
00193    inline void resetBestLB() {
00194       objBest.first = -DecompInf;
00195    }
00196    inline DecompObjBound* getLastBound() {
00197       int nHistorySize = static_cast<int>(objHistoryBound.size());
00198 
00199       if (nHistorySize > 0) {
00200          return &(objHistoryBound[nHistorySize - 1]);
00201       } else {
00202          return 0;
00203       }
00204    }
00205    inline double getLastBoundThis() {
00206       double           thisBound = -DecompInf;
00207       DecompObjBound* lastBound = getLastBound();
00208 
00209       if (lastBound) {
00210          thisBound = lastBound->thisBound;
00211       }
00212 
00213       return thisBound;
00214    }
00215 
00216 public:
00217    DecompNodeStats() :
00218       objHistoryBound(),
00219       objBest        () {
00220       init();
00221    }
00222 };
00223 
00224 
00225 //===========================================================================//
00226 class DecompStats {
00227 
00228 public:
00229    UtilTimer timerOverall;
00230    UtilTimer timerDecomp;
00231    UtilTimer timerOther1;
00232    UtilTimer timerOther2;
00233 
00234 public:
00235    double totalOverall;
00236 
00237    double totalDecomp;
00238    double totalSolveRelax;
00239    double totalSolveRelaxApp;
00240    double totalSolUpdate;
00241    double totalGenCuts;
00242    double totalGenCutsApp;
00243    double totalGenVars;
00244    double totalCompressCols;
00245 
00246    double maxDecomp;
00247    double maxSolveRelax;
00248    double maxSolveRelaxApp;
00249    double maxSolUpdate;
00250    double maxGenCuts;
00251    double maxGenVars;
00252    double maxCompressCols;
00253 
00254 public:
00255    std::vector<double> thisDecomp;
00256    std::vector<double> thisSolveRelax;
00257    std::vector<double> thisSolveRelaxApp;
00258    std::vector<double> thisSolUpdate;
00259    std::vector<double> thisGenCuts;
00260    std::vector<double> thisGenCutsApp;
00261    std::vector<double> thisGenVars;
00262    std::vector<double> thisCompressCols;
00263 
00264 public:
00265    void calculateStats();
00266    void printOverallStats (std::ostream* os = &std::cout); //ostream?
00267    void printDetailedStats(std::ostream* os = &std::cout); //ostream?
00268 
00269 public:
00270    DecompStats() :
00271 
00272       totalOverall      (0.0),
00273 
00274       totalDecomp       (0.0),
00275       totalSolveRelax   (0.0),
00276       totalSolveRelaxApp(0.0),
00277       totalSolUpdate    (0.0),
00278       totalGenCuts      (0.0),
00279       totalGenCutsApp   (0.0),
00280       totalGenVars      (0.0),
00281       totalCompressCols (0.0),
00282 
00283       maxDecomp         (0.0),
00284       maxSolveRelax     (0.0),
00285       maxSolveRelaxApp  (0.0),
00286       maxSolUpdate      (0.0),
00287       maxGenCuts        (0.0),
00288       maxGenVars        (0.0),
00289       maxCompressCols   (0.0)
00290 
00291    {
00292    }
00293 
00294    ~DecompStats() {}
00295 
00296 };
00297 //===========================================================================//
00298 
00299 #endif
00300 

Generated on 5 Apr 2015 for Dip-All by  doxygen 1.6.1