ATM_Instance.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-2013, Lehigh University, Matthew Galati, and Ted Ralphs//
00010 // All Rights Reserved.                                                      //
00011 //===========================================================================//
00012 
00013 #ifndef ATM_INSTANCE_INCLUDED
00014 #define ATM_INSTANCE_INCLUDED
00015 
00016 // --------------------------------------------------------------------- //
00017 #include "UtilMacros.h"
00018 
00019 using namespace std;
00020 
00021 // --------------------------------------------------------------------- //
00022 
00049 // --------------------------------------------------------------------- //
00050 class ATM_Instance {
00051 
00052 private:
00054    int                 m_nAtms;         //number of atms  (20  of these)
00055    int                 m_nDates;        //number of dates (272 of these)
00056    map<string, int>    m_strToIntAtms;  //map from name to index (atms)
00057    map<string, int>    m_strToIntDates; //map from date to index (dates)
00058    vector<string>      m_intToStrAtms;  //map from index to name (atms)
00059    vector<string>      m_intToStrDates; //map from index to date (dates)
00060    vector<int>         m_pairsAD;       //pairs of indices with observations
00061 
00062    double            * m_a_ad;          //a[a,d]
00063    double            * m_b_ad;          //b[a,d]
00064    double            * m_c_ad;          //c[a,d]
00065    double            * m_d_ad;          //d[a,d]
00066    double            * m_e_ad;          //e[a,d]
00067    double            * m_w_ad;          //w[a,d]
00068    double            * m_B_d;           //B[d]
00069    double            * m_K_a;           //K[a]
00070 
00071 public:
00073    inline const int    getNAtms    ()  const {return m_nAtms; }
00074    inline const int    getNDates   ()  const {return m_nDates;}
00075    inline const int    getNPairs   ()  const {
00076       return static_cast<int>(m_pairsAD.size());
00077    }
00078    inline const vector<int> & getPairsAD() const {
00079       return m_pairsAD;
00080    }
00081    inline const int getIndexAD(int a, int d) const {
00082       return a * m_nDates + d;
00083    }
00084    inline const pair<int,int> getIndexADInv(int ad) const {
00085       return make_pair(ad / m_nDates, ad % m_nDates);
00086    }
00087    inline const double * get_a_ad() const {return m_a_ad;}
00088    inline const double * get_b_ad() const {return m_b_ad;}
00089    inline const double * get_c_ad() const {return m_c_ad;}
00090    inline const double * get_d_ad() const {return m_d_ad;}
00091    inline const double * get_e_ad() const {return m_e_ad;}
00092    inline const double * get_w_ad() const {return m_w_ad;}
00093    inline const double * get_B_d()  const {return m_B_d;}
00094    inline const double * get_K_a()  const {return m_K_a;}
00095    inline const string & getAtmName(const int a) const{
00096       return m_intToStrAtms[a];
00097    }
00098    inline const string & getDateName(const int d) const{
00099       return m_intToStrDates[d];
00100    }
00101 
00102    
00103 public:
00105    void readInstance(string & fileNameA,
00106              string & fileNameD,
00107              string & fileNameAD);
00108    void generateRandom(const int nAtms,
00109                const int nDates,
00110                const int seed);
00111    void initMembers(){
00112       m_nAtms = 0;
00113       m_nDates= 0;
00114       m_a_ad  = NULL;
00115       m_b_ad  = NULL;
00116       m_c_ad  = NULL;
00117       m_d_ad  = NULL;
00118       m_e_ad  = NULL;
00119       m_w_ad  = NULL;
00120       m_B_d   = NULL;
00121       m_K_a   = NULL;
00122    }
00123 
00124 public:
00128    ATM_Instance(){initMembers();};
00129  
00130  ATM_Instance(string & fileNameA,
00131               string & fileNameD,
00132               string & fileNameAD)
00133    {
00134       initMembers();
00135       readInstance(fileNameA,
00136            fileNameD,
00137            fileNameAD);
00138    }
00139    
00140    ~ATM_Instance() {
00141       UTIL_DELARR(m_a_ad);
00142       UTIL_DELARR(m_b_ad);
00143       UTIL_DELARR(m_c_ad);
00144       UTIL_DELARR(m_d_ad);
00145       UTIL_DELARR(m_e_ad);
00146       UTIL_DELARR(m_w_ad);
00147       UTIL_DELARR(m_B_d);
00148       UTIL_DELARR(m_K_a);
00149    };
00150 };
00151 
00152 #endif

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