ROOT::Math::Minimizer ( Not every variable of minimized function set to minimize)

Suppose that I have a function f which takes n parameters. And I want to minimize this function. But I want to variate only n-k parameters. At the same time I should pass all parameters to the function (sounds strange, I know, but it is program’s flaw):

FunctionToMinimize( const double* allParameters ){
  //do staff with them

//I want something like the following
for( int i = 0; i < n; i++){
  if(/* I want to minimize this parameter */){
    Minimizer->SetLimitedVariable( i, "ivarToMin", step, ll, lo );
    Minimizer->SetVariable( i, "ivarToNotMin" );

Two questions:
Is it possible to do something like that? And If so, what I’ll get from X() method after the minimization? What it will be with “stable” variables?

EDIT: One more question. When I use SetFunction method should I provide number n or n-k:

ROOT::Math::Functor functor( &FunctionToMinimize, n /*or n-k*/ );

Thanks in advance.

I think the total number of parameters remains constant and you should be able to use: Minimizer->SetFixedVariable( i, "ivarToNotMin", value ); // new fixed variable and / or: Minimizer->SetVariable( i, "ivarToNotMin", value, step ); // new free variable Minimizer->FixVariable( i ); // fix an existing variable
Note: there is also: Minimizer->ReleaseVariable( i ); // "free" an existing "fixed" variable

Thank you. It is what I want. Actually I want to variate those k variables but not in the minimizer`s procedure.


You have two possibility:

  1. Define you function with n parameters. This means also n should be used when creating the ROOT::Math::Functor class. Then you need to defined n-k variable parameters using either Minimizer::SetVariables or Minimizer::SetLimitedVariables and k fixed parameters using MInimizer::SetFixedvariables.

  2. Define your function with n-k parameters. In this case the double * array used to in f(double*) should be of n-k dimension and the same value should be used when creating the Functor.
    Also in this case no parameter needs to be defined as fixed.

Best Regards


Thank you, I use the 1st case. Here is a question. Is there explicit method to know minimized function value at the found minima? I do not see it in class reference.


You can use



This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.