gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool

#include <model_parameters.hpp>

Collaboration diagram for Gambit::ModelParameters:

Public Member Functions

 ModelParameters ()
 Default constructor. More...
 
 ModelParameters (const std::vector< std::string > &)
 Constructor using vector of strings. More...
 
 ModelParameters (const char **)
 Constructor using array of char arrays. More...
 
double getValue (std::string const &inkey) const
 Get value of named parameter. More...
 
const std::map< std::string, double > & getValues () const
 Get values of all parameters. More...
 
std::map< std::string, double >::const_iterator begin () const
 Get a const iterator to the first parameter map entry. More...
 
std::map< std::string, double >::const_iterator end () const
 Get a const iterator to the last parameter map entry. More...
 
int getNumberOfPars () const
 Get number of parameters stored in this object. More...
 
const doubleoperator[] (std::string const &inkey) const
 Get parameter value using bracket operator. More...
 
const doubleat (std::string const &inkey) const
 Get parameter value using 'at' syntax. More...
 
void setValue (std::string const &inkey, double const &value)
 Set single parameter value. More...
 
void setValues (std::map< std::string, double > const &params_map, bool missing_is_error=true)
 Set many parameter values using a map. More...
 
void setValues (ModelParameters const &donor, bool missing_is_error=true)
 Set many parameter values using another ModelParameters object. More...
 
std::vector< std::string > getKeys () const
 Get parameter keys (names), probably for external iteration. More...
 
void print () const
 Dump parameter names and values to stdout (should be for debugging only) More...
 
void _definePar (const std::string &newkey)
 Define a parameter with name, value (i.e. add to internal map). Value is initialised to zero. More...
 
void _definePars (const std::vector< std::string > &v)
 Define many new parameters at once via a vector of names. More...
 
void _definePars (const char **array)
 Define many new parameters at once via an array of char arrays. More...
 
std::string getModelName () const
 Getters/setters for model and output names. More...
 
std::string getOutputName () const
 
void setModelName (const std::string &)
 
void setOutputName (const std::string &)
 

Protected Member Functions

void assert_contains (std::string) const
 Checks if this model container holds a parameter match the supplied name. More...
 

Private Attributes

std::map< std::string, double_values
 Internal map representation of parameters and their values. More...
 
std::string modelname
 Name of the model; intended mainly for more helpful error messages. More...
 
std::string outputname
 Output name (string used for labelling in output, related to the model_functor which produced these parameters) Currently used only by the postprocessor ScannerBit plugin and reader plugins. More...
 

Friends

std::ostream & operator<< (std::ostream &strm, const ModelParameters &me)
 Dump parameter names and values to stream (again for debugging only I think) More...
 

Detailed Description

Definition at line 53 of file model_parameters.hpp.

Constructor & Destructor Documentation

◆ ModelParameters() [1/3]

Gambit::ModelParameters::ModelParameters ( )

Default constructor.

Definition at line 52 of file model_parameters.cpp.

52 : _values(), modelname("None"), outputname("None") {}
std::string outputname
Output name (string used for labelling in output, related to the model_functor which produced these p...
std::map< std::string, double > _values
Internal map representation of parameters and their values.
std::string modelname
Name of the model; intended mainly for more helpful error messages.

◆ ModelParameters() [2/3]

Gambit::ModelParameters::ModelParameters ( const std::vector< std::string > &  paramlist)

Constructor using vector of strings.

Definition at line 55 of file model_parameters.cpp.

References _definePars().

55  : _values(), modelname("None"), outputname("None")
56  {
57  _definePars(paramlist);
58  }
std::string outputname
Output name (string used for labelling in output, related to the model_functor which produced these p...
std::map< std::string, double > _values
Internal map representation of parameters and their values.
std::string modelname
Name of the model; intended mainly for more helpful error messages.
void _definePars(const std::vector< std::string > &v)
Define many new parameters at once via a vector of names.
Here is the call graph for this function:

◆ ModelParameters() [3/3]

Gambit::ModelParameters::ModelParameters ( const char **  paramlist)

Constructor using array of char arrays.

Definition at line 61 of file model_parameters.cpp.

References _definePars().

61  : _values(), modelname("None"), outputname("None")
62  {
63  _definePars(paramlist);
64  }
std::string outputname
Output name (string used for labelling in output, related to the model_functor which produced these p...
std::map< std::string, double > _values
Internal map representation of parameters and their values.
std::string modelname
Name of the model; intended mainly for more helpful error messages.
void _definePars(const std::vector< std::string > &v)
Define many new parameters at once via a vector of names.
Here is the call graph for this function:

Member Function Documentation

◆ _definePar()

void Gambit::ModelParameters::_definePar ( const std::string &  newkey)

Define a parameter with name, value (i.e. add to internal map). Value is initialised to zero.

Definition at line 165 of file model_parameters.cpp.

References _values.

Referenced by _definePars(), and Gambit::model_functor::addParameter().

166  {
167  _values[newkey]=0.;
168  }
std::map< std::string, double > _values
Internal map representation of parameters and their values.
Here is the caller graph for this function:

◆ _definePars() [1/2]

void Gambit::ModelParameters::_definePars ( const std::vector< std::string > &  v)

Define many new parameters at once via a vector of names.

Definition at line 171 of file model_parameters.cpp.

References _definePar().

Referenced by ModelParameters().

172  {
173  for(std::vector<std::string>::const_iterator it = v.begin(); it != v.end(); ++it)
174  {
175  _definePar(*it);
176  }
177  }
void _definePar(const std::string &newkey)
Define a parameter with name, value (i.e. add to internal map). Value is initialised to zero...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _definePars() [2/2]

void Gambit::ModelParameters::_definePars ( const char **  array)

Define many new parameters at once via an array of char arrays.

Definition at line 180 of file model_parameters.cpp.

References _definePar().

181  {
182  int i = 0;
183  while (array[i] != 0)
184  {
185  _definePar(array[i]);
186  i++;
187  }
188  }
void _definePar(const std::string &newkey)
Define a parameter with name, value (i.e. add to internal map). Value is initialised to zero...
Here is the call graph for this function:

◆ assert_contains()

void Gambit::ModelParameters::assert_contains ( std::string  inkey) const
protected

Checks if this model container holds a parameter match the supplied name.

ModelParameters class member function definitions.

Checks if this model container holds a parameter matching the supplied name

Definition at line 43 of file model_parameters.cpp.

References _values, getModelName(), LOCAL_INFO, and Gambit::model_error().

Referenced by at(), getValue(), operator[](), setValue(), and setValues().

44  {
45  if(_values.count(inkey)!=1)
46  {
47  model_error().raise(LOCAL_INFO, "ModelParameters object (with name "+getModelName()+") does not contain the requested parameter '"+inkey+"'.");
48  }
49  }
#define LOCAL_INFO
Definition: local_info.hpp:34
std::map< std::string, double > _values
Internal map representation of parameters and their values.
std::string getModelName() const
Getters/setters for model and output names.
error & model_error()
Model errors.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ at()

const double & Gambit::ModelParameters::at ( std::string const &  inkey) const

Get parameter value using 'at' syntax.

Get parameter value using 'at' operator This is no different to the bracket operator method, since keys cannot be added with the bracket method anyhow, but for people who are used to maps it is nice to have.

Definition at line 108 of file model_parameters.cpp.

References _values, and assert_contains().

109  {
110  assert_contains(inkey);
111  return _values.at(inkey);
112  }
void assert_contains(std::string) const
Checks if this model container holds a parameter match the supplied name.
std::map< std::string, double > _values
Internal map representation of parameters and their values.
Here is the call graph for this function:

◆ begin()

std::map< std::string, double >::const_iterator Gambit::ModelParameters::begin ( ) const

Get a const iterator to the first parameter map entry.

Definition at line 80 of file model_parameters.cpp.

References getValues().

Referenced by Gambit::model_functor::donateParameters().

81  {
82  return getValues().begin();
83  }
const std::map< std::string, double > & getValues() const
Get values of all parameters.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ end()

std::map< std::string, double >::const_iterator Gambit::ModelParameters::end ( ) const

Get a const iterator to the last parameter map entry.

Definition at line 86 of file model_parameters.cpp.

References getValues().

Referenced by Gambit::model_functor::donateParameters().

87  {
88  return getValues().end();
89  }
const std::map< std::string, double > & getValues() const
Get values of all parameters.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getKeys()

std::vector< std::string > Gambit::ModelParameters::getKeys ( ) const

Get parameter keys (names), probably for external iteration.

Definition at line 144 of file model_parameters.cpp.

References _values.

Referenced by Gambit::PostProcessor::PPDriver::get_ModelParameters(), main(), and Gambit::PostProcessor::PPDriver::run_main_loop().

145  {
146  std::vector<std::string> parnames;
147  for (std::map<std::string,double>::const_iterator it=_values.begin();it!=_values.end();it++)
148  {
149  parnames.push_back((*it).first);
150  }
151  return parnames;
152  }
std::map< std::string, double > _values
Internal map representation of parameters and their values.
Here is the caller graph for this function:

◆ getModelName()

std::string Gambit::ModelParameters::getModelName ( ) const

Getters/setters for model and output names.

Definition at line 191 of file model_parameters.cpp.

References modelname.

Referenced by assert_contains(), and Gambit::model_functor::donateParameters().

191 { return modelname; }
std::string modelname
Name of the model; intended mainly for more helpful error messages.
Here is the caller graph for this function:

◆ getNumberOfPars()

int Gambit::ModelParameters::getNumberOfPars ( ) const

Get number of parameters stored in this object.

Definition at line 92 of file model_parameters.cpp.

References _values.

93  {
94  return _values.size();
95  }
std::map< std::string, double > _values
Internal map representation of parameters and their values.

◆ getOutputName()

std::string Gambit::ModelParameters::getOutputName ( ) const

Definition at line 192 of file model_parameters.cpp.

References outputname.

Referenced by Gambit::PostProcessor::PPDriver::run_main_loop().

192 { return outputname; }
std::string outputname
Output name (string used for labelling in output, related to the model_functor which produced these p...
Here is the caller graph for this function:

◆ getValue()

double Gambit::ModelParameters::getValue ( std::string const &  inkey) const

Get value of named parameter.

Definition at line 67 of file model_parameters.cpp.

References _values, and assert_contains().

68  {
69  assert_contains(inkey);
70  return _values.at(inkey);
71  }
void assert_contains(std::string) const
Checks if this model container holds a parameter match the supplied name.
std::map< std::string, double > _values
Internal map representation of parameters and their values.
Here is the call graph for this function:

◆ getValues()

const std::map< std::string, double > & Gambit::ModelParameters::getValues ( ) const

Get values of all parameters.

Definition at line 74 of file model_parameters.cpp.

References _values.

Referenced by Gambit::Printers::_common_print(), begin(), end(), and setValues().

75  {
76  return _values;
77  }
std::map< std::string, double > _values
Internal map representation of parameters and their values.
Here is the caller graph for this function:

◆ operator[]()

const double & Gambit::ModelParameters::operator[] ( std::string const &  inkey) const

Get parameter value using bracket operator.

Definition at line 98 of file model_parameters.cpp.

References _values, and assert_contains().

99  {
100  assert_contains(inkey);
101  return _values.at(inkey);
102  }
void assert_contains(std::string) const
Checks if this model container holds a parameter match the supplied name.
std::map< std::string, double > _values
Internal map representation of parameters and their values.
Here is the call graph for this function:

◆ print()

void Gambit::ModelParameters::print ( ) const

Dump parameter names and values to stdout (should be for debugging only)

Definition at line 155 of file model_parameters.cpp.

References _values.

156  {
157  std::cout << "ModelParameters: Printing: "<<std::endl;
158  for (std::map<std::string,double>::const_iterator it=_values.begin();it!=_values.end();it++)
159  {
160  std::cout << "parameter: " << it->first << "; value: "<<it->second<<std::endl ;
161  }
162  }
std::map< std::string, double > _values
Internal map representation of parameters and their values.

◆ setModelName()

void Gambit::ModelParameters::setModelName ( const std::string &  in)

Definition at line 193 of file model_parameters.cpp.

References modelname.

Referenced by Gambit::model_functor::setModelName().

193 { modelname = in; }
std::string modelname
Name of the model; intended mainly for more helpful error messages.
Here is the caller graph for this function:

◆ setOutputName()

void Gambit::ModelParameters::setOutputName ( const std::string &  in)

Definition at line 194 of file model_parameters.cpp.

References outputname.

194 { outputname = in; }
std::string outputname
Output name (string used for labelling in output, related to the model_functor which produced these p...

◆ setValue()

void Gambit::ModelParameters::setValue ( std::string const &  inkey,
double const &  value 
)

Set single parameter value.

Definition at line 116 of file model_parameters.cpp.

References _values, and assert_contains().

Referenced by main(), Gambit::MSSM20atX_to_MSSM25atX(), Gambit::MSSM25atX_to_MSSM30atX(), Gambit::MSSM30atX_to_MSSM63atX(), Gambit::MSSM_mA_to_MSSM_mhud(), Gambit::MSSMatX_to_MSSMatQ(), and Gambit::Models::set_many_to_one().

117  {
118  assert_contains(inkey);
119  _values[inkey]=value;
120  }
void assert_contains(std::string) const
Checks if this model container holds a parameter match the supplied name.
std::map< std::string, double > _values
Internal map representation of parameters and their values.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setValues() [1/2]

void Gambit::ModelParameters::setValues ( std::map< std::string, double > const &  params_map,
bool  missing_is_error = true 
)

Set many parameter values using a map.

Definition at line 129 of file model_parameters.cpp.

References _values, and assert_contains().

Referenced by Gambit::MSSM20atX_to_MSSM25atX(), Gambit::MSSM25atX_to_MSSM30atX(), Gambit::MSSM30atX_to_MSSM63atX(), Gambit::MSSM_mA_to_MSSM_mhud(), Gambit::MSSMatX_to_MSSMatQ(), and setValues().

130  {
131  typedef std::map<std::string,double>::const_iterator it_type;
132  for(it_type iterator = params_map.begin();
133  iterator != params_map.end();
134  iterator++)
135  {
136  // iterator->first = key
137  // iterator->second = value
138  if (missing_is_error) assert_contains(iterator->first);
139  if (_values.count(iterator->first)==1) _values[iterator->first]=iterator->second;
140  }
141  }
void assert_contains(std::string) const
Checks if this model container holds a parameter match the supplied name.
std::map< std::string, double > _values
Internal map representation of parameters and their values.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setValues() [2/2]

void Gambit::ModelParameters::setValues ( ModelParameters const &  donor,
bool  missing_is_error = true 
)

Set many parameter values using another ModelParameters object.

Definition at line 123 of file model_parameters.cpp.

References getValues(), and setValues().

124  {
125  setValues(donor.getValues(), missing_is_error);
126  }
void setValues(std::map< std::string, double > const &params_map, bool missing_is_error=true)
Set many parameter values using a map.
Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  strm,
const ModelParameters me 
)
friend

Dump parameter names and values to stream (again for debugging only I think)

Definition at line 109 of file model_parameters.hpp.

110  {
111  strm << "ModelParameters: Printing: "<<std::endl;
112  for (std::map<std::string,double>::const_iterator it=me._values.begin();it!=me._values.end();it++)
113  {
114  strm << "parameter: " << it->first << " value: "<<it->second ;
115  }
116  return strm;
117  }

Member Data Documentation

◆ _values

std::map<std::string,double> Gambit::ModelParameters::_values
private

Internal map representation of parameters and their values.

Definition at line 137 of file model_parameters.hpp.

Referenced by _definePar(), assert_contains(), at(), getKeys(), getNumberOfPars(), getValue(), getValues(), operator[](), print(), setValue(), and setValues().

◆ modelname

std::string Gambit::ModelParameters::modelname
private

Name of the model; intended mainly for more helpful error messages.

Definition at line 140 of file model_parameters.hpp.

Referenced by getModelName(), and setModelName().

◆ outputname

std::string Gambit::ModelParameters::outputname
private

Output name (string used for labelling in output, related to the model_functor which produced these parameters) Currently used only by the postprocessor ScannerBit plugin and reader plugins.

Definition at line 144 of file model_parameters.hpp.

Referenced by getOutputName(), and setOutputName().


The documentation for this class was generated from the following files: