ATM_DecompApp.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-2015, Lehigh University, Matthew Galati, and Ted Ralphs//
00010 // All Rights Reserved.                                                      //
00011 //===========================================================================//
00012 
00013 #ifndef ATM_DECOMPAPP_INCLUDED
00014 #define ATM_DECOMPAPP_INCLUDED
00015 
00016 //===========================================================================//
00017 #include "DecompApp.h"
00018 //===========================================================================//
00019 #include "ATM_Param.h"
00020 #include "ATM_Instance.h"
00021 
00022 
00023 //===========================================================================//
00034 //===========================================================================//
00035 class ATM_DecompApp : public DecompApp {
00036 private:
00038    const string m_classTag;
00039 
00041    ATM_Instance m_instance;
00042  
00044    ATM_Param m_appParam;  
00045 
00047    double * m_objective;
00048 
00050    vector<DecompConstraintSet*> m_models;
00051    
00052 public:
00053    /* @name Inherited (from virtual) methods. */
00054    virtual bool APPisUserFeasible(const double * x,
00055                                   const int      nCols,
00056                                   const double   tolZero);
00057 
00058 public:
00062    void initializeApp(UtilParameters & utilParam);
00063 
00064    /* Create models. */
00065    void createModels();
00066 
00067 
00068    //create model
00069    int createConZtoX(DecompConstraintSet * model,
00070              const int             atmIndex);
00071    int createConPickOne(DecompConstraintSet * model,
00072             const int             atmIndex);
00073    int createConCount(DecompConstraintSet * model,
00074               const int             atmIndex);
00075 
00076    DecompConstraintSet * createModelCore1(bool includeCount = true);
00077    DecompConstraintSet * createModelRelax1(const int a,
00078                        bool      includeCount = true);
00079 
00080    DecompConstraintSet * createModelCore2();
00081    DecompConstraintSet * createModelRelax2(const int d);
00082 
00083    DecompConstraintSet * createModelCoreCount();
00084    DecompConstraintSet * createModelRelaxCount();
00085    
00086    //counts
00087    inline const int numCoreCols() const {
00088       //---    for a in A, d in D:
00089       //---       f+[a,d], f-[a,d] >= 0
00090       //---                f-[a,d] <= w[a,d]
00091       //---       v[a,d] in {0,1}
00092       //---    for a in A:
00093       //---       x2[a] in [0,1], x3[a] >= 0
00094       //---    for a in A, t in T
00095       //---       x1[a,t] in {0,1}, z[a,t] >= 0
00096       int nAtms  = m_instance.getNAtms();
00097       int nPairs = m_instance.getNPairs();
00098       int nCols  = (2 * (getNAtmsSteps() + nPairs + nAtms)) + nPairs;
00099       return nCols;
00100    }
00101    
00102    inline const int getNAtmsSteps() const {
00103       if(m_appParam.UseTightModel)
00104      return m_instance.getNAtms() * (m_appParam.NumSteps+1);
00105       else
00106      return m_instance.getNAtms() * m_appParam.NumSteps;
00107    }
00108    
00109    //---
00110    //--- Columns
00111    //---   x1[a,t] (binary)
00112    //---   z [a,t]
00113    //---   f+[a,d]
00114    //---   f-[a,d]
00115    //---   x2[a]
00116    //---   x3[a]
00117    //---   v[a,d] (binary)
00118    //---
00119    void createModelColumns(DecompConstraintSet * model,
00120                const int             atmIndex  = -1,
00121                            const int             dateIndex = -1);
00122 
00123    inline const int getColOffset_x1() const {
00124       return 0;
00125    }
00126    inline const int getColOffset_z() const {
00127       return getColOffset_x1() + getNAtmsSteps();
00128    }
00129    inline const int getColOffset_fp() const {
00130       return getColOffset_z() + getNAtmsSteps();
00131    }
00132    inline const int getColOffset_fm() const {
00133       return getColOffset_fp() + m_instance.getNPairs();
00134    }
00135    inline const int getColOffset_x2() const {
00136       return getColOffset_fm() + m_instance.getNPairs();
00137    }
00138    inline const int getColOffset_x3() const {
00139       return getColOffset_x2() + m_instance.getNAtms();
00140    }
00141    inline const int getColOffset_v() const {
00142       return getColOffset_x3() + m_instance.getNAtms();
00143    }
00144 
00145    inline const int colIndex_x1(const int a, const int t) const {
00146       int tLen = m_appParam.NumSteps;
00147       if(m_appParam.UseTightModel)
00148      tLen++;
00149       return getColOffset_x1() + ((a * tLen) + t);
00150    }
00151    inline const int colIndex_z(const int a, const int t) const {
00152       int tLen = m_appParam.NumSteps;
00153       if(m_appParam.UseTightModel)
00154      tLen++;
00155       return getColOffset_z() + ((a * tLen) + t);
00156    }
00157    inline const int colIndex_fp(const int pairIndex) const {
00158       return getColOffset_fp() + pairIndex;         
00159    }
00160    inline const int colIndex_fm(const int pairIndex) const {
00161       return getColOffset_fm() + pairIndex;
00162    }
00163    inline const int colIndex_x2(const int a) const {
00164       return getColOffset_x2() + a;
00165    }
00166    inline const int colIndex_x3(const int a) const {
00167       return getColOffset_x3() + a;
00168    }
00169    inline const int colIndex_v(const int pairIndex) const {
00170       return getColOffset_v() + pairIndex;         
00171    }
00172 
00173    //column names
00174    void addColumnNamesA(DecompConstraintSet * model,
00175             const string          prefix,
00176             const int             offset);
00177    void addColumnNamesAT(DecompConstraintSet * model,
00178              const string          prefix,
00179              const int             offset);
00180    void addColumnNamesAD(DecompConstraintSet * model,
00181              const string          prefix,
00182              const int             offset);
00183    
00184  
00185 public:
00189    ATM_DecompApp(UtilParameters & utilParam) : 
00190       DecompApp   (),
00191       m_classTag  ("ATM-APP"),
00192       m_objective (NULL)
00193    {
00194       initializeApp(utilParam);
00195    };
00196    
00197    virtual ~ATM_DecompApp() {
00198       //UTIL_DELARR(m_objective);
00199       UtilDeleteVectorPtr(m_models);
00200    };
00201 };
00202 
00203 #endif

Generated on 3 Jun 2015 for Dip-All by  doxygen 1.6.1