53 if (niter <=0 ) niter = 1000;
66 if (ivar >
fValues.size() )
return false;
80 std::map<unsigned int, std::pair<double, double> >::iterator iter =
fBounds.find(ivar);
91 if (!ret)
return false;
92 const double upper = std::numeric_limits<double>::infinity();
93 fBounds[ivar] = std::make_pair( lower, upper);
100 if (!ret)
return false;
101 const double lower = -std::numeric_limits<double>::infinity();
102 fBounds[ivar] = std::make_pair( lower, upper);
110 if (!ret)
return false;
111 fBounds[ivar] = std::make_pair( lower, upper);
119 if (!ret)
return false;
128 if (ivar >=
fValues.size() )
return false;
135 if (
x == 0)
return false;
142 if (ivar >
fValues.size() )
return false;
149 double upper = (
fBounds.count(ivar)) ?
fBounds[ivar].second : std::numeric_limits<double>::infinity();
155 double lower = (
fBounds.count(ivar)) ?
fBounds[ivar].
first : - std::numeric_limits<double>::infinity();
161 if (ivar >
fVarTypes.size() )
return false;
163 fBounds[ivar] = std::make_pair( lower, upper);
164 if (lower > upper || (lower == - std::numeric_limits<double>::infinity() &&
165 upper == std::numeric_limits<double>::infinity() ) ) {
169 else if (lower == upper)
172 if (lower == - std::numeric_limits<double>::infinity() )
174 else if (upper == std::numeric_limits<double>::infinity() )
184 if (ivar >=
fVarTypes.size() )
return false;
191 if (ivar >=
fVarTypes.size() )
return false;
192 if (
fBounds.count(ivar) == 0) {
196 if (
fBounds[ivar].
first == - std::numeric_limits<double>::infinity() )
198 else if (
fBounds[ivar].second == std::numeric_limits<double>::infinity() )
207 if (ivar >=
fVarTypes.size() )
return false;
212 if (ivar >=
fValues.size() )
return false;
215 std::map< unsigned int , std::pair< double, double> >::const_iterator itr =
fBounds.find(ivar);
217 double lower = (itr->second).
first;
218 double upper = (itr->second).second;
228 if (ivar >=
fNames.size() )
return "";
233 std::vector<std::string>::const_iterator itr = std::find(
fNames.begin(),
fNames.end(),
name);
234 if (itr ==
fNames.end() )
return -1;
235 return itr -
fNames.begin();
255 unsigned int npar =
fValues.size();
256 if (npar == 0 || npar <
fDim ) {
257 MATH_ERROR_MSGVAL(
"BasicMinimizer::CheckDimension",
"Wrong number of parameters",npar);
265 MATH_ERROR_MSG(
"BasicMinimizer::CheckFunction",
"Function has not been set");
274 bool doTransform = (
fBounds.size() > 0);
275 unsigned int ivar = 0;
276 while (!doTransform && ivar <
fVarTypes.size() ) {
280 startValues = std::vector<double>(
fValues.begin(),
fValues.end() );
288 doTransform &= (gradObjFunc != 0);
297 startValues.resize( trFunc->
NDim() );
337 int pr = std::cout.precision(18);
338 std::cout <<
"FVAL = " <<
fMinVal << std::endl;
339 std::cout.precision(pr);
341 std::cout <<
"Niterations = " <<
NIterations() << std::endl;
342 unsigned int ncalls =
NCalls();
343 if (ncalls) std::cout <<
"NCalls = " << ncalls << std::endl;
344 for (
unsigned int i = 0; i <
fDim; ++i)
345 std::cout <<
fNames[i] <<
"\t = " <<
fValues[i] << std::endl;
358 unsigned int nfree =
fValues.size();
359 for (
unsigned int i = 0; i <
fVarTypes.size(); ++i)
#define MATH_ERROR_MSGVAL(loc, txt, x)
#define MATH_ERROR_MSG(loc, str)
Class, describing value, limits and step size of the parameters Provides functionality also to set/re...
void Set(const std::string &name, double value, double step)
set value and name (unlimited parameter)
void SetLimits(double low, double up)
set a double side limit, if low == up the parameter is fixed if low > up the limits are removed The c...
void SetUpperLimit(double up)
set a single upper limit
void Fix()
fix the parameter
void SetLowerLimit(double low)
set a single lower limit
virtual ~BasicMinimizer()
Destructor.
virtual unsigned int NFree() const
number of free variables (real dimension of the problem)
virtual bool GetVariableSettings(unsigned int ivar, ROOT::Fit::ParameterSettings &varObj) const
get variable settings in a variable object (like ROOT::Fit::ParamsSettings)
void PrintResult() const
print result of minimization
BasicMinimizer()
Default constructor.
const ROOT::Math::IMultiGenFunction * fObjFunc
virtual bool IsFixedVariable(unsigned int ivar) const
query if an existing variable is fixed (i.e.
std::vector< ROOT::Math::EMinimVariableType > fVarTypes
const ROOT::Math::MinimTransformFunction * TransformFunction() const
return transformation function (NULL if not having a transformation)
bool CheckObjFunction() const
virtual bool SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double, double)
set upper/lower limited variable (override if minimizer supports them )
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)
set the function to minimize
virtual bool SetVariable(unsigned int ivar, const std::string &name, double val, double step)
set free variable
virtual bool FixVariable(unsigned int ivar)
fix an existing variable
virtual unsigned int NDim() const
number of dimensions
virtual bool SetUpperLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double upper)
set upper limit variable (override if minimizer supports them )
virtual bool SetVariableLimits(unsigned int ivar, double lower, double upper)
set the limits of an already existing variable
std::vector< double > fSteps
virtual bool SetVariableValues(const double *x)
set the values of all existing variables (array must be dimensioned to the size of existing parameter...
virtual bool SetVariableStepSize(unsigned int ivar, double step)
set the step size of an already existing variable
virtual bool ReleaseVariable(unsigned int ivar)
release an existing variable
virtual std::string VariableName(unsigned int ivar) const
get name of variables (override if minimizer support storing of variable names)
std::map< unsigned int, std::pair< double, double > > fBounds
virtual bool SetVariableValue(unsigned int ivar, double val)
set the value of an existing variable
void SetFinalValues(const double *x)
virtual bool SetFixedVariable(unsigned int, const std::string &, double)
set fixed variable (override if minimizer supports them )
bool CheckDimension() const
virtual bool SetVariableLowerLimit(unsigned int ivar, double lower)
set the lower-limit of an already existing variable
virtual bool Minimize()
method to perform the minimization
MinimTransformFunction * CreateTransformation(std::vector< double > &startValues, const ROOT::Math::IMultiGradFunction *func=0)
virtual int VariableIndex(const std::string &name) const
get index of variable given a variable given a name return -1 if variable is not found
std::vector< double > fValues
virtual bool SetLowerLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double lower)
set lower limit variable (override if minimizer supports them )
const ROOT::Math::IMultiGradFunction * GradObjFunction() const
return pointer to used gradient object function (NULL if gradient is not supported)
std::vector< std::string > fNames
virtual bool SetVariableUpperLimit(unsigned int ivar, double upper)
set the upper-limit of an already existing variable
Documentation for the abstract class IBaseFunctionMultiDim.
virtual IBaseFunctionMultiDimTempl< T > * Clone() const =0
Clone a function.
virtual unsigned int NDim() const =0
Retrieve the dimension of the function.
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
static int DefaultPrintLevel()
static int DefaultMaxIterations()
virtual unsigned int NIterations() const
number of iterations to reach the minimum
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
void SetPrintLevel(int level)
set print level
virtual unsigned int NCalls() const
number of function calls to reach the minimum
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...