14 #include <boost/program_options.hpp>
15 #include <boost/any.hpp>
20 namespace po = boost::program_options;
21 namespace pt = boost::property_tree;
32 ostream&
operator<<(ostream&,
const vector<string>&);
49 template <
typename Ttype>
50 void add(
string,
string,
string);
53 template <
typename Ttype>
54 void add(
string,
string,
string,
const Ttype);
57 template<
typename Ttype>
58 void set(
const string&,
const Ttype);
61 template<
typename Ttype>
62 void set(
const string&,
const pt::ptree &);
69 void update(
int,
char*[],po::options_description&);
78 const po::variables_map&
operator()()
const {
return params;}
79 po::variables_map&
operator()() {
return params;}
82 const bool operator()(
const string & key)
const {
return !(state.at(key) == UNSET); }
85 const po::variable_value &
operator[](
const string & key)
const {
return params[key];}
86 po::variable_value &
operator[](
const string & key) {
return params.at(key);}
90 using Extractor = map<string, void(*)(
const po::variable_value &)>;
92 po::variables_map params;
93 map<string, const type_info&> type;
94 map<string,string> pClass;
95 map<string,ParamState> state;
96 map<string,string> shortName;
97 map<string,string> helpMessage;
101 vector<string> split(
const string &,
char);
103 template <
typename Ttype>
104 po::typed_value<Ttype, char>* initValue(
const string &);
107 bool getNode(
const pt::ptree &xmlParams, pt::ptree &node,
const string key) {
108 boost::optional<const pt::ptree&> child = xmlParams.get_child_optional(key);
124 template <
typename Ttype>
129 vector<string> label = split(_label,
',');
130 string key = label[0];
131 if (label.size() > 1)
132 shortName.emplace(key,label[1]);
134 shortName.emplace(key,
"");
137 helpMessage.emplace(key,_helpMessage);
140 pClass.emplace(key,_pClass);
143 type.emplace(pair<string,const type_info&>(key,
typeid(Ttype)));
146 extract.emplace(pair<
string,
void(*)(
const po::variable_value &)>
147 (key,[](
const po::variable_value& v) {cout << v.as<Ttype>();}));
150 state.emplace(key,UNSET);
153 params.insert(make_pair(key, po::variable_value()));
167 template <
typename Ttype>
169 const Ttype _defaultValue) {
172 add<Ttype>(_label,_helpMessage,_pClass);
175 vector<string> label = split(_label,
',');
176 string key = label[0];
179 set<Ttype>(key,_defaultValue);
182 state.at(key) = DEFAULTED;
191 template<
typename Ttype>
193 if (params.count(key)) {
194 po::variables_map::iterator it(params.find(key));
195 po::variable_value & v(it->second);
199 params.insert(std::make_pair(key, po::variable_value(val,
false)));
203 type.emplace(pair<string,const type_info&>(key,
typeid(Ttype)));
215 template<
typename Ttype>
221 if (state[key] == UNSET || state[key] == DEFAULTED) {
222 set<Ttype>(key,xml.get<Ttype>(key));
231 template <
typename Ttype>
232 po::typed_value<Ttype, char>* Parameters::initValue(
const string& key) {
233 if (state[key] == DEFAULTED)
234 return po::value<Ttype>()->default_value(params[key].as<Ttype>());
236 return po::value<Ttype>();
299 boost::ptr_vector<EstimatorBase> *
estimators(boost::ptr_vector<Path> &,
300 boost::ptr_vector<ActionBase> &, MTRand&);
305 vector<string> interactionPotentialName;
306 vector<string> externalPotentialName;
307 vector<string> waveFunctionName;
308 vector<string> randomGeneratorName;
309 vector<string> actionName;
310 vector<string> estimatorName;
311 vector<string> moveName;
312 vector<string> optionClassNames;
314 string interactionNames;
315 string externalNames;
316 string waveFunctionNames;
317 string randomGeneratorNames;
319 string estimatorNames;
329 boost::ptr_map<string,po::options_description> optionClasses;
330 po::options_description cmdLineOptions;
333 void cleanCommandLineOptions(
int,
char*[], vector<string> &, vector<string> &,
335 void update(
int,
char*[],po::options_description&);
338 void initParameters();
341 string getXMLOptionList(
const vector<string> &,
const string);
Holds a base class that all action classes will be derived from.
The base class which holds details on the generalized box that our system will be simulated inside of...
The base class that all estimator classes will be derived from.
The particle (bead) lookup table.
The base class that all moves will be derived from.
void print()
print out the parameter map
void set(const string &, const Ttype)
Set a parameter from a value.
const po::variable_value & operator[](const string &key) const
Parmaters[key] returns the variable value at key.
const bool operator()(const string &key) const
Parmaters(key) returns the existence of a parameter.
const po::variables_map & operator()() const
Parameters() returns the full map.
void update(int, char *[], po::options_description &)
Update parameters from command line.
void add(string, string, string)
Add a parameter to the map without a default value.
void update(const pt::ptree &)
Update parameters from an xml file.
void setupCommandLine(boost::ptr_map< string, po::options_description > &)
Insert options into the options_description data structure to be read from the command line.
The space-time trajectories.
The base class from which all specific potentials are derived from.
ActionBase * action(const Path &, LookupTable &, PotentialBase *, PotentialBase *, WaveFunctionBase *)
Setup the action.
Setup()
Setup the program_options variables.
uint32 seed(const uint32)
Return the random seed.
bool parseOptions()
Parse the command line options for obvious errors and return values.
PotentialBase * interactionPotential(const Container *)
Setup the interaction potential.
WaveFunctionBase * waveFunction(const Path &, LookupTable &)
Setup the trial wave function.
void setConstants()
Setup the simulation constants.
void outputOptions(int, char *[], const uint32, const Container *, const iVec &)
Output the simulation parameters to a log file.
void communicator()
Setup the communicator.
boost::ptr_vector< EstimatorBase > * estimators(Path &, ActionBase *, MTRand &)
Create a list of estimators to be measured.
void getOptions(int, char *[])
Define all command line options and get them from the command line.
boost::ptr_vector< MoveBase > * moves(Path &, ActionBase *, MTRand &)
Define the Monte Carlo updates that will be performed.
Parameters params
All simulation parameters.
Container * cell()
Setup the simulation cell.
bool worldlines()
Setup the worldlines.
PotentialBase * externalPotential(const Container *)
Setup the external potential.
Holds a base class that all trial wave function classes will be derived from.
Global common header with shared dependencies and methods.
unsigned long uint32
Unsigned integer type, at least 32 bits.
TinyVector< int, NDIM > iVec
A NDIM-vector of type integer.
Factory class definitions.
ParamState
The three possible states of a parameter.
ostream & operator<<(ostream &, const vector< string > &)
Overload << to print a vector of strings to the terminal.