35 MnPrint print(
"NegativeG2LineSearch");
41 print.
Info(
"Doing a NegativeG2LineSearch since one of the G2 component is negative");
47 unsigned int iter = 0;
50 print.
Debug(
"Gradient ", dgrad.
Vec(),
"G2",dgrad.
G2());
55 print.
Error(
"Input gradient to NG2LS must have G2 already computed");
58 bool computeHessian =
false;
62 for (
unsigned int i = 0; i <
n; i++) {
64 if (dgrad.
G2()(i) <= 0) {
68 if (std::fabs(dgrad.
Vec()(i)) < prec.
Eps() && std::fabs(dgrad.
G2()(i)) < prec.
Eps())
75 if (dgrad.
Vec()(i) < 0)
76 step(i) = (hasGStep) ? dgrad.
Gstep()(i) : 1;
78 step(i) = (hasGStep) ? -dgrad.
Gstep()(i) : -1;
80 double gdel = step(i) * dgrad.
Vec()(i);
85 print.
Debug(
"Iter", iter,
"param", i, pa.
Vec()(i),
"grad2", dgrad.
G2()(i),
"grad",
86 dgrad.
Vec()(i),
"grad step", step(i),
" gdel ", gdel);
90 print.
Debug(
"Line search result", pp.
X(),
"f(0)", pa.
Fval(),
"f(1)", pp.
Y());
95 dgrad =
gc(pa, dgrad);
98 computeHessian =
true;
99 print.
Debug(
"Compute Hessian at the new point", pa.
Vec());
100 bool ret =
gc.Hessian(pa,mat);
102 print.
Error(
"Cannot compute Hessian");
107 for (
unsigned int j = 0; j <
n; j++)
112 print.
Debug(
"New result after Line search - iter", iter,
"param", i, pa.
Vec()(i),
"step", step(i),
"new grad2",
113 dgrad.
G2()(i),
"new grad", dgrad.
Vec()(i));
119 }
while (iter++ < 2 *
n &&
iterate);
122 if (!computeHessian) {
123 print.
Info(
"Approximate covariance using only G2");
124 for (
unsigned int i = 0; i <
n; i++) {
125 mat(i, i) = (std::fabs(dgrad.
G2()(i)) > prec.
Eps2() ? 1. / dgrad.
G2()(i) :
126 (dgrad.
G2()(i) >= 0) ? 1./prec.
Eps2() : -1./prec.
Eps2());
144 for (
unsigned int i = 0; i < grad.
Vec().
size(); i++)
146 if (grad.
G2()(i) <= 0) {
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
bool IsAnalytical() const
const MnAlgebraicVector & Gstep() const
const MnAlgebraicVector & Grad() const
const MnAlgebraicVector & Vec() const
const MnAlgebraicVector & G2() const
interface class for gradient calculators
Class describing a symmetric matrix of size n.
unsigned int size() const
MinimumError keeps the inv.
const MnAlgebraicVector & Vec() const
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
const MinimumParameters & Parameters() const
const FunctionGradient & Gradient() const
Wrapper class to FCNBase interface used internally by Minuit.
unsigned int NumOfCalls() const
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.
void Debug(const Ts &... args)
void Error(const Ts &... args)
void Info(const Ts &... args)
bool HasNegativeG2(const FunctionGradient &, const MnMachinePrecision &) const
MinimumState operator()(const MnFcn &, const MinimumState &, const GradientCalculator &, const MnMachinePrecision &) const
double Estimate(const FunctionGradient &, const MinimumError &) const
int iterate(rng_state_t *X)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.