47 result.push_back(state);
54 MnPrint::PrintState(std::cout, result.back(),
"VariableMetric: Iteration # ",result.size()-1);
78 std::cout<<
"VariableMetricBuilder convergence when edm < "<<edmval<<std::endl;
93 MN_INFO_MSG(
"VariableMetricBuilder: initial matrix not pos.def.");
99 std::vector<MinimumState> result;
108 std::cout <<
"VariableMetric: start iterating until Edm is < " << edmval << std::endl;
116 int maxfcn_eff = maxfcn;
125 std::cout <<
"start iterating... " << std::endl;
126 if (ipass > 0) std::cout <<
"continue iterating... " << std::endl;
129 min =
Minimum(fcn, gc, seed, result, maxfcn_eff, edmval);
134 MN_INFO_MSG(
"VariableMetricBuilder: FunctionMinimum is invalid, reached the function call limit");
143 MN_INFO_MSG(
"VariableMetricBuilder: FunctionMinimum is invalid after second try");
150 edm = result.back().
Edm();
157 std::cout<<
"MnMigrad will verify convergence and Error matrix. "<< std::endl;
158 std::cout<<
"dcov is = "<< min.
Error().
Dcovar() << std::endl;
163 if (printLevel > 1) {
171 std::cout <<
"edm after Hesse calculation " << edm <<
" requested " << edmval << std::endl;
176 if (edm >= machineLimit) {
179 MN_INFO_MSG(
"VariableMetricBuilder: Tolerance is not sufficient, continue the minimization");
186 MN_INFO_MSG(
"VariableMetricBuilder: Stop the minimization - reached machine accuracy limit");
187 MN_INFO_VAL2(
"Edm is smaller than machine accuracy",machineLimit);
203 if (ipass == 0) maxfcn_eff =
int(maxfcn*1.3);
210 if (edm > 10*edmval) {
213 MN_INFO_VAL2(
"VariableMetricBuilder: INVALID function minimum - edm is above tolerance,",edm);
214 MN_INFO_VAL2(
"VariableMetricBuilder: Required tolerance is 10 x edmval ",edmval);
221 MN_INFO_MSG(
"VariableMetricBuilder: Edm has been re-computed after Hesse");
222 MN_INFO_VAL2(
"new value is now smaller than the required tolerance,",edm);
225 min.
Add( result.back() );
229 std::cout <<
"Obtained function minimum " << min << std::endl;
251 double edm = initialState.
Edm();
255 std::cout <<
"\n\nDEBUG Variable Metric Builder \nInitial State: "
256 <<
" Parameter " << initialState.
Vec()
259 <<
" edm = " << initialState.
Edm() << std::endl;
272 assert(
s0.IsValid() );
278 step = -1.*
s0.Error().InvHessian()*
s0.Gradient().Vec();
281 std::cout <<
"\n\n---> Iteration - " << result.size()
282 <<
"\nFval = " <<
s0.Fval() <<
" numOfCall = " << fcn.
NumOfCalls()
283 <<
"\nInternal Parameter values " <<
s0.Vec()
284 <<
" Newton step " << step << std::endl;
290 std::cout <<
"VariableMetricBuilder: all derivatives are zero - return current status" << std::endl;
299 std::cout <<
" gdel = " << gdel << std::endl;
305 MN_INFO_MSG(
"VariableMetricBuilder: matrix not pos.def, gdel > 0");
310 step = -1.*
s0.Error().InvHessian()*
s0.Gradient().Vec();
330 MN_INFO_MSG(
"VariableMetricBuilder: no improvement in line search");
334 if (result.size() <= 1 )
346 std::cout <<
"Result after line search : \nx = " << pp.
X()
347 <<
"\nOld Fval = " <<
s0.Fval()
348 <<
"\nNew Fval = " << pp.
Y()
349 <<
"\nNFcalls = " << fcn.
NumOfCalls() << std::endl;
363 MN_INFO_MSG(
"VariableMetricBuilder: matrix not pos.def. : edm is < 0. Make pos def...");
370 MN_INFO_MSG(
"VariableMetricBuilder: matrix still not pos.def. : exit iterations ");
380 std::cout <<
"Updated new point: \n "
381 <<
" Parameter " << p.
Vec()
382 <<
" Gradient " <<
g.Vec()
383 <<
" InvHessian " <<
e.Matrix()
384 <<
" Hessian " <<
e.Hessian()
385 <<
" edm = " << edm << std::endl << std::endl;
397 edm *= (1. + 3.*
e.Dcovar());
400 std::cout <<
"Dcovar = " <<
e.Dcovar() <<
"\tCorrected edm = " << edm << std::endl;
405 }
while(edm > edmval && fcn.
NumOfCalls() < maxfcn);
408 if ( ! result.back().IsValid() )
414 MN_INFO_MSG(
"VariableMetricBuilder: call limit exceeded.");
420 if(edm <
fabs(prec.
Eps2()*result.back().Fval())) {
422 MN_INFO_MSG(
"VariableMetricBuilder: machine accuracy limits further improvement.");
425 }
else if(edm < 10*edmval) {
429 MN_INFO_MSG(
"VariableMetricBuilder: iterations finish without convergence.");
439 std::cout <<
"Exiting successfully Variable Metric Builder \n"
441 <<
"\nFval = " << result.back().Fval()
442 <<
"\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.
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.
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 &)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...