61 std::cout <<
"Minimize using GSLSimAnMinimizer " << std::endl;
65 if (function ==
nullptr) {
66 MATH_ERROR_MSG(
"GSLSimAnMinimizer::Minimize",
"Function has not been set");
72 if (debugLevel >= 1) {
73 std::cout <<
"Parameters for simulated annealing: " << std::endl;
78 std::cout <<
"no simulated annealing options available" << std::endl;
82 unsigned int npar =
NPar();
83 std::vector<double> xvar;
94 trFunc->InvStepTransformation(
X(),
StepSizes(), &steps[0]);
95 steps.resize( trFunc->NDim() );
98 assert (xvar.size() == steps.size() );
102 for (
unsigned int i = 0; i < npar ; ++i) {
103 std::cout <<
"x = " << xvar[i] <<
" steps " << steps[i] <<
" x " <<
X()[i] << std::endl;
105 std::cout <<
"f(x) = " << (*
ObjFunction())(xvar.data() ) << std::endl;
106 std::cout <<
"f(x) not transf = " << (*
ObjFunction())(
X() ) << std::endl;
107 if (trFunc) std::cout <<
"ftrans(x) = " << (*trFunc) ( xvar.data() ) << std::endl;
111 std::vector<double>
xmin(xvar.size() );
114 int iret =
fSolver.
Solve( (trFunc) ? *trFunc : *function, xvar.data(), steps.data(),
xmin.data(), (debugLevel > 1) );
120 if (debugLevel >=1 ) {
122 std::cout <<
"GSLSimAnMinimizer: Minimum Found" << std::endl;
124 std::cout <<
"GSLSimAnMinimizer: Error in solving" << std::endl;
126 int pr = std::cout.precision(18);
127 std::cout <<
"FVAL = " <<
MinValue() << std::endl;
128 std::cout.precision(pr);
129 for (
unsigned int i = 0; i <
NDim(); ++i)
130 std::cout <<
VariableName(i) <<
"\t = " <<
X()[i] << std::endl;
134 return ( iret == 0) ? true :
false;
143 if (gf)
return gf->
NCalls();
#define MATH_ERROR_MSG(loc, str)
FitMethodFunction class Interface for objective functions (like chi2 and likelihood used in the fit) ...
virtual unsigned int NCalls() const
return the total number of function calls (override if needed)
virtual unsigned int NPar() const
total number of parameter defined
unsigned int NDim() const override
number of dimensions
void SetMinValue(double val)
void SetFinalValues(const double *x, const MinimTransformFunction *func=nullptr)
double MinValue() const override
return minimum function value
MinimTransformFunction * CreateTransformation(std::vector< double > &startValues, const ROOT::Math::IMultiGradFunction *func=nullptr)
virtual const double * StepSizes() const
accessor methods
const ROOT::Math::IMultiGenFunction * ObjFunction() const
return pointer to used objective function
const double * X() const override
return pointer to X values at the minimum
std::string VariableName(unsigned int ivar) const override
get name of variables (override if minimizer support storing of variable names)
bool Minimize() override
method to perform the minimization
void SetParameters(const GSLSimAnParams ¶ms)
set new minimizer option parameters using directly the GSLSimAnParams structure
GSLSimAnMinimizer(int type=0)
Default constructor.
void DoSetSimAnParameters(const MinimizerOptions &opt)
set minimizer option parameters from stored ROOT::Math::MinimizerOptions (fOpt)
unsigned int NCalls() const override
number of calls
const GSLSimAnParams & MinimizerParameters() const
Get current minimizer option parameters.
ROOT::Math::GSLSimAnnealing fSolver
~GSLSimAnMinimizer() override
Destructor (no operations)
void DoSetMinimOptions(const GSLSimAnParams ¶ms)
Set the Minimizer options from the simulated annealing parameters.
int Solve(const ROOT::Math::IMultiGenFunction &func, const double *x0, const double *scale, double *xmin, bool debug=false)
solve the simulated annealing given a multi-dim function, the initial vector parameters and a vector ...
class implementing generic options for a numerical algorithm Just store the options in a map of strin...
Documentation for the abstract class IBaseFunctionMultiDim.
Generic interface for defining configuration options of a numerical algorithm.
void SetValue(const char *name, double val)
generic methods for retrieving options
bool GetValue(const char *name, T &t) const
virtual void Print(std::ostream &=std::cout) const
print options
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
void SetStrategy(int stra)
set the strategy
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
const IOptions * ExtraOptions() const
return extra options (NULL pointer if they are not present)
void SetMinimizerType(const char *type)
set minimizer type
void SetExtraOptions(const IOptions &opt)
set extra options (in this case pointer is cloned)
void SetPrecision(double prec)
set the precision
void SetErrorDef(double err)
set error def
void SetPrintLevel(int level)
set print level
void SetMinimizerAlgorithm(const char *type)
set minimizer algorithm
void SetTolerance(double tol)
set the tolerance
MinimizerOptions fOptions
minimizer options
int PrintLevel() const
minimizer configuration parameters
MultiNumGradFunction class to wrap a normal function in a gradient function using numerical gradient ...
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
structure holding the simulated annealing parameters
double k
parameters for the Boltzman distribution