46 result.push_back(state);
53 MnPrint::PrintState(std::cout, result.back(),
"VariableMetric: Iteration # ",result.size()-1);
73 std::cout<<
"VariableMetricBuilder convergence when edm < "<<edmval<<std::endl;
88 MN_INFO_MSG(
"VariableMetricBuilder: initial matrix not pos.def.");
94 std::vector<MinimumState> result;
103 std::cout <<
"VariableMetric: start iterating until Edm is < " << edmval << std::endl;
111 int maxfcn_eff = maxfcn;
120 std::cout <<
"start iterating... " << std::endl;
121 if (ipass > 0) std::cout <<
"continue iterating... " << std::endl;
124 min =
Minimum(fcn, gc, seed, result, maxfcn_eff, edmval);
129 MN_INFO_MSG(
"VariableMetricBuilder: FunctionMinimum is invalid, reached the function call limit");
138 MN_INFO_MSG(
"VariableMetricBuilder: FunctionMinimum is invalid after second try");
145 edm = result.back().
Edm();
152 std::cout<<
"MnMigrad will verify convergence and Error matrix. "<< std::endl;
153 std::cout<<
"dcov is = "<< min.
Error().
Dcovar() << std::endl;
158 if (printLevel > 1) {
166 std::cout <<
"edm after Hesse calculation " << edm <<
" requested " << edmval << std::endl;
171 if (edm >= machineLimit) {
174 MN_INFO_MSG(
"VariableMetricBuilder: Tolerance is not sufficient, continue the minimization");
181 MN_INFO_MSG(
"VariableMetricBuilder: Stop the minimization - reached machine accuracy limit");
182 MN_INFO_VAL2(
"Edm is smaller than machine accuracy",machineLimit);
198 if (ipass == 0) maxfcn_eff = int(maxfcn*1.3);
205 if (edm > 10*edmval) {
208 MN_INFO_VAL2(
"VariableMetricBuilder: INVALID function minimum - edm is above tolerance,",edm);
209 MN_INFO_VAL2(
"VariableMetricBuilder: Required tolerance is 10 x edmval ",edmval);
216 MN_INFO_MSG(
"VariableMetricBuilder: Edm has been re-computed after Hesse");
217 MN_INFO_VAL2(
"new value is now smaller than the required tolerance,",edm);
220 min.
Add( result.back() );
224 std::cout <<
"Obtained function minimum " << min << std::endl;
246 double edm = initialState.
Edm();
250 std::cout <<
"\n\nDEBUG Variable Metric Builder \nInitial State: "
251 <<
" Parameter " << initialState.
Vec()
254 <<
" edm = " << initialState.
Edm() << std::endl;
267 assert(
s0.IsValid() );
273 step = -1.*
s0.Error().InvHessian()*
s0.Gradient().Vec();
276 std::cout <<
"\n\n---> Iteration - " << result.size()
277 <<
"\nFval = " <<
s0.Fval() <<
" numOfCall = " << fcn.
NumOfCalls()
278 <<
"\nInternal Parameter values " <<
s0.Vec()
279 <<
" Newton step " << step << std::endl;
285 std::cout <<
"VariableMetricBuilder: all derivatives are zero - return current status" << std::endl;
294 std::cout <<
" gdel = " << gdel << std::endl;
300 MN_INFO_MSG(
"VariableMetricBuilder: matrix not pos.def, gdel > 0");
305 step = -1.*
s0.Error().InvHessian()*
s0.Gradient().Vec();
325 MN_INFO_MSG(
"VariableMetricBuilder: no improvement in line search");
329 if (result.size() <= 1 )
341 std::cout <<
"Result after line search : \nx = " << pp.
X()
342 <<
"\nOld Fval = " <<
s0.Fval()
343 <<
"\nNew Fval = " << pp.
Y()
344 <<
"\nNFcalls = " << fcn.
NumOfCalls() << std::endl;
358 MN_INFO_MSG(
"VariableMetricBuilder: matrix not pos.def. : edm is < 0. Make pos def...");
365 MN_INFO_MSG(
"VariableMetricBuilder: matrix still not pos.def. : exit iterations ");
375 std::cout <<
"Updated new point: \n "
376 <<
" Parameter " << p.
Vec()
377 <<
" Gradient " <<
g.Vec()
378 <<
" InvHessian " <<
e.Matrix()
379 <<
" Hessian " <<
e.Hessian()
380 <<
" edm = " << edm << std::endl << std::endl;
392 edm *= (1. + 3.*
e.Dcovar());
395 std::cout <<
"Dcovar = " <<
e.Dcovar() <<
"\tCorrected edm = " << edm << std::endl;
400 }
while(edm > edmval && fcn.
NumOfCalls() < maxfcn);
403 if ( ! result.back().IsValid() )
409 MN_INFO_MSG(
"VariableMetricBuilder: call limit exceeded.");
415 if(edm <
fabs(prec.
Eps2()*result.back().Fval())) {
417 MN_INFO_MSG(
"VariableMetricBuilder: machine accuracy limits further improvement.");
420 }
else if(edm < 10*edmval) {
424 MN_INFO_MSG(
"VariableMetricBuilder: iterations finish without convergence.");
434 std::cout <<
"Exiting successfully Variable Metric Builder \n"
436 <<
"\nFval = " << result.back().Fval()
437 <<
"\nedm = " << edm <<
" requested = " << edmval << std::endl;
#define MN_INFO_VAL2(loc, x)
const MnAlgebraicVector & Vec() const
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
void Add(const MinimumState &state)
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
MinimumSeed contains the starting values for the minimization produced by the SeedGenerator.
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.
determines the relative floating point 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.
static void PrintState(std::ostream &os, const MinimumState &state, const char *msg, int iter=-1)
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)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
double inner_product(const LAVector &, const LAVector &)
Namespace for new ROOT classes and functions.