GammaLib 2.0.0
Loading...
Searching...
No Matches
GModelPar.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GModelPar.hpp - Model parameter class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2009-2014 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- *
6 * *
7 * This program is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 * *
20 ***************************************************************************/
21/**
22 * @file GModelPar.hpp
23 * @brief Model parameter class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GMODELPAR_HPP
28#define GMODELPAR_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GOptimizerPar.hpp"
33#include "GXmlElement.hpp"
34
35
36/***********************************************************************//**
37 * @class GModelPar
38 *
39 * @brief Model parameter class
40 *
41 * This class implements a model parameter. A model parameter is a numerical
42 * value that is used to describe a model. A model parameter has the
43 * following attributes:
44 * - @p value gives the numerical value of the parameter
45 * - @p error gives the statistical uncertainty in the parameter value
46 * - @p gradient gives the gradient of a the model with respect to the
47 * parameter
48 * - @p min gives the minimum value that the parameter value can take
49 * - @p max gives the maximum value that the parameter value can take
50 *
51 * The parameter attributes are set and retrieved using the value(),
52 * error(), gradient(), min() and max() methods, respectively. Furthermore,
53 * the range() method is used to simultaneously set the minimum and maximum
54 * value of a parameter.
55 *
56 * The minimum and maximum values are optional, and existence of these
57 * attributes is tested using the has_min() and has_max() methods,
58 * respectively. The minimum value, maximum value are removed using the
59 * remove_min() and remove_max() methods. Simultaneous removal of minimum
60 * and maximum values is done using the remove_range() method.
61 *
62 * Each parameter has furthermore the following properties:
63 * - @p free specifies whether the parameter should be fitted
64 * - @p grad specifies whether the parameter gradient is computed
65 * analytically (true) or numerically (false)
66 *
67 * The parameter property @p free is set using the free() and fix()
68 * methods and it is retrieved using the is_free() and is_fixed() methods.
69 * The attribute @p grad is set and retrieved using the has has_grad()
70 * methods.
71 *
72 * Each model parameter is factorized into a @p factor and a @p scale
73 * term. The GModelPar class stores the factors and the scale factor has
74 * data members, and the true values are computed using the following
75 * relations:
76 *
77 * value = m_factor_value * m_scale
78 * error = m_factor_error * m_scale
79 * gradient = m_factor_gradient * m_scale
80 * min = m_factor_min * m_scale
81 * max = m_factor_max * m_scale
82 *
83 * The @p factor and @p scale terms can be set and retrieved using the
84 * factor_value(), factor_error(), factor_gradient(), factor_min(),
85 * factor_max() and scale() methods.
86 ***************************************************************************/
87class GModelPar : public GOptimizerPar {
88
89public:
90 // Constructors and destructors
91 GModelPar(void);
92 GModelPar(const std::string& name, const double& value);
93 GModelPar(const std::string& name, const double& factor,
94 const double& scale);
95 GModelPar(const GModelPar& par);
96 virtual ~GModelPar(void);
97
98 // Operators
99 GModelPar& operator=(const GModelPar& par);
100
101 // Methods
102 GModelPar* clone(void) const;
103 std::string classname(void) const;
104 void read(const GXmlElement& xml);
105 void write(GXmlElement& xml) const;
106
107protected:
108 // Protected methods
109 void init_members(void);
110 void copy_members(const GModelPar& par);
111 void free_members(void);
112};
113
114
115/***********************************************************************//**
116 * @brief Return class name
117 *
118 * @return String containing the class name ("GModelPar").
119 ***************************************************************************/
120inline
121std::string GModelPar::classname(void) const
122{
123 return ("GModelPar");
124}
125
126#endif /* GMODELPAR_HPP */
Optimizer parameter class interface definition.
XML element node class interface definition.
Model parameter class.
Definition GModelPar.hpp:87
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
void copy_members(const GModelPar &par)
Copy class members.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
GModelPar * clone(void) const
Clone model parameter.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
std::string classname(void) const
Return class name.
virtual ~GModelPar(void)
Destructor.
GModelPar(void)
Void constructor.
Definition GModelPar.cpp:59
GModelPar & operator=(const GModelPar &par)
Assignment operator.
Optimizer parameter class.
const double & scale(void) const
Return parameter scale.
double value(void) const
Return parameter value.
const std::string & name(void) const
Return parameter name.
XML element node class.