DecompVar.h

Go to the documentation of this file.
00001 //===========================================================================//
00002 // This file is part of the Decomp Solver Framework.                         //
00003 //                                                                           //
00004 // Decomp is distributed under the Common Public License as part of the      //
00005 // COIN-OR repository (http://www.coin-or.org).                              //
00006 //                                                                           //
00007 // Author: Matthew Galati, Lehigh University                                 //
00008 //                                                                           //
00009 // Copyright (C) 2002-2007, Lehigh University, Matthew Galati, and Ted Ralphs//
00010 // All Rights Reserved.                                                      //
00011 //===========================================================================//
00012 
00013 //this is a lambda_s variable
00014 //assumption throughout is lambda is {0,1}
00015 
00016 #ifndef DECOMP_VAR_INCLUDED
00017 #define DECOMP_VAR_INCLUDED
00018 
00019 #include "DecompPortable.h"
00020 #include "UtilHash.h"
00021 
00022 #include <iostream>
00023 using namespace std;
00024 
00025 class DecompApp;
00026 
00027 // --------------------------------------------------------------------- //
00028 class DecompVar {
00029 private:
00030    DecompVar(const DecompVar&);
00031    DecompVar& operator=(const DecompVar&);
00032 
00033 public:
00034    //THINK: or user overriden way to store it (like a tree)
00035    //and a function which says expandVarToCol - just as in cuts
00036    CoinPackedVector m_s;//this is the var in terms of x-space
00037 
00038 private:
00039    //TODO: lb, ub, "type"?
00040    double           m_origCost;
00041    double           m_redCost; //(c - uA'')s - alpha
00042    int              m_effCnt;  //effectiveness counter
00043    string           m_strHash;
00044 
00045 public:
00046    inline double getOriginalCost()  const {
00047       return m_origCost;
00048    }
00049    inline double getReducedCost()   const {
00050       return m_redCost;
00051    }
00052    inline double getEffectiveness() const {
00053       return m_effCnt;
00054    }
00055    inline double getLowerBound()    const {
00056       return 0.0;         //TODO
00057    }
00058    inline double getUpperBound()    const {
00059       return DecompInf;   //TODO
00060    }
00061    inline string getStrHash()       const {
00062       return m_strHash;
00063    }
00064 
00065    inline void   setReducedCost(const double redCost) {
00066       m_redCost = redCost;
00067    }
00068    bool   isEquivalent(const DecompVar& dvar) {
00069       return m_s.isEquivalent(dvar.m_s);
00070    }
00071 
00072    void fillDenseArr(int      len,
00073                      double* arr);
00074 
00075 public:
00076    virtual void  print(ostream*    os  = &cout,
00077                        DecompApp* app = 0) const;
00078 
00079 public:
00080    DecompVar(const vector<int>    & ind,
00081              const vector<double> & els,
00082              const double           redCost,
00083              const double           origCost) :
00084       m_s       (),
00085       m_origCost(origCost),
00086       m_redCost (redCost),
00087       m_effCnt  (0),
00088       m_strHash () {
00089       if (ind.size() > 0) {
00090          m_s.setVector(static_cast<int>(ind.size()),
00091                        &ind[0], &els[0], DECOMP_TEST_DUPINDEX);
00092          m_strHash = UtilCreateStringHash(static_cast<int>(ind.size()),
00093                                           &ind[0], &els[0]);
00094       }
00095    }
00096 
00097    DecompVar(const int              len,
00098              const int*             ind,
00099              const double*          els,
00100              const double           redCost,
00101              const double           origCost) :
00102       m_s       (),
00103       m_origCost(origCost),
00104       m_redCost (redCost),
00105       m_effCnt  (0),
00106       m_strHash () {
00107       if (len > 0) {
00108          m_s.setVector(len, ind, els, DECOMP_TEST_DUPINDEX);
00109          m_strHash = UtilCreateStringHash(len, ind, els);
00110       }
00111    }
00112 
00113    DecompVar(const int              denseLen,
00114              const double*          denseArray,
00115              const double           redCost,
00116              const double           origCost) :
00117       m_s       (DECOMP_TEST_DUPINDEX),
00118       m_origCost(origCost),
00119       m_redCost (redCost),
00120       m_effCnt  (0),
00121       m_strHash () {
00122       UtilPackedVectorFromDense(denseLen, denseArray, DecompEpsilon, m_s);
00123 
00124       if (m_s.getNumElements() > 0) {
00125          m_strHash = UtilCreateStringHash(denseLen, denseArray);
00126       }
00127    }
00128 
00129    virtual ~DecompVar() {};
00130 };
00131 
00132 #endif

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