13 #ifndef VMCMC_PARAMETER_H_ 14 #define VMCMC_PARAMETER_H_ 19 #include <boost/optional.hpp> 37 static Parameter FixedParameter(
const std::string& name =
"",
double startValue = 0.0);
40 Parameter(
const std::string& name,
double startValue,
double absoluteError,
41 boost::optional<double> lowerLimit = boost::none,
42 boost::optional<double> upperLimit = boost::none,
46 const std::string& GetName()
const {
return fName; }
47 void SetName(
const std::string& name) { fName = name; }
49 double GetStartValue()
const {
return fStartValue; }
50 void SetStartValue(
double startValue) { fStartValue = startValue; }
52 double GetAbsoluteError()
const {
return fAbsoluteError; }
53 void SetAbsoluteError(
double absoluteError) { fAbsoluteError = std::abs(absoluteError); }
62 const boost::optional<double>& GetLowerLimit()
const {
return fLowerLimit; }
63 void SetLowerLimit(
const boost::optional<double>& lowerLimit) { fLowerLimit = lowerLimit; }
65 const boost::optional<double>& GetUpperLimit()
const {
return fUpperLimit; }
66 void SetUpperLimit(
const boost::optional<double>& upperLimit) { fUpperLimit = upperLimit; }
68 bool IsFixed()
const {
return fFixed; }
69 void SetFixed(
bool fixed) { fFixed = fixed; }
98 double fAbsoluteError;
99 boost::optional<double> fLowerLimit;
100 boost::optional<double> fUpperLimit;
112 using const_iterator = std::vector<Parameter>::const_iterator;
118 void SetParameter(
size_t pIndex,
const Parameter& param);
119 void SetParameter(
size_t pIndex,
const std::string& name,
double startValue,
120 double absoluteError, boost::optional<double> lowerLimit = boost::none,
121 boost::optional<double> upperLimit = boost::none,
bool fixed =
false);
123 Parameter& GetParameter(
size_t pIndex) {
return fParameters[pIndex]; }
124 const Parameter& GetParameter(
size_t pIndex)
const {
return fParameters[pIndex]; }
126 size_t size()
const {
return fParameters.size(); }
127 Parameter& operator[](
size_t pIndex) {
return fParameters[pIndex]; }
128 const Parameter& operator[](
size_t pIndex)
const {
return fParameters[pIndex]; }
129 const_iterator begin()
const {
return fParameters.cbegin(); }
130 const_iterator end()
const {
return fParameters.cend(); }
138 double GetErrorScaling()
const {
return fErrorScaling; }
140 Vector GetStartValues(
bool randomized =
false)
const;
141 Vector GetErrors()
const;
148 template <
typename MatrixT>
150 const MatrixUnitLower& GetCorrelationMatrix()
const {
return fCorrelations; }
152 void SetCorrelation(
size_t p1,
size_t p2,
double correlation);
153 double GetCorrelation(
size_t p1,
size_t p2)
const;
155 MatrixLower GetCovarianceMatrix()
const;
156 MatrixLower GetCholeskyDecomp()
const;
182 std::vector<Parameter> fParameters;
183 double fErrorScaling;
184 MatrixUnitLower fCorrelations;
Definition: algorithm.cpp:28
A list of parameters, describing the parameter space of the target function to be evaluated...
Definition: parameter.hpp:109
void SetCorrelationMatrix(const MatrixT &matrix)
Set a correlation matrix.
Definition: parameter.hpp:149
void SetErrorScaling(double scaling)
Set an error scaling factor, which is applied to all parameter errors uniformly.
Definition: parameter.hpp:137
This class represents a fit parameter of the target function to be sampled from.
Definition: parameter.hpp:34
void ConstrainToLimits(double &someValue) const
If a value lies outside the parameter limits, constrain it accordingly.
Definition: parameter.cpp:80
bool IsInsideLimits(double someValue) const
Checks if some parameter value is inside the configured parameter limits.
Definition: parameter.cpp:74
bool ReflectFromLimits(double &someValue) const
If a value lies outside a parameter limits, attempt a reflection from the closer limit.
Definition: parameter.cpp:88
BLAS (Basic Linear Algebra Subprograms) utility functions.
void SetRelativeError(double relativeError)
Sets the absolute error by multiplying a relative error argument with the before-hand configured star...
Definition: parameter.cpp:49