Dip-All  0.91.0
MMKP_Param.h
Go to the documentation of this file.
1 //===========================================================================//
2 // This file is part of the Decomp Solver Framework. //
3 // //
4 // Decomp is distributed under the Common Public License as part of the //
5 // COIN-OR repository (http://www.coin-or.org). //
6 // //
7 // Author: Matthew Galati, Lehigh University //
8 // //
9 // Copyright (C) 2002-2015, Lehigh University, Matthew Galati, and Ted Ralphs//
10 // All Rights Reserved. //
11 //===========================================================================//
12 
13 #ifndef MMKP_PARAM_INCLUDED
14 #define MMKP_PARAM_INCLUDED
15 
16 //===========================================================================//
17 #include "UtilMacros.h"
18 #include "UtilMacrosDecomp.h"
19 #include "UtilParameters.h"
20 //===========================================================================//
21 
22 using namespace std;
23 
24 //===========================================================================//
31 //===========================================================================//
32 class MMKP_Param {
33 public:
34  int LogLevel; //application log level
35  string DataDir; //data directory
36  string Instance; //name of instance
37  string DataFormat; //format of data
38  string ModelNameCore; //name of model core
39  string ModelNameRelax; //name of model relax
40  string ModelNameRelaxNest; //name of nested model relax
42 
43 public:
44  void getSettings(UtilParameters & utilParam){
45  static const char * common = "MMKP";
46  LogLevel = utilParam.GetSetting("LogLevel", 0, common);
47  DataDir = utilParam.GetSetting("DataDir", "", common);
48  Instance = utilParam.GetSetting("Instance", "", common);
49  DataFormat = utilParam.GetSetting("DataFormat", "", common);
50  ModelNameCore = utilParam.GetSetting("ModelNameCore", "MDKP0", common);
51  ModelNameRelax = utilParam.GetSetting("ModelNameRelax", "MCKP0", common);
52  ModelNameRelaxNest
53  = utilParam.GetSetting("ModelNameRelaxNest", "", common);
54  UsePisinger = utilParam.GetSetting("UsePisinger", true, common);
55  if(!checkOptions())
56  throw UtilException("Bad Parameter", "getSettings", "MMKP_Param");
57  }
58 
59  bool checkOptions(){
60  bool optionsOk = true;
61  if(!(ModelNameCore == "MDKP0" ||
62  ModelNameCore == "MCP" ||
63  ModelNameCore == "MMKPHalf")){
64  cerr << "Error: Parameter ModelNameCore = " << ModelNameCore
65  << " is not a defined model choice." << endl;
66  optionsOk = false;
67  }
68  if(!(ModelNameRelax == "MCKP0" ||
69  ModelNameRelax == "MDKP" ||
70  ModelNameRelax == "MDKPHalf")){
71  cerr << "Error: Parameter ModelNameRelax = " << ModelNameRelax
72  << " is not a defined model choice." << endl;
73  optionsOk = false;
74  }
75  if(!(ModelNameRelaxNest == "MC2KP0" ||
76  ModelNameRelaxNest == "MDKP" ||
77  ModelNameRelaxNest == "MMKP" ||
78  ModelNameRelaxNest == "")){
79  cerr << "Error: Parameter ModelNameRelaxNest = "
80  << ModelNameRelaxNest
81  << " is not a defined model choice." << endl;
82  optionsOk = false;
83  }
84  //TODO: check for bad combos too
85  return optionsOk;
86  }
87 
88  void dumpSettings(ostream * os = &cout){
89  static const char * common = "MMKP";
90  (*os) << "\n=====================================================\n"
91  << "MMKP_DECOMP PARAMETER SETTINGS \n";
92  (*os) << common << ": LogLevel : " << LogLevel << endl;
93  (*os) << common << ": DataDir : " << DataDir << endl;
94  (*os) << common << ": Instance : " << Instance << endl;
95  (*os) << common << ": DataFormat : " << DataFormat << endl;
96  (*os) << common << ": ModelNameCore : " << ModelNameCore << endl;
97  (*os) << common << ": ModelNameRelax : " << ModelNameRelax << endl;
98  (*os) << common << ": ModelNameRelaxNest: " << ModelNameRelaxNest<< endl;
99  (*os) << common << ": UsePisinger : " << UsePisinger << endl;
100  (*os) << "=====================================================\n";
101  }
102 
103 public:
105  LogLevel (0),
106  DataDir (""),
107  Instance (""),
108  DataFormat ("hifi"),//hifi, khan, or gsimon
109  ModelNameCore ("MDKP0"),
110  ModelNameRelax ("MCKP0"),
111  ModelNameRelaxNest("" ),
112  UsePisinger (true ){}
114 };
115 
116 #endif
void getSettings(UtilParameters &utilParam)
Definition: MMKP_Param.h:44
string DataDir
Definition: MMKP_Param.h:35
string GetSetting(const char *name, const char *defaultValue, const char *section=NULL)
bool UsePisinger
Definition: MMKP_Param.h:41
string ModelNameRelax
Definition: MMKP_Param.h:39
string ModelNameCore
Definition: MMKP_Param.h:38
string DataFormat
Definition: MMKP_Param.h:37
void dumpSettings(ostream *os=&cout)
Definition: MMKP_Param.h:88
string ModelNameRelaxNest
Definition: MMKP_Param.h:40
string Instance
Definition: MMKP_Param.h:36
#define UtilException(msg, methodN, classN)
int LogLevel
Definition: MMKP_Param.h:34
bool checkOptions()
Definition: MMKP_Param.h:59