50 if (niter <=0 ) niter = 1000;
63 if (ivar >
fValues.size() )
return false;
77 std::map<unsigned int, std::pair<double, double> >::iterator
iter =
fBounds.find(ivar);
88 if (!ret)
return false;
90 fBounds[ivar] = std::make_pair( lower, upper);
97 if (!ret)
return false;
99 fBounds[ivar] = std::make_pair( lower, upper);
107 if (!ret)
return false;
108 fBounds[ivar] = std::make_pair( lower, upper);
116 if (!ret)
return false;
125 if (ivar >
fValues.size() )
return false;
132 if (x == 0)
return false;
139 if (ivar >
fValues.size() )
return false;
158 if (ivar >
fVarTypes.size() )
return false;
160 fBounds[ivar] = std::make_pair( lower, upper);
166 else if (lower == upper)
181 if (ivar >
fVarTypes.size() )
return false;
188 if (ivar >
fVarTypes.size() )
return false;
189 if (
fBounds.count(ivar) == 0) {
204 if (ivar >
fVarTypes.size() )
return false;
209 if (ivar >
fValues.size() )
return false;
212 std::map< unsigned int , std::pair< double, double> >::const_iterator itr =
fBounds.find(ivar);
214 double lower = (itr->second).first;
215 double upper = (itr->second).second;
225 if (ivar >
fNames.size() )
return "";
230 std::vector<std::string>::const_iterator itr = std::find(
fNames.begin(),
fNames.end(),
name);
231 if (itr ==
fNames.end() )
return -1;
232 return itr -
fNames.begin();
252 unsigned int npar =
fValues.size();
253 if (npar == 0 || npar <
fDim ) {
254 MATH_ERROR_MSGVAL(
"BasicMinimizer::CheckDimension",
"Wrong number of parameters",npar);
262 MATH_ERROR_MSG(
"BasicMinimizer::CheckFunction",
"Function has not been set");
271 bool doTransform = (
fBounds.size() > 0);
272 unsigned int ivar = 0;
273 while (!doTransform && ivar <
fVarTypes.size() ) {
277 startValues = std::vector<double>(
fValues.begin(),
fValues.end() );
285 doTransform &= (gradObjFunc != 0);
291 trFunc->InvTransformation(&
fValues.front(), &startValues[0]);
294 startValues.resize( trFunc->NDim() );
334 int pr = std::cout.precision(18);
335 std::cout <<
"FVAL = " <<
fMinVal << std::endl;
336 std::cout.precision(pr);
338 std::cout <<
"Niterations = " <<
NIterations() << std::endl;
339 unsigned int ncalls =
NCalls();
340 if (ncalls) std::cout <<
"NCalls = " << ncalls << std::endl;
341 for (
unsigned int i = 0; i <
fDim; ++i)
342 std::cout <<
fNames[i] <<
"\t = " <<
fValues[i] << std::endl;
355 unsigned int nfree =
fValues.size();
356 for (
unsigned int i = 0; i <
fVarTypes.size(); ++i)
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
virtual bool SetVariableUpperLimit(unsigned int ivar, double upper)
set the upper-limit of an already existing variable
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
std::vector< ROOT::Math::EMinimVariableType > fVarTypes
Namespace for new ROOT classes and functions.
virtual bool SetVariableStepSize(unsigned int ivar, double step)
set the step size of an already existing variable
virtual bool SetFixedVariable(unsigned int, const std::string &, double)
set fixed variable (override if minimizer supports them )
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 ...
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 )
Class, describing value, limits and step size of the parameters Provides functionality also to set/re...
virtual bool SetVariableValues(const double *x)
set the values of all existing variables (array must be dimensioned to the size of existing parameter...
void PrintResult() const
print result of minimization
virtual bool SetVariableLowerLimit(unsigned int ivar, double lower)
set the lower-limit of an already existing variable
MinimTransformFunction * CreateTransformation(std::vector< double > &startValues, const ROOT::Math::IMultiGradFunction *func=0)
virtual bool SetVariableLimits(unsigned int ivar, double lower, double upper)
set the limits of an already existing variable
virtual bool SetVariable(unsigned int ivar, const std::string &name, double val, double step)
set free variable
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::IMultiGenFunction * fObjFunc
#define MATH_ERROR_MSGVAL(loc, str, x)
virtual bool GetVariableSettings(unsigned int ivar, ROOT::Fit::ParameterSettings &varObj) const
get variable settings in a variable object (like ROOT::Fit::ParamsSettings)
std::map< std::string, std::string >::const_iterator iter
void Fix()
fix the parameter
std::vector< double > fValues
#define MATH_ERROR_MSG(loc, str)
std::map< unsigned int, std::pair< double, double > > fBounds
std::vector< double > fSteps
void SetLowerLimit(double low)
set a single lower limit
virtual unsigned int NDim() const
number of dimensions
virtual bool Minimize()
method to perform the minimization
void SetFinalValues(const double *x)
const ROOT::Math::MinimTransformFunction * TransformFunction() const
return transformation function (NULL if not having a transformation)
virtual std::string VariableName(unsigned int ivar) const
get name of variables (override if minimizer support storing of variable names)
bool CheckObjFunction() const
virtual unsigned int NDim() const =0
Retrieve the dimension of the function.
static int DefaultPrintLevel()
virtual bool FixVariable(unsigned int ivar)
fix an existing variable
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)
set the function to minimize
const ROOT::Math::IMultiGradFunction * GradObjFunction() const
return pointer to used gradient object function (NULL if gradient is not supported) ...
bool CheckDimension() const
void Set(const std::string &name, double value, double step)
set value and name (unlimited parameter)
static int DefaultMaxIterations()
virtual unsigned int NIterations() const
number of iterations to reach the minimum
virtual unsigned int NFree() const
number of free variables (real dimension of the problem)
double func(double *x, double *p)
Namespace for new Math classes and functions.
virtual bool ReleaseVariable(unsigned int ivar)
release an existing variable
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 )
void SetUpperLimit(double up)
set a single upper limit
virtual bool IsFixedVariable(unsigned int ivar) const
query if an existing variable is fixed (i.e.
std::vector< std::string > fNames
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 ...
BasicMinimizer()
Default constructor.
virtual unsigned int NCalls() const
number of function calls to reach the minimum
void SetPrintLevel(int level)
set print level
Documentation for the abstract class IBaseFunctionMultiDim.
virtual bool SetVariableValue(unsigned int ivar, double val)
set the value of an existing variable
virtual IBaseFunctionMultiDim * Clone() const =0
Clone a function.
virtual ~BasicMinimizer()
Destructor.