Mungojerrie  1.0
Mungojerrie
CommandLineOptions.hh
Go to the documentation of this file.
1 #ifndef COMMAND_LINE_OPTIONS_HH_
2 #define COMMAND_LINE_OPTIONS_HH_
3 
46 #include <boost/program_options.hpp>
47 #include <string>
48 #include <vector>
49 
50 #include "Verbosity.hh"
51 #include "ModelOptions.hh"
52 #include "Gym.hh"
53 
58 
59 public:
60 
65 
69  int parseCommandLineOptions(int argc, char * argv[]);
70 
75  boost::program_options::variables_map & options() { return varMap; }
76 
77  boost::program_options::variables_map const & options() const
78  { return varMap; }
79 
83  std::string const & inputFile() const { return inputFileName; }
84 
88  Verbosity::Level verbosity() const { return (Verbosity::Level) verbosityLevel;
89 }
90 
91  ModelOptions::ReachType reachSolver() const {
92  if (varMap["reach-with"].as<std::string>() == std::string("glop"))
93  return ModelOptions::ReachType::glop;
94  if (varMap["reach-with"].as<std::string>() == std::string("iter"))
95  return ModelOptions::ReachType::iter;
96  throw std::out_of_range("Invalid solver type");
97  }
98 
99  ModelOptions::SSPType sspSolver() const {
100  if (varMap["ssp-with"].as<std::string>() == std::string("glop"))
101  return ModelOptions::SSPType::glop;
102  if (varMap["ssp-with"].as<std::string>() == std::string("iter"))
103  return ModelOptions::SSPType::iter;
104  if (varMap["ssp-with"].as<std::string>() == std::string("poly"))
105  return ModelOptions::SSPType::poly;
106  throw std::out_of_range("Invalid solver type");
107  }
108 
109  void fillModelOptions(ModelOptions & m) const;
110 
111  bool learnEnabled() const {
112  if (varMap["learn"].as<std::string>() != std::string("none"))
113  return true;
114  else
115  return false;
116  }
117 
118  bool QEnabled() const {
119  if (varMap["learn"].as<std::string>() == std::string("Q"))
120  return true;
121  else
122  return false;
123  }
124 
125  bool DQEnabled() const {
126  if (varMap["learn"].as<std::string>() == std::string("DQ"))
127  return true;
128  else
129  return false;
130  }
131 
132  bool SLEnabled() const {
133  if (varMap["learn"].as<std::string>() == std::string("SL"))
134  return true;
135  else
136  return false;
137  }
138 
139  bool AQEnabled() const {
140  if (varMap["learn"].as<std::string>() == std::string("AQ"))
141  return true;
142  else
143  return false;
144  }
145 
146  GymOptions::GymRewardTypes getRewardType() const {
147  if (varMap["reward-type"].as<std::string>() == std::string("default-type"))
149  else if (varMap["reward-type"].as<std::string>() == std::string("prism"))
151  else if (varMap["reward-type"].as<std::string>() == std::string("zeta-reach"))
153  else if (varMap["reward-type"].as<std::string>() == std::string("zeta-acc"))
155  else if (varMap["reward-type"].as<std::string>() == std::string("zeta-discount"))
157  else if (varMap["reward-type"].as<std::string>() == std::string("reward-on-acc"))
159  else if (varMap["reward-type"].as<std::string>() == std::string("multi-discount"))
161  else if (varMap["reward-type"].as<std::string>() == std::string("parity"))
163  else if (varMap["reward-type"].as<std::string>() == std::string("pri-tracker"))
165  else if (varMap["reward-type"].as<std::string>() == std::string("lexo"))
167  else if (varMap["reward-type"].as<std::string>() == std::string("avg"))
168  return GymOptions::GymRewardTypes::avg;
169  else
170  throw(std::runtime_error("Reward type invalid."));
171  }
172 
173 private:
174  boost::program_options::options_description visible;
175  boost::program_options::options_description hidden;
176  boost::program_options::options_description cmdline_options;
177  boost::program_options::positional_options_description posOpt;
178  boost::program_options::variables_map varMap;
179 
180  // Variables that reflect the command line options go here
181 
185  std::string inputFileName;
186 
190  int verbosityLevel;
191 
192 };
193 
194 #endif
ModelOptions
Class to pass options to Model.
Definition: ModelOptions.hh:52
GymOptions::GymRewardTypes::zeta_acc
@ zeta_acc
CommandLineOptions::verbosity
Verbosity::Level verbosity() const
Convert verbosity to enumerated type.
Definition: CommandLineOptions.hh:88
GymOptions::GymRewardTypes::multi_discount
@ multi_discount
CommandLineOptions::inputFile
const std::string & inputFile() const
Get the input file name.
Definition: CommandLineOptions.hh:83
GymOptions::GymRewardTypes::prism
@ prism
CommandLineOptions::options
boost::program_options::variables_map & options()
Returns the boost::program_options::variables_map.
Definition: CommandLineOptions.hh:75
ModelOptions.hh
Option structure for models.
Gym.hh
Interface between learner and model/objective.
CommandLineOptions
A class for parsing and storing command line options.
Definition: CommandLineOptions.hh:57
GymOptions::GymRewardTypes::parity
@ parity
GymOptions::GymRewardTypes::default_type
@ default_type
GymOptions::GymRewardTypes
GymRewardTypes
Definition: Gym.hh:217
CommandLineOptions::CommandLineOptions
CommandLineOptions()
Constructor adds the desired command line options.
Definition: CommandLineOptions.cc:59
GymOptions::GymRewardTypes::reward_on_acc
@ reward_on_acc
GymOptions::GymRewardTypes::zeta_reach
@ zeta_reach
GymOptions::GymRewardTypes::pri_tracker
@ pri_tracker
GymOptions::GymRewardTypes::lexo
@ lexo
CommandLineOptions::parseCommandLineOptions
int parseCommandLineOptions(int argc, char *argv[])
Parses the command line options and stores them in the appropriate member variables.
Definition: CommandLineOptions.cc:347
Verbosity.hh
Verbosity-related definitions.
GymOptions::GymRewardTypes::zeta_discount
@ zeta_discount