45 MnPrint print(
"MnSeedGenerator");
51 print.
Info(
"Computing seed using NumericalGradient calculator");
53 print.
Debug(
n,
"free parameters, FCN pointer", &fcn);
57 for (
unsigned int i = 0; i <
n; i++)
59 double fcnmin = fcn(
x);
66 for (
unsigned int i = 0; i <
n; i++)
67 for (
unsigned int j = i; j <
n; j++)
71 for (
unsigned int i = 0; i <
n; i++)
72 mat(i, i) = (std::fabs(dgrad.
G2()(i)) > prec.
Eps2() ? 1. / dgrad.
G2()(i) :
73 (dgrad.
G2()(i) >= 0) ? 1./prec.
Eps2() : -1./prec.
Eps2());
84 print.
Debug(
"Negative G2 Found",
"\n point:",
x,
"\n grad :", dgrad.
Grad(),
"\n g2 :", dgrad.
G2());
86 state = ng2ls(fcn, state,
gc, prec);
88 print.
Info(
"Negative G2 found - new state:", state);
94 print.
Debug(
"calling MnHesse");
98 print.
Info(
"run Hesse - Initial seeding state:", tmp);
103 print.
Info(
"Initial state ",state);
111 MnPrint print(
"MnSeedGenerator");
118 if (!
gc.CanComputeG2()) {
123 print.
Info(
"Computing seed using analytical (external) gradients");
131 for (
unsigned int i = 0; i <
n; i++)
133 double fcnmin = fcn(
x);
141 bool computedHessian =
false;
143 assert(
gc.CanComputeHessian());
145 bool ret =
gc.Hessian(pa, hmat);
147 print.
Error(
"Cannot compute G2 and Hessian");
152 for (
unsigned int i = 0; i <
n; i++)
156 print.
Debug(
"Computed analytical G2",g2);
162 if (computedHessian) {
164 print.
Info(
"Use full Hessian as seed");
165 print.
Debug(
"computed Hessian",hmat);
166 print.
Debug(
"computed Error matrix (H^-1)",mat);
170 if (!computedHessian) {
173 print.
Info(
"Using existing covariance matrix");
174 for (
unsigned int i = 0; i <
n; i++)
175 for (
unsigned int j = i; j <
n; j++)
179 for (
unsigned int i = 0; i <
n; i++) {
181 mat(i, i) = (std::fabs(grad.
G2()(i)) > prec.
Eps2() ? 1. / grad.
G2()(i)
182 : (grad.
G2()(i) >= 0) ? 1. / prec.
Eps2()
183 : -1. / prec.
Eps2());
188 print.
Info(
"Computing seed using full Hessian");
195 print.
Error(
"Cannot compute seed because G2 is not computed");
202 state = ng2ls(fcn, state,
gc, prec);
209 print.
Info(
"Initial seeding state ",tmpState);
213 print.
Info(
"Initial seeding state ",state);
234 std::pair<FunctionGradient, MnAlgebraicVector> hgrd = hgc.DeltaGradient(pa, dgrad);
235 for (
unsigned int i = 0; i <
n; i++) {
236 if (std::fabs(hgrd.first.Grad()(i) - grd.
Grad()(i)) > hgrd.second(i)) {
237 int externalParameterIndex = trafo.
ExtOfInt(i);
238 const char *parameter_name = trafo.
Name(externalParameterIndex);
239 print.Warn(
"Gradient discrepancy of external Parameter too large:"
241 parameter_name,
"externalParameterIndex =", externalParameterIndex,
"internal =", i);
246 print.Error(
"Minuit does not accept user specified Gradient. To force acceptance, override 'virtual bool "
247 "CheckGradient() const' of FCNGradientBase.h in the derived class.");
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
const MnAlgebraicVector & Gstep() const
const MnAlgebraicVector & Grad() const
const MnAlgebraicVector & G2() const
interface class for gradient calculators
HessianGradientCalculator: class to calculate Gradient for Hessian.
Class to calculate an initial estimate of the gradient.
Class describing a symmetric matrix of size n.
MinimumError keeps the inv.
static MnAlgebraicSymMatrix InvertMatrix(const MnAlgebraicSymMatrix &matrix, int &ifail)
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
const MinimumParameters & Parameters() 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...
Sets the relative floating point (double) arithmetic precision.
double Eps2() const
eps2 returns 2*sqrt(eps)
void Debug(const Ts &... args)
void Error(const Ts &... args)
void Info(const Ts &... args)
MinimumSeed operator()(const MnFcn &, const GradientCalculator &, const MnUserParameterState &, const MnStrategy &) const override
API class for defining three levels of strategies: low (0), medium (1), high (>=2); acts on: Migrad (...
unsigned int Strategy() const
class which holds the external user and/or internal Minuit representation of the parameters and error...
const MnMachinePrecision & Precision() const
unsigned int VariableParameters() const
const std::vector< double > & IntParameters() const
const MnUserTransformation & Trafo() const
const MnUserCovariance & IntCovariance() const
bool HasCovariance() const
In case that one of the components of the second derivative g2 calculated by the numerical Gradient c...
bool HasNegativeG2(const FunctionGradient &, const MnMachinePrecision &) const
class performing the numerical gradient calculation
double Estimate(const FunctionGradient &, const MinimumError &) const
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.