BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Parameter.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Fit/Kernel/Parameter.h
6 //! @brief Defines class Parameter.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
15 #ifndef BORNAGAIN_FIT_KERNEL_PARAMETER_H
16 #define BORNAGAIN_FIT_KERNEL_PARAMETER_H
17 
18 #include "Fit/Tools/AttLimits.h"
19 #include <string>
20 
21 namespace Fit
22 {
23 
24 //! A fittable parameter with value, error, step, and limits.
25 //! @ingroup fitting
26 
27 class Parameter
28 {
29 public:
30  Parameter();
31 
32  //! Fit parameter constructor.
33  //! @param name: unique name of fit parameters
34  //! @param value: starting value of fit parameter
35  //! @param limits: fit parameter limits
36  //! @param step: initial step of fit parameter during the minimization,
37  //! will be calculated automatically, if zero.
38  Parameter(const std::string& name, double value,
39  const AttLimits& limits = AttLimits::limitless(), double step = 0.0);
40 
41  std::string name() const;
42 
43  double startValue() const;
44 
45  AttLimits limits() const;
46 
47  double value() const;
48  void setValue(double value);
49 
50  double step() const;
51 
52  double error() const;
53  void setError(double value);
54 
55 private:
56  std::string m_name; //!< unique fit parameter name
57  double m_start_value; //!< starting value of fit parameters
58  double m_value; //!< current value of fit parameters
59  double m_step; //!< approximate initial step for the minimizer
60  double m_error; //!< error of fit parameter calculated by the minimizer
62 };
63 
64 } // namespace Fit
65 
66 #endif // BORNAGAIN_FIT_KERNEL_PARAMETER_H
Defines and implements class AttLimits.
Attributes and limits of a fit parameter, and coupling between these properties.
Definition: AttLimits.h:26
static AttLimits limitless()
Definition: AttLimits.cpp:26
A fittable parameter with value, error, step, and limits.
Definition: Parameter.h:28
void setValue(double value)
Definition: Parameter.cpp:61
double startValue() const
Definition: Parameter.cpp:46
double m_start_value
starting value of fit parameters
Definition: Parameter.h:57
std::string m_name
unique fit parameter name
Definition: Parameter.h:56
double m_value
current value of fit parameters
Definition: Parameter.h:58
double step() const
Definition: Parameter.cpp:66
std::string name() const
Definition: Parameter.cpp:41
AttLimits limits() const
Definition: Parameter.cpp:51
double value() const
Definition: Parameter.cpp:56
double error() const
Definition: Parameter.cpp:71
void setError(double value)
Definition: Parameter.cpp:76
double m_error
error of fit parameter calculated by the minimizer
Definition: Parameter.h:60
AttLimits m_limits
Definition: Parameter.h:61
double m_step
approximate initial step for the minimizer
Definition: Parameter.h:59
Objective function types.