35 #ifndef OPENMS_TRANSFORMATIONS_FEATUREFINDER_LEVMARQFITTER1D_H 36 #define OPENMS_TRANSFORMATIONS_FEATUREFINDER_LEVMARQFITTER1D_H 40 #include <unsupported/Eigen/NonLinearOptimization> 65 int inputs()
const {
return m_inputs; }
66 int values()
const {
return m_values; }
69 : m_inputs(dimensions), m_values(num_data_points) {}
73 virtual int operator()(
const Eigen::VectorXd &x, Eigen::VectorXd &fvec) = 0;
76 virtual int df(
const Eigen::VectorXd &x, Eigen::MatrixXd &J) = 0;
86 this->defaults_.setValue(
"max_iteration", 500,
"Maximum number of iterations using by Levenberg-Marquardt algorithm.", ListUtils::create<String>(
"advanced"));
92 max_iteration_(source.max_iteration_)
104 if (&source ==
this)
return *
this;
128 int data_count = functor.
values();
129 int num_params = functor.
inputs();
132 if (data_count < num_params)
throw Exception::UnableToFit(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"UnableToFit-FinalSet",
"Skipping feature, we always expects N>=p");
134 Eigen::LevenbergMarquardt<GenericFunctor> lmSolver (functor);
135 lmSolver.parameters.maxfev = max_iteration_;
136 Eigen::LevenbergMarquardtSpace::Status status = lmSolver.minimize(x_init);
141 if (status <= Eigen::LevenbergMarquardtSpace::ImproperInputParameters)
143 throw Exception::UnableToFit(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"UnableToFit-FinalSet",
"Could not fit the gaussian to the data: Error " +
String(status));
150 max_iteration_ = this->param_.getValue(
"max_iteration");
156 #endif // OPENMS_TRANSFORMATIONS_FEATUREFINDER_LEVMARQFITTER1D_H Abstract class for 1D-model fitter using Levenberg-Marquardt algorithm for parameter optimization...
Definition: LevMarqFitter1D.h:52
int inputs() const
Definition: LevMarqFitter1D.h:65
A more convenient string class.
Definition: String.h:57
virtual ~LevMarqFitter1D()
destructor
Definition: LevMarqFitter1D.h:97
Int max_iteration_
Maximum number of iterations.
Definition: LevMarqFitter1D.h:117
GenericFunctor(int dimensions, int num_data_points)
Definition: LevMarqFitter1D.h:68
virtual LevMarqFitter1D & operator=(const LevMarqFitter1D &source)
assignment operator
Definition: LevMarqFitter1D.h:102
LevMarqFitter1D(const LevMarqFitter1D &source)
copy constructor
Definition: LevMarqFitter1D.h:90
Definition: LevMarqFitter1D.h:62
void optimize_(Eigen::VectorXd &x_init, GenericFunctor &functor)
Optimize start parameter.
Definition: LevMarqFitter1D.h:124
const int m_values
Definition: LevMarqFitter1D.h:79
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
virtual Fitter1D & operator=(const Fitter1D &source)
assignment operator
int values() const
Definition: LevMarqFitter1D.h:66
LevMarqFitter1D()
Default constructor.
Definition: LevMarqFitter1D.h:83
bool symmetric_
Parameter indicates symmetric peaks.
Definition: LevMarqFitter1D.h:115
Exception used if an error occurred while fitting a model to a given dataset.
Definition: Exception.h:677
Abstract base class for all 1D-dimensional model fitter.
Definition: Fitter1D.h:59
std::vector< double > ContainerType
Definition: LevMarqFitter1D.h:58
virtual void updateMembers_()
This method is used to update extra member variables at the end of the setParameters() method...
int Int
Signed integer type.
Definition: Types.h:103
virtual ~GenericFunctor()
Definition: LevMarqFitter1D.h:71
void updateMembers_()
This method is used to update extra member variables at the end of the setParameters() method...
Definition: LevMarqFitter1D.h:147