Minuit2 FCNGradientBase-interface

Hi!

I was playing quite a bit with the FCNGradientBase-interface of minuit2 (ROOT v5.22, gcc 4.1.2 and 4.3.3) and it works reasonably well for problems like the minimization of Wood’s function.
Then I turned to more realistic problems and was trying to implement the interface for the chi^2 minimization of a (still) simple function.

It is no problem to pass the initial gradient check which tells me, that my analytical gradient seems to be OK. However, after this first check, the minimization gets completely screwed up and migrad in fact never converges!
If I go back to the FCNBase-interface, everything works out just fine.

So if anybody ever tried to implement the FCNGradientBase-interface for chi^2 and solved this problems, please let me know…
Or maybe something is wrong with the interface?
If there are any suggestions what to do, I’ll be happy to hear them!

I’ll attach the example which I lately used for this tests.
The function to be fitted to some data (data.txt) is:

f = p6exp(-t/tau)(1+A(p0,…,p5))+p7
A = p2cos(pi/180p0+2pit*p1)exp(-p3t)+p4

Cheers,
Marvin
Makefile.minuit2test_Gradients.txt (1.74 KB)
minuit2test_Gradients.cpp (6.68 KB)
data.txt (6.25 KB)

Hello,

the way you are using the FCNGradientBase interface looks correct to me.
In principle the interface should work and it is tested.
I will have to look in detail at your code example to understand the problem.

Best Regards

Lorenzo

Hi Lorenzo!

Thanks for your reply.
The code should not be too complicated - in the operator() a “standard chi2”-definition and in the Gradient() the derivatives of chi2 with respect to all the parameters which are pushed into the vector one after the other in this example.
The “theory function” I stated already last time (and it’s correct that parameter 5 is not used at all - it’s left from a more complicated example).

If there are any questions concerning the code, please feel free to ask.

Cheers,
Marvin

Hello,

debugging your example, I could spot a bug in Minuit2 when using the user provided gradient (FCNGradientBase-interface) in combination with bounds.
The bug is now fixed in the Minuit2 version in the ROOT trunk. In the next days we will also release a new version.
Thank you very much for your report and your example code. It was very useful !

Best Regards

Lorenzo

Well, thank you for fixing the bug!

Best regards,
Marvin

Hi!

After applying your changes (svn rev 28280) I have done a few more tests and run into another problem.
Changing the function mentioned in my first posting according to
exp(-p3t) -> exp(-(p3t)^p5)
yields again huge differences between the two situations, meaning either deriving from FCNBase or from FCNGradientBase.
On the one hand, I know of course that this function is definitely not behaving nicely numerically and therefore there is a certain chance that the observed differences are simply due to the numerical instabilities in the function and the gradient. Additionally my initial step-values for the minimisation are a kind of crazy for this extreme test.
On the other hand, however, without specifying the analytical gradient finding the minimum works quite smoothly.

The problem when deriving from FCNGradientBase is that it either finds no valid minimum at all (strategy 2) or a completely different (strategy 1) than in the other case.

So, as mentioned already above I do not know for sure that there is another problem in one of the MINUIT2-classes but I would certainly appreciate if you had another closer look into the example.
I therefore attach it again.

Cheers,
Marvin
minuit2test_Gradients_v2.tar.gz (3.3 KB)

Hi,

the fact you are putting all these bounds you increase the non-linearity of the function and therefore you have more of these problems.
I have checked your case and I have not found any problem in Minuit2, also comparing with the old Minuit version (TMinuit).
I would use also strategy 1, because using strategy 2, you calculate the full second derivatives and you increase the numerical errors.
Reducing for example in your case the step size of the second parameter by a factor 10 (to the value t was before) makes the fit converge.

Best Regards

Lorenzo

Well, that’s fine. I am aware of the numerical problems - and as I have written before this was only meant to be an extreme test.
Thanks a lot again.

Bonne journée!
Marvin