MMKP_Param.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 MMKP_PARAM_INCLUDED
00014 #define MMKP_PARAM_INCLUDED
00015 
00016 //===========================================================================//
00017 #include "UtilMacros.h"
00018 #include "UtilMacrosDecomp.h"
00019 #include "UtilParameters.h"
00020 //===========================================================================//
00021 
00022 using namespace std;
00023 
00024 //===========================================================================//
00031 //===========================================================================//
00032 class MMKP_Param {
00033 public:
00034    int    LogLevel;           //application log level
00035    string DataDir;            //data directory
00036    string Instance;           //name of instance
00037    string DataFormat;         //format of data
00038    string ModelNameCore;      //name of model core
00039    string ModelNameRelax;     //name of model relax
00040    string ModelNameRelaxNest; //name of nested model relax
00041    bool   UsePisinger;
00042 
00043 public:
00044    void getSettings(UtilParameters & utilParam){
00045       static const char * common = "MMKP";
00046       LogLevel       = utilParam.GetSetting("LogLevel",        0,      common);
00047       DataDir        = utilParam.GetSetting("DataDir",        "",      common);
00048       Instance       = utilParam.GetSetting("Instance",       "",      common);
00049       DataFormat     = utilParam.GetSetting("DataFormat",     "",      common);
00050       ModelNameCore  = utilParam.GetSetting("ModelNameCore",  "MDKP0", common);
00051       ModelNameRelax = utilParam.GetSetting("ModelNameRelax", "MCKP0", common);
00052       ModelNameRelaxNest 
00053          = utilParam.GetSetting("ModelNameRelaxNest", "", common);
00054       UsePisinger    = utilParam.GetSetting("UsePisinger", true,  common);
00055       if(!checkOptions())
00056          throw UtilException("Bad Parameter", "getSettings", "MMKP_Param");
00057    }
00058 
00059    bool checkOptions(){
00060       bool optionsOk = true;
00061       if(!(ModelNameCore == "MDKP0" || 
00062        ModelNameCore == "MCP"   ||
00063        ModelNameCore == "MMKPHalf")){
00064          cerr << "Error: Parameter ModelNameCore = " << ModelNameCore
00065               << " is not a defined model choice." << endl;
00066          optionsOk = false;
00067       }
00068       if(!(ModelNameRelax == "MCKP0" || 
00069        ModelNameRelax == "MDKP"  ||
00070        ModelNameRelax == "MDKPHalf")){
00071          cerr << "Error: Parameter ModelNameRelax = " << ModelNameRelax
00072               << " is not a defined model choice." << endl;
00073          optionsOk = false;
00074       }
00075       if(!(ModelNameRelaxNest == "MC2KP0" || 
00076        ModelNameRelaxNest == "MDKP"   ||
00077        ModelNameRelaxNest == "MMKP"   ||
00078        ModelNameRelaxNest == "")){
00079          cerr << "Error: Parameter ModelNameRelaxNest = " 
00080               << ModelNameRelaxNest
00081               << " is not a defined model choice." << endl;
00082          optionsOk = false;
00083       }
00084       //TODO: check for bad combos too
00085       return optionsOk;
00086    }
00087 
00088    void dumpSettings(ostream * os = &cout){
00089       static const char * common = "MMKP";
00090       (*os) << "\n=====================================================\n"
00091             << "MMKP_DECOMP PARAMETER SETTINGS \n";
00092       (*os) << common << ": LogLevel          : " << LogLevel      << endl;
00093       (*os) << common << ": DataDir           : " << DataDir       << endl;
00094       (*os) << common << ": Instance          : " << Instance      << endl;
00095       (*os) << common << ": DataFormat        : " << DataFormat    << endl;
00096       (*os) << common << ": ModelNameCore     : " << ModelNameCore     << endl;
00097       (*os) << common << ": ModelNameRelax    : " << ModelNameRelax    << endl;
00098       (*os) << common << ": ModelNameRelaxNest: " << ModelNameRelaxNest<< endl;
00099       (*os) << common << ": UsePisinger       : " << UsePisinger       << endl;
00100       (*os) <<   "=====================================================\n";
00101    }
00102    
00103 public:
00104    MMKP_Param() :
00105       LogLevel          (0),
00106       DataDir           (""),
00107       Instance          (""),                   
00108       DataFormat        ("hifi"),//hifi, khan, or gsimon
00109       ModelNameCore     ("MDKP0"),
00110       ModelNameRelax    ("MCKP0"),
00111       ModelNameRelaxNest(""     ),
00112       UsePisinger       (true   ){}
00113    ~MMKP_Param() {};
00114 };
00115 
00116 #endif

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