-
Notifications
You must be signed in to change notification settings - Fork 122
/
CostFuncSimplex.h
115 lines (88 loc) · 3.56 KB
/
CostFuncSimplex.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#ifndef MANTID_CURVEFITTING_COSTFUNCSIMPLEX_H_
#define MANTID_CURVEFITTING_COSTFUNCSIMPLEX_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidCurveFitting/CostFuncFitting.h"
#include "MantidCurveFitting/GSLMatrix.h"
#include "MantidCurveFitting/GSLVector.h"
namespace Mantid
{
namespace CurveFitting
{
class SeqDomain;
class ParDomain;
/** Cost function for simplex
@author Anders Markvardsen, ISIS, RAL
@date 11/05/2010
Copyright © 2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport CostFuncSimplex : public CostFuncFitting
{
public:
/// Constructor
CostFuncSimplex();
/// Virtual destructor
virtual ~CostFuncSimplex() {}
/// Get name of minimizer
virtual std::string name() const { return "Simplex";}
/// Get short name of minimizer - useful for say labels in guis
virtual std::string shortName() const {return "Chi";};
/// Calculate value of cost function
virtual double val() const;
/// Calculate the derivatives of the cost function
/// @param der :: Container to output the derivatives
virtual void deriv(std::vector<double>& der) const;
/// Calculate the value and the derivatives of the cost function
/// @param der :: Container to output the derivatives
/// @return :: The value of the function
virtual double valAndDeriv(std::vector<double>& der) const;
virtual double valDerivHessian(bool evalFunction = true, bool evalDeriv = true, bool evalHessian = true) const;
const GSLVector& getDeriv() const;
const GSLMatrix& getHessian() const;
void push();
void pop();
void drop();
void setParameters(const GSLVector& params);
void getParameters(GSLVector& params) const;
protected:
virtual void calActiveCovarianceMatrix(GSLMatrix& covar, double epsrel = 1e-8);
void addVal(
API::FunctionDomain_sptr domain,
API::FunctionValues_sptr values
)const;
void addValDerivHessian(
API::IFunction_sptr function,
API::FunctionDomain_sptr domain,
API::FunctionValues_sptr values,
bool evalFunction = true, bool evalDeriv = true, bool evalHessian = true) const;
/// Get mapped weights from FunctionValues
virtual std::vector<double> getFitWeights(API::FunctionValues_sptr values) const;
/// Flag to include constraint in cost function value
bool m_includePenalty;
mutable double m_value;
mutable GSLVector m_der;
mutable GSLMatrix m_hessian;
mutable bool m_pushed;
mutable double m_pushedValue;
mutable GSLVector m_pushedParams;
friend class SeqDomain;
friend class ParDomain;
double m_factor;
};
} // namespace CurveFitting
} // namespace Mantid
#endif /*MANTID_CURVEFITTING_COSTFUNCSIMPLEX_H_*/