Dip  0.92.4
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 // Authors: Matthew Galati, SAS Institute Inc. (matthew.galati@sas.com) //
8 // Ted Ralphs, Lehigh University (ted@lehigh.edu) //
9 // Jiadong Wang, Lehigh University (jiw408@lehigh.edu) //
10 // //
11 // Copyright (C) 2002-2019, Lehigh University, Matthew Galati, and Ted Ralphs//
12 // All Rights Reserved. //
13 //===========================================================================//
14 
15 #ifndef MMKP_PARAM_INCLUDED
16 #define MMKP_PARAM_INCLUDED
17 
18 //===========================================================================//
19 #include "UtilMacros.h"
20 #include "UtilMacrosDecomp.h"
21 #include "UtilParameters.h"
22 //===========================================================================//
23 
24 using namespace std;
25 
26 //===========================================================================//
33 //===========================================================================//
34 class MMKP_Param {
35 public:
36  int LogLevel; //application log level
37  string DataDir; //data directory
38  string Instance; //name of instance
39  string DataFormat; //format of data
40  string ModelNameCore; //name of model core
41  string ModelNameRelax; //name of model relax
42  string ModelNameRelaxNest; //name of nested model relax
44 
45 public:
46  void getSettings(UtilParameters & utilParam){
47  static const char * common = "MMKP";
48  LogLevel = utilParam.GetSetting("LogLevel", 0, common);
49  DataDir = utilParam.GetSetting("DataDir", "", common);
50  Instance = utilParam.GetSetting("Instance", "", common);
51  DataFormat = utilParam.GetSetting("DataFormat", "", common);
52  ModelNameCore = utilParam.GetSetting("ModelNameCore", "MDKP0", common);
53  ModelNameRelax = utilParam.GetSetting("ModelNameRelax", "MCKP0", common);
54  ModelNameRelaxNest
55  = utilParam.GetSetting("ModelNameRelaxNest", "", common);
56  UsePisinger = utilParam.GetSetting("UsePisinger", true, common);
57  if(!checkOptions())
58  throw UtilException("Bad Parameter", "getSettings", "MMKP_Param");
59  }
60 
61  bool checkOptions(){
62  bool optionsOk = true;
63  if(!(ModelNameCore == "MDKP0" ||
64  ModelNameCore == "MCP" ||
65  ModelNameCore == "MMKPHalf")){
66  cerr << "Error: Parameter ModelNameCore = " << ModelNameCore
67  << " is not a defined model choice." << endl;
68  optionsOk = false;
69  }
70  if(!(ModelNameRelax == "MCKP0" ||
71  ModelNameRelax == "MDKP" ||
72  ModelNameRelax == "MDKPHalf")){
73  cerr << "Error: Parameter ModelNameRelax = " << ModelNameRelax
74  << " is not a defined model choice." << endl;
75  optionsOk = false;
76  }
77  if(!(ModelNameRelaxNest == "MC2KP0" ||
78  ModelNameRelaxNest == "MDKP" ||
79  ModelNameRelaxNest == "MMKP" ||
80  ModelNameRelaxNest == "")){
81  cerr << "Error: Parameter ModelNameRelaxNest = "
82  << ModelNameRelaxNest
83  << " is not a defined model choice." << endl;
84  optionsOk = false;
85  }
86  //TODO: check for bad combos too
87  return optionsOk;
88  }
89 
90  void dumpSettings(ostream * os = &cout){
91  static const char * common = "MMKP";
92  (*os) << "\n=====================================================\n"
93  << "MMKP_DECOMP PARAMETER SETTINGS \n";
94  (*os) << common << ": LogLevel : " << LogLevel << endl;
95  (*os) << common << ": DataDir : " << DataDir << endl;
96  (*os) << common << ": Instance : " << Instance << endl;
97  (*os) << common << ": DataFormat : " << DataFormat << endl;
98  (*os) << common << ": ModelNameCore : " << ModelNameCore << endl;
99  (*os) << common << ": ModelNameRelax : " << ModelNameRelax << endl;
100  (*os) << common << ": ModelNameRelaxNest: " << ModelNameRelaxNest<< endl;
101  (*os) << common << ": UsePisinger : " << UsePisinger << endl;
102  (*os) << "=====================================================\n";
103  }
104 
105 public:
107  LogLevel (0),
108  DataDir (""),
109  Instance (""),
110  DataFormat ("hifi"),//hifi, khan, or gsimon
111  ModelNameCore ("MDKP0"),
112  ModelNameRelax ("MCKP0"),
113  ModelNameRelaxNest("" ),
114  UsePisinger (true ){}
116 };
117 
118 #endif
void getSettings(UtilParameters &utilParam)
Definition: MMKP_Param.h:46
string DataDir
Definition: MMKP_Param.h:37
string GetSetting(const char *name, const char *defaultValue, const char *section=NULL)
bool UsePisinger
Definition: MMKP_Param.h:43
string ModelNameRelax
Definition: MMKP_Param.h:41
string ModelNameCore
Definition: MMKP_Param.h:40
string DataFormat
Definition: MMKP_Param.h:39
void dumpSettings(ostream *os=&cout)
Definition: MMKP_Param.h:90
string ModelNameRelaxNest
Definition: MMKP_Param.h:42
string Instance
Definition: MMKP_Param.h:38
#define UtilException(msg, methodN, classN)
int LogLevel
Definition: MMKP_Param.h:36
bool checkOptions()
Definition: MMKP_Param.h:61