22class GradientCalculator;
25 const MnStrategy &,
unsigned int maxfcn,
double minedm)
const
34 print.
Debug(
"Running with maxfcn", maxfcn,
"minedm", minedm);
42 double alpha = 1., beta = 0.5, gamma = 2., rhomin = 4., rhomax = 8.;
43 double rho1 = 1. + alpha;
46 double rho2 = 1. + alpha * gamma;
48 std::vector<std::pair<double, MnAlgebraicVector>> simpl;
50 simpl.push_back(std::pair<double, MnAlgebraicVector>(seed.
Fval(),
x));
52 unsigned int jl = 0, jh = 0;
53 double amin = seed.
Fval(), aming = seed.
Fval();
55 for (
unsigned int i = 0; i <
n; i++) {
56 double dmin = 8. * prec.
Eps2() * (std::fabs(
x(i)) + prec.
Eps2());
69 simpl.push_back(std::pair<double, MnAlgebraicVector>(tmp,
x));
74 print.
Debug([&](std::ostream &os) {
75 os <<
"Initial parameters - min " << jl <<
" " << amin <<
" max " << jh <<
" " << aming <<
'\n';
76 for (
unsigned int i = 0; i <
simplex.Simplex().
size(); ++i)
77 os <<
" i = " << i <<
" x = " <<
simplex(i).second <<
" fval(x) = " <<
simplex(i).
first <<
'\n';
88 print.
Debug(
"iteration: edm =",
simplex.Edm(),
'\n',
"--> Min Param is", jl,
"pmin",
simplex(jl).second,
89 "f(pmin)", amin,
'\n',
"--> Max param is", jh,
simplex(jh).
first);
104 for (
unsigned int i = 0; i <
n + 1; i++) {
107 pbar += (wg *
simplex(i).second);
111 double ystar = mfcn(pstar);
113 print.
Debug(
"pbar", pbar,
"pstar", pstar,
"f(pstar)", ystar);
122 double ystst = mfcn(pstst);
124 print.
Debug(
"Reduced simplex pstst", pstst,
"f(pstst)", ystst);
133 double ystst = mfcn(pstst);
135 print.
Debug(
"pstst", pstst,
"f(pstst)", ystst);
137 double y1 = (ystar -
simplex(jh).first) * rho2;
138 double y2 = (ystst -
simplex(jh).first) * rho1;
139 double rho = 0.5 * (rho2 *
y1 - rho1 *
y2) / (
y1 -
y2);
150 double yrho = mfcn(prho);
152 print.
Debug(
"prho", prho,
"f(prho)", yrho);
170 pstst = beta *
simplex(jh).second + (1. - beta) * pbar;
177 print.
Debug(
"End loop : Edm",
simplex.Edm(),
"pstst", pstst,
"f(pstst)", ystst);
179 }
while ((
simplex.Edm() > minedm || edmPrev > minedm) && mfcn.
NumOfCalls() < maxfcn);
186 for (
unsigned int i = 0; i <
n + 1; i++) {
189 pbar += (wg *
simplex(i).second);
191 double ybar = mfcn(pbar);
201 dirin *= std::sqrt(mfcn.
Up() /
simplex.Edm());
203 print.
Debug(
"End simplex edm =",
simplex.Edm(),
"pbar =", pbar,
"f(p) =", ybar);
213 print.
Warn(
"Simplex did not converge, #fcn calls exhausted");
218 print.
Warn(
"Simplex did not converge, edm > minedm");
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
const MnAlgebraicVector & Gstep() const
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
interface class for gradient calculators
unsigned int size() const
void TraceIteration(int iter, const MinimumState &state) const
const MnAlgebraicVector & Vec() const
const FunctionGradient & Gradient() const
const MinimumParameters & Parameters() const
const MnMachinePrecision & Precision() const
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
Wrapper class to FCNBase interface used internally by Minuit.
unsigned int NumOfCalls() const
Sets the relative floating point (double) arithmetic precision.
double Eps2() const
eps2 returns 2*sqrt(eps)
void Debug(const Ts &... args)
void Info(const Ts &... args)
void Warn(const Ts &... args)
API class for defining three levels of strategies: low (0), medium (1), high (>=2); acts on: Migrad (...
FunctionMinimum Minimum(const MnFcn &, const GradientCalculator &, const MinimumSeed &, const MnStrategy &, unsigned int, double) const override
class describing the simplex set of points (f(x), x ) which evolve during the minimization iteration ...
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.