mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2024-11-10 00:45:36 +00:00
Minuit minimiser: interface to choose algorithm
This commit is contained in:
parent
6202ed4518
commit
af3023038b
@ -62,11 +62,17 @@ double MinuitMinimizer::MinuitFunction::Up(void) const
|
||||
}
|
||||
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
MinuitMinimizer::MinuitMinimizer(const Index dim)
|
||||
MinuitMinimizer::MinuitMinimizer(const Index dim, const Algorithm algorithm)
|
||||
: Minimizer(dim)
|
||||
, algorithm_(algorithm)
|
||||
{}
|
||||
|
||||
// access //////////////////////////////////////////////////////////////////////
|
||||
MinuitMinimizer::Algorithm MinuitMinimizer::getAlgorithm(void) const
|
||||
{
|
||||
return algorithm_;
|
||||
}
|
||||
|
||||
double MinuitMinimizer::getPrecision(void) const
|
||||
{
|
||||
LATAN_ERROR(Implementation,
|
||||
@ -75,6 +81,11 @@ double MinuitMinimizer::getPrecision(void) const
|
||||
return 0.;
|
||||
}
|
||||
|
||||
void MinuitMinimizer::setAlgorithm(const Algorithm algorithm)
|
||||
{
|
||||
algorithm_ = algorithm;
|
||||
}
|
||||
|
||||
void MinuitMinimizer::setPrecision(const double precision __dumb)
|
||||
{
|
||||
LATAN_ERROR(Implementation,
|
||||
@ -134,13 +145,21 @@ const DVec & MinuitMinimizer::operator()(const DoubleFunction &f)
|
||||
}
|
||||
|
||||
// minimization and output
|
||||
MnMigrad minimizer(minuitF, parameters, 2);
|
||||
unique_ptr<MnApplication> minimizer(nullptr);
|
||||
if (algorithm_ == Algorithm::Migrad)
|
||||
{
|
||||
minimizer.reset(new MnMigrad(minuitF, parameters, 2));
|
||||
}
|
||||
else if (algorithm_ == Algorithm::Simplex)
|
||||
{
|
||||
minimizer.reset(new MnSimplex(minuitF, parameters, 2));
|
||||
}
|
||||
unsigned int iTry = 0;
|
||||
FunctionMinimum min = minimizer();
|
||||
FunctionMinimum min = (*minimizer)();
|
||||
|
||||
while ((!min.IsValid())&&(iTry < maxTry))
|
||||
{
|
||||
min = minimizer();
|
||||
min = (*minimizer)();
|
||||
iTry++;
|
||||
}
|
||||
if (!min.IsValid())
|
||||
|
@ -33,6 +33,12 @@ BEGIN_LATAN_NAMESPACE
|
||||
|
||||
class MinuitMinimizer: public Minimizer
|
||||
{
|
||||
public:
|
||||
enum class Algorithm
|
||||
{
|
||||
Migrad = 1,
|
||||
Simplex = 2
|
||||
};
|
||||
private:
|
||||
class MinuitFunction: public ROOT::Minuit2::FCNBase
|
||||
{
|
||||
@ -49,14 +55,19 @@ private:
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
explicit MinuitMinimizer(const Index dim);
|
||||
explicit MinuitMinimizer(const Index dim,
|
||||
const Algorithm algorithm = Algorithm::Migrad);
|
||||
// destructor
|
||||
virtual ~MinuitMinimizer(void) = default;
|
||||
// access
|
||||
virtual double getPrecision(void) const;
|
||||
Algorithm getAlgorithm(void) const;
|
||||
virtual void setPrecision(const double precision);
|
||||
void setAlgorithm(const Algorithm algorithm);
|
||||
// minimization
|
||||
virtual const DVec & operator()(const DoubleFunction &f);
|
||||
private:
|
||||
Algorithm algorithm_;
|
||||
};
|
||||
|
||||
END_LATAN_NAMESPACE
|
||||
|
Loading…
Reference in New Issue
Block a user