Iteration failed with status 27

Dear ROOTers,

I am using ROOT::Math::GSLMinimizer to compute optimum prize for 300 data points. This is a 300 parameter model with each parameter having a Minimum and Maximum allowable values. I am using the SetLimitedVariable() method to set the initial values and the allowed range for each of the 300 parameters.

When running the program, I have the following two problems:

  1. After about 17 iterations, the program ends with a message[quote]GSLMinimizer: Minimizer did not converge. Iteration failed with a status 27[/quote]
    2.Many of the parameter values in the last iteration have values that are outside the range that I originally specified

Is there anything I can do better to make the model converge and why is the algorithm considering parameter values that are outside the specified range?

I am attaching both the program and the data here.

Any advice will be appreciated.

optimize.C (3.67 KB)
OptimizeThis.root (11.2 KB)


the GSL minimizer fails because the iteration do not make any more progress towards the solution. This is the meaning of error status 27.
The reason is probably due to the complexity of your function and the fact that you are applying some constraint to the minimization problem in a naive way (just setting an high function value).
You would need probably a real constraint optimizer to solve the problem.
In ROOT we have only the quadratic programming methods for constraint optimization (quadp library).

I have also tried your program with Minuit, but it did not work either.

I attached anyway a correct version of your program (where some C++ errors have been fixed)

Best Regards


Dear Lorenzo,

Thanks for your reply.

You have forgotten to attach your version of the program. I would like to to see what changes you made to the program.

The example I have shown is a 300 parameter model. Eventually, I would like it to work on a 10,000 parameter model. Do you think ROOT’s quadp can handle this? OR is your advice not to use ROOT for these kinds of problems.


I am sorry for forgetting, here is the attachment.

quadp can handle quadratic programming problem, i.e. when the objective function is quadratic and the constraint are linear. In your case I see that your function is not quadratic, maybe is linear if the value yhat is very small.

Concerning the GSL minimizer the bound on the parameters is not supported as it is in Minuit. This is the reason that you get parameter values outside the specified range. It might work better if this is supported.
If you want, you can try to implement it by adding the same sine transformation used in Minuit. See for example … ation.html

Best Regards

optimize.C (4.15 KB)


Thank you for your help.

I added another line of code to the minimizer function to return a large value if any of the parameters are outside of its MAX-MIN range. This seems to have taken care of the issue where the parameters were falling outside the required range.

The algorithm still doesn’t converge. But, after 27 iterations I do get parameter values that are very reasonable.

The code below tells the optimizer to try new parameter values in steps of 10:

For some reason, the optimizer is till trying other increments that are much smaller. I think this makes the convergence very slow.

Is the ‘step’ feature also not supported by the GSLMinimizer?


Hello Ravi,

the step size passed as input in the parameters is used only for the first iteration. It just gives an order of magnitude for the first step in the parameters. Afterwards the step sizes are calculated internally using the gradient of the functions.
If you start from a good region, not too far away from the minimum, the convergence should be rather independent from the step size.



I’m trying to minimize an array of spins using this method, but I’m having the same problem.
I don’t understand when you say that the equation should be so naif :slight_smile:.
Also I attach the files to clarify the situation.

Thank you

Nuno Sousa (27.7 KB)