13 #include "msdevstudio/MSconfig.h"
30 m_needs_derivs ( false )
37 m_function ( fcn.m_function ),
38 m_needs_derivs ( fcn.m_needs_derivs )
67 string what (
"StatedFCN: The function `" );
68 what +=
function -> name ();
69 what +=
"' can not provide partial\n";
70 what +=
"derivatives needed by this fitter.";
71 throw std::runtime_error ( what );
77 const vector < string > &
84 const vector < double > &
105 unsigned int size = parms.size ();
106 for (
unsigned int i = 0; i <
size; i++ ) {
107 if ( flags[ i ] == 0 ) {
108 free_parms.push_back ( parms[ i ] );
117 unsigned int number = 0;
120 unsigned int size = flags.size ();
121 for (
unsigned int i = 0; i <
size; i++ ) {
123 if ( flags[i] == 0 ) number++;
129 const vector < int > &
152 unsigned int size = parms.size ();
155 for (
unsigned int i = 0; i <
size; i++ ) {
156 if ( flags [i] == 0 ) {
157 parms[i] = free_parms[j];
172 unsigned int size = parms.size();
174 for (
unsigned int i = 0; i <
size; i++ ) {
176 if ( flags [i] == 0 ) {
177 double value =
m_function -> derivByParm ( i, x );
178 derives.push_back ( value );
205 (
function -> hasDerivatives () ==
false ) ) {
bool hasFunction() const
Returns true if model function has been set, otherwise returns false.
const std::vector< double > & getParameters() const
Returns the current state of the model function's parameters.
void setNeedsDerivatives(bool yes)
Sets the needs derivatives flag.
bool isCompatible(const FunctionBase *) const
Returns true if function is compatible this objective function.
virtual void setFixedFlags(const std::vector< int > &flags)
Returns the vector of which of the model function's parameters are considered fixed and not to be cha...
unsigned int getNumberFreeParms() const
Returns the number of free parameters.
virtual double objectiveValue() const =0
Returns the value of the objective function.
StatedFCN()
The default constructor.
void setParameters(const std::vector< double > &parms)
Sets the values of the model function's parameters.
hippodraw::FunctionBase class interface
hippodraw::StatedFCN class interface
intp size(numeric::array arr)
A derived class for FCNBase class.
bool m_needs_derivs
Needs derivatives flag.
void fillFreeDerivatives(std::vector< double > &, double x)
Clears and fills the vector with the derivatives of the function a coordinate value x...
void setFunction(FunctionBase *function)
Sets the model function.
const std::vector< int > & getFixedFlags() const
Returns a vector of flags for parameters which are held fixed by the function.
A function that can be added to a DataRep and used in a fitter.
const std::vector< std::string > & getParmNames() const
Returns the names of the model function's parameters.
virtual void copyFrom(const StatedFCN *other)
Makes a copy of the relevant attributes from other object.
FunctionBase * m_function
The flags to indicated which parameters are to be held fixed during minimization of this objective fu...
virtual void setFreeParameters(const std::vector< double > &parms)
Sets the free parameters from the vector parms.
void fillFreeParameters(std::vector< double > &free_parms) const
Fills the vector with the values of the free parameters.
virtual double operator()(const std::vector< double > &parms) const
Sets the model function parameters to parms and returns the objective value.