GAP_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 GAP_DECOMPAPP_INCLUDED
00014 #define GAP_DECOMPAPP_INCLUDED
00015 
00016 // --------------------------------------------------------------------- //
00017 #include "DecompApp.h"
00018 
00019 // --------------------------------------------------------------------- //
00020 #include "GAP_Instance.h"
00021 #include "GAP_KnapPisinger.h"
00022 #include "GAP_DecompParam.h"
00023 
00024 // --------------------------------------------------------------------- //
00035 // --------------------------------------------------------------------- //
00036 class GAP_DecompApp : public DecompApp {
00037 private:
00039    const string m_classTag;
00040 
00042    GAP_Instance m_instance;
00043 
00045    GAP_DecompParam m_appParam;
00046 
00048    vector<GAP_KnapPisinger*> m_knap;
00049 
00051    double* m_objective;
00052 
00055    map<string, DecompConstraintSet*> m_models;
00056 
00057 
00058 public:
00059    /* @name Inherited (from virtual) methods. */
00061    DecompSolverStatus solveRelaxed(const int             whichBlock,
00062                                    const double*         redCostX,
00063                    const double          target,
00064                                    list<DecompVar*>&     vars);
00065 
00067    void printOriginalColumn(const int   index,
00068                             ostream*    os = &cout) const;
00069 
00070 public:
00074    void initializeApp(UtilParameters& utilParam);
00075 
00077    inline const int getOffsetI(const int i) const {
00078       return i * m_instance.getNTasks();
00079    }
00080    inline const int getIndexIJ(const int i,
00081                                const int j) const {
00082       return (i * m_instance.getNTasks()) + j;
00083    }
00084 
00085    inline pair<int, int> getIndexInv(const int index) const {
00086       return make_pair(index / m_instance.getNTasks(),
00087                        index % m_instance.getNTasks());
00088    }
00089 
00091    int createModels();
00092    int createModelPartAP(DecompConstraintSet* model);
00093 
00094 public:
00095    inline const GAP_Instance& getInstance() const {
00096       return m_instance;
00097    }
00098    inline const GAP_DecompParam& getParam() const {
00099       return m_appParam;
00100    }
00101    inline const double* getObjective() const {
00102       return m_objective;
00103    }
00104    inline DecompConstraintSet* getModel(string modelName) const {
00105       map<string, DecompConstraintSet*>::const_iterator it;
00106       it = m_models.find(modelName);
00107 
00108       if (it == m_models.end()) {
00109          cout << "Error: model with name " << modelName << " not defined."
00110               << endl;
00111          assert(it != m_models.end());
00112          return NULL;
00113       }
00114 
00115       return it->second;
00116    }
00117 
00118 
00119 public:
00123    GAP_DecompApp(UtilParameters& utilParam) :
00124       DecompApp   (),
00125       m_classTag  ("GAP-APP"),
00126       m_objective (NULL) {
00127       initializeApp(utilParam);
00128    }
00129 
00130    virtual ~GAP_DecompApp() {
00131       UtilDeleteVectorPtr(m_knap);
00132       //UTIL_DELARR(m_objective);
00133       UtilDeleteMapPtr(m_models);
00134    };
00135 };
00136 
00137 #endif

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