62 std::cout <<
"Minimize using GSLSimAnMinimizer " << std::endl;
67 MATH_ERROR_MSG(
"GSLSimAnMinimizer::Minimize",
"Function has not been set");
73 if (debugLevel >= 1) {
74 std::cout <<
"Parameters for simulated annealing: " << std::endl;
79 std::cout <<
"no simulated annealing options available" << std::endl;
83 unsigned int npar =
NPar();
84 std::vector<double> xvar;
95 trFunc->InvStepTransformation(
X(),
StepSizes(), &steps[0]);
96 steps.resize( trFunc->NDim() );
99 assert (xvar.size() == steps.size() );
103 for (
unsigned int i = 0; i < npar ; ++i) {
104 std::cout <<
"x = " << xvar[i] <<
" steps " << steps[i] <<
" x " <<
X()[i] << std::endl;
106 std::cout <<
"f(x) = " << (*
ObjFunction())(xvar.data() ) << std::endl;
107 std::cout <<
"f(x) not transf = " << (*
ObjFunction())(
X() ) << std::endl;
108 if (trFunc) std::cout <<
"ftrans(x) = " << (*trFunc) ( xvar.data() ) << std::endl;
112 std::vector<double>
xmin(xvar.size() );
115 int iret =
fSolver.
Solve( (trFunc) ? *trFunc : *function, xvar.data(), steps.data(),
xmin.data(), (debugLevel > 1) );
121 if (debugLevel >=1 ) {
123 std::cout <<
"GSLSimAnMinimizer: Minimum Found" << std::endl;
125 std::cout <<
"GSLSimAnMinimizer: Error in solving" << std::endl;
127 int pr = std::cout.precision(18);
128 std::cout <<
"FVAL = " <<
MinValue() << std::endl;
129 std::cout.precision(pr);
130 for (
unsigned int i = 0; i <
NDim(); ++i)
131 std::cout <<
VariableName(i) <<
"\t = " <<
X()[i] << std::endl;
135 return ( iret == 0) ? true :
false;
144 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)
Base Minimizer class, which defines the basic functionality of various minimizer implementations (apa...
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 parameteres.
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.
virtual void Print(std::ostream &=std::cout) const
print options
void SetValue(const char *name, double val)
generic methods for retrieving options
bool GetValue(const char *name, T &t) const
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.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
structure holding the simulated annealing parameters
double k
parameters for the Boltzman distribution