DecompCut.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-2013, Lehigh University, Matthew Galati, Ted Ralphs    //
00013 // All Rights Reserved.                                                      //
00014 //===========================================================================//
00015 
00016 
00017 #ifndef DECOMP_CUT_INCLUDED
00018 #define DECOMP_CUT_INCLUDED
00019 
00020 //a cut in terms of the original x variables
00021 
00022 //by default it could look for OSI-CGL cuts? for CP procedures
00023 //or the user can provide its own cut generator - force them to return
00024 //a common cut structure?
00025 
00026 //the user might have some compact way to store its cut, for example
00027 //with TSP cuts, they just want to store the customer set, and then
00028 //they override a function called expandCutToRow which tells this base
00029 //class how to expand into the LP
00030 
00031 #include "Decomp.h"
00032 #include "UtilHash.h"
00033 #include "UtilMacros.h"
00034 
00035 class DecompCut {
00036 private:
00037    double           m_lb;        //row lower bound
00038    double           m_ub;        //row upper bound
00039    //THINK, or they can stick in as sense/rhs
00040    double           m_violation; //current violation
00041    int              m_effCnt;    //effectiveness counter
00042 
00043 protected:
00044    std::string           m_strHash;
00045    //TODO - use distance instead of violation? see SAS
00046 
00047 public:
00048    inline double    getLowerBound()   const {
00049       return m_lb;
00050    }
00051    inline double    getUpperBound()   const {
00052       return m_ub;
00053    }
00054    inline double    getViolation()    const {
00055       return m_violation;
00056    }
00057    inline int       getEffCnt()       const {
00058       return m_effCnt;
00059    }
00060    inline std::string    getStrHash()      const {
00061       return m_strHash;
00062    }
00063 
00064 public:
00065    inline void      setLowerBound(const double lb) {
00066       m_lb = lb;
00067    }
00068    inline void      setUpperBound(const double ub) {
00069       m_ub = ub;
00070    }
00071    inline void      setViolation(const double violation) {
00072       m_violation = violation;
00073    }
00074 
00075    bool calcViolation(const CoinPackedVector* row,
00076                       const double*              x);
00077 
00078 public:
00079    //but these should be optional to user! after they show us how to
00080    //expandCutToRow... then we should be able to handle the hashing and
00081    //checking isSame, etc... the user can override it, if they can do it
00082    //faster - but we should not force them
00083 
00084    //now it is essentially a DecompCutOsi
00085    virtual void     setStringHash(CoinPackedVector* row) {
00086       //the user can override this if they can do it faster... also
00087       //should link up with isSame
00088       char sense;
00089       double rhs, range;
00090       UtilBoundToSense(getLowerBound(),
00091                        getUpperBound(), DecompInf,
00092                        sense, rhs, range);
00093       m_strHash = UtilCreateStringHash(row->getNumElements(),
00094                                        row->getIndices(),
00095                                        row->getElements(),
00096                                        sense, rhs);
00097       //need backup for user
00098       //throw CoinError("Method was invoked but not overridden.",
00099       //            "setStringHash", "DecompCut");1
00100    }
00101 
00102    virtual void     expandCutToRow(CoinPackedVector* row) {
00103       throw CoinError("Method was invoked but not overridden.",
00104                       "expandCutToRow", "DecompCut");
00105    }
00106 
00107    virtual void     setBounds() {
00108       throw CoinError("Method was invoked but not overridden.",
00109                       "setBounds", "DecompCut");
00110    }
00111 
00112    virtual bool     isSame(const DecompCut* cut) const {
00113       return false;
00114    }
00115 
00116    virtual void     print(std::ostream* os = &std::cout) const;
00117 
00118 public:
00119    inline void resetEffCnt() {
00120       m_effCnt = 0;
00121    }
00122 
00125    inline void increaseEffCnt() {
00126       m_effCnt = m_effCnt <= 0 ? 1 : m_effCnt + 1;
00127    }
00128 
00131    inline void decreaseEffCnt() {
00132       m_effCnt = m_effCnt >= 0 ? -1 : m_effCnt - 1;
00133    }
00134 
00135 public:
00136    DecompCut() :
00137       m_lb       (0.0),
00138       m_ub       (0.0),
00139       m_violation(0.0),
00140       m_effCnt   (0),
00141       m_strHash  () {
00142    };
00143    virtual ~DecompCut() {};
00144 
00145 };
00146 
00147 #endif

Generated on 12 Feb 2015 for Dip-All by  doxygen 1.6.1