42 result.push_back(state);
55 const MnStrategy &strategy,
unsigned int maxfcn,
double edmval)
const
78 print.
Warn(
"No free parameters.");
83 print.
Error(
"Minimum seed invalid.");
88 print.
Error(
"Initial matrix not pos.def.");
94 std::vector<MinimumState> result;
101 print.
Info(
"Start iterating until Edm is <", edmval,
"with call limit =", maxfcn);
106 int maxfcn_eff = maxfcn;
109 bool hessianComputed =
false;
114 hessianComputed =
false;
116 print.
Debug(ipass > 0 ?
"Continue" :
"Start",
"iterating...");
118 min =
Minimum(fcn, gc, seed, result, maxfcn_eff, edmval);
122 print.
Warn(
"FunctionMinimum is invalid, reached function call limit");
129 print.
Warn(
"FunctionMinimum is invalid after second try");
135 edm = result.back().
Edm();
140 print.
Debug(
"MnMigrad will verify convergence and Error matrix; dcov =", min.
Error().
Dcovar());
144 hessianComputed =
true;
146 print.
Info(
"After Hessian");
151 print.
Warn(
"Invalid Hessian - exit the minimization");
158 print.
Debug(
"New Edm", edm,
"Requested", edmval);
162 double machineLimit = std::fabs(seed.
Precision().
Eps2() * result.back().Fval());
163 if (edm >= machineLimit) {
166 print.
Info(
"Tolerance not sufficient, continue minimization; "
168 edm,
"Required", edmval);
170 print.
Warn(
"Reached machine accuracy limit; Edm", edm,
"is smaller than machine limit", machineLimit,
171 "while", edmval,
"was requested");
183 maxfcn_eff =
int(maxfcn * 1.3);
189 if (edm > 10 * edmval) {
191 print.
Warn(
"No convergence; Edm", edm,
"is above tolerance", 10 * edmval);
195 print.
Info(
"Edm has been re-computed after Hesse; Edm", edm,
"is now within tolerance");
198 min.
Add(result.back());
201 print.
Debug(
"Minimum found", min);
207 std::vector<MinimumState> &result,
unsigned int maxfcn,
224 double edm = initialState.
Edm();
226 print.
Debug(
"Initial State:",
"\n Parameter:", initialState.
Vec(),
"\n Gradient:", initialState.
Gradient().
Vec(),
242 step = -1. *
s0.Error().InvHessian() *
s0.Gradient().Vec();
244 print.
Debug(
"Iteration", result.size(),
"Fval",
s0.Fval(),
"numOfCall", fcn.
NumOfCalls(),
245 "\n Internal parameters",
s0.Vec(),
"\n Newton step", step);
249 print.
Debug(
"all derivatives are zero - return current status");
256 print.
Warn(
"Matrix not pos.def, gdel =", gdel,
"> 0");
260 step = -1. *
s0.Error().InvHessian() *
s0.Gradient().Vec();
267 print.
Warn(
"gdel =", gdel);
279 if (std::fabs(pp.
Y() -
s0.Fval()) <= std::fabs(
s0.Fval()) * prec.
Eps()) {
281 print.
Warn(
"No improvement in line search");
285 if (result.size() <= 1)
294 print.
Debug(
"Result after line search :",
"\n x =", pp.
X(),
"\n Old Fval =",
s0.Fval(),
295 "\n New Fval =", pp.
Y(),
"\n NFcalls =", fcn.
NumOfCalls());
303 if (std::isnan(edm)) {
304 print.
Warn(
"Edm is NaN; stop iterations");
310 print.
Warn(
"Matrix not pos.def., try to make pos.def.");
316 print.
Warn(
"Matrix still not pos.def.; stop iterations");
326 print.
Debug(
"Updated new point:",
"\n Parameter:", p.
Vec(),
"\n Gradient:",
g.Vec(),
327 "\n InvHessian:",
e.Matrix(),
"\n Edm:", edm);
338 edm *= (1. + 3. *
e.Dcovar());
340 print.
Debug(
"Dcovar =",
e.Dcovar(),
"\tCorrected edm =", edm);
342 }
while (edm > edmval && fcn.
NumOfCalls() < maxfcn);
348 if (!result.back().IsValid())
352 print.
Warn(
"Call limit exceeded");
358 if (edm < std::fabs(prec.
Eps2() * result.back().Fval())) {
359 print.
Warn(
"Machine accuracy limits further improvement");
362 }
else if (edm < 10 * edmval) {
365 print.
Warn(
"Iterations finish without convergence; Edm", edm,
"Requested", edmval);
372 print.
Debug(
"Exiting successfully;",
"Ncalls", fcn.
NumOfCalls(),
"FCN", result.back().Fval(),
"Edm", edm,
373 "Requested", edmval);
const MnAlgebraicVector & Vec() const
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
void Add(const MinimumState &state, Status status=MnValid)
add latest minimization state (for example add Hesse result after Migrad)
const MinimumError & Error() const
bool HasReachedCallLimit() const
const MinimumState & State() const
bool IsAboveMaxEdm() const
const MinimumSeed & Seed() const
interface class for gradient calculators
unsigned int size() const
void TraceIteration(int iter, const MinimumState &state) const
virtual MinimumError Update(const MinimumState &, const MinimumParameters &, const FunctionGradient &) const =0
MinimumError keeps the inv.
const MnAlgebraicSymMatrix & InvHessian() const
const MnAlgebraicVector & Vec() const
const MnUserTransformation & Trafo() const
const MinimumParameters & Parameters() const
const MnMachinePrecision & Precision() const
const MinimumState & State() const
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
const MinimumError & Error() const
const MnAlgebraicVector & Vec() const
const FunctionGradient & Gradient() const
Wrapper class to FCNBase interface used internally by Minuit.
unsigned int NumOfCalls() const
API class for calculating the numerical covariance matrix (== 2x Inverse Hessian == 2x Inverse 2nd de...
Implements a 1-dimensional minimization along a given direction (i.e.
Sets the relative floating point (double) arithmetic precision.
double Eps() const
eps returns the smallest possible number so that 1.+eps > 1.
double Eps2() const
eps2 returns 2*sqrt(eps)
double Y() const
Accessor to the y (second) coordinate.
double X() const
Accessor to the x (first) coordinate.
Force the covariance matrix to be positive defined by adding extra terms in the diagonal.
void Debug(const Ts &... args)
void Error(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 (...
unsigned int Strategy() const
void AddResult(std::vector< MinimumState > &result, const MinimumState &state) const
const VariableMetricEDMEstimator & Estimator() const
virtual FunctionMinimum Minimum(const MnFcn &, const GradientCalculator &, const MinimumSeed &, const MnStrategy &, unsigned int, double) const
const MinimumErrorUpdator & ErrorUpdator() const
double Estimate(const FunctionGradient &, const MinimumError &) const
int iterate(rng_state_t *X)
double inner_product(const LAVector &, const LAVector &)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...