comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: mpfit and analytical derivative debugging
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: mpfit and analytical derivative debugging [message #80065] Wed, 09 May 2012 01:32
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den tisdagen den 8:e maj 2012 kl. 19:29:12 UTC+2 skrev Mats Löfdahl:
> Den tisdagen den 8:e maj 2012 kl. 16:50:05 UTC+2 skrev Craig Markwardt:
>> On Tuesday, May 8, 2012 9:53:55 AM UTC-4, Mats Löfdahl wrote:
>
>>> Oh, silly me! You must turn on the analytical derivatives using parinfo.mpside=3 and not with autoderivative=0 for the debugging to work.
>>
>> Thanks for reminding me to document FJAC_MASK. It's just telling you which parameters MPFIT expects explicit derivatives from your user function. All 1s indicates all parameters.
>>
>> You always have to set MPSIDE=3; that's well documented. :-)
>
> That doesn't help you if you're like me and think you are smarter than the documentation...

Actually, here is one instance where the documentation could be improved (in mpfit.pro header):


; The keyword setting AUTODERIVATIVE=0 always globally overrides the
; individual values of PARINFO.MPSIDE. Setting AUTODERIVATIVE=0 is
; equivalent to resetting PARINFO.MPSIDE=3 for all parameters.

It kind of suggests that I should have been able to do what I did.
Re: mpfit and analytical derivative debugging [message #80071 is a reply to message #80065] Tue, 08 May 2012 10:29 Go to previous message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den tisdagen den 8:e maj 2012 kl. 16:50:05 UTC+2 skrev Craig Markwardt:
> On Tuesday, May 8, 2012 9:53:55 AM UTC-4, Mats Löfdahl wrote:

>> Oh, silly me! You must turn on the analytical derivatives using parinfo.mpside=3 and not with autoderivative=0 for the debugging to work.
>
> Thanks for reminding me to document FJAC_MASK. It's just telling you which parameters MPFIT expects explicit derivatives from your user function. All 1s indicates all parameters.
>
> You always have to set MPSIDE=3; that's well documented. :-)

That doesn't help you if you're like me and think you are smarter than the documentation...
Re: mpfit and analytical derivative debugging [message #80075 is a reply to message #80071] Tue, 08 May 2012 07:50 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Tuesday, May 8, 2012 9:53:55 AM UTC-4, Mats Löfdahl wrote:
> Den tisdagen den 8:e maj 2012 kl. 15:04:24 UTC+2 skrev Mats Löfdahl:
>> I have this fitting problem that I'm solving with mpfit. The code works but the function values are kind of costly to calculate and the penalty for calculating the analytical derivatives once you have calculated the function value is relatively small. So I'm trying to use the AUTODERIVATIVE=0 setting.
>>
>> I've tested my analytical derivatives against numerical derivatives in a standalone program that does not involve mpfit. Looks fine.
>>
>> However, there seems to be something wrong because the problem does not converge anymore. (The solution does not change significantly from one iteration to the next.) Most likely an order of magnitude problem because the problem does not go away when I change the sign of the derivatives. (Or something more fundamental that I've misunderstood.)
>>
>> So I'm setting
>>
>> parinfo[iparam].mpderiv_debug = 1
>> parinfo[iparam].mpderiv_reltol = 1d-3
>> parinfo[iparam].mpderiv_abstol = 1d-7
>>
>> for all parameters, expecting screen output of this sort (from doc header of mpfit.pro):
>>
>> ; FJAC DEBUG BEGIN
>> ; # IPNT FUNC DERIV_U DERIV_N DIFF_ABS DIFF_REL
>> ; FJAC PARM 2
>> ; 80 -0.7308 0.04233 0.04233 -5.543E-07 -1.309E-05
>> ; 99 1.370 0.01417 0.01417 -5.518E-07 -3.895E-05
>> ; 118 0.07187 -0.01400 -0.01400 -5.566E-07 3.977E-05
>> ; 137 1.844 -0.04216 -0.04216 -5.589E-07 1.326E-05
>> ; FJAC DEBUG END
>>
>> But what I get looks like this:
>>
>>
>> FJAC DEBUG BEGIN
>> # IPNT FUNC DERIV_U DERIV_N DIFF_ABS DIFF_REL
>> # FJAC_MASK = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
>> analytical derivatives
>> Iter 1 -- CHI-SQUARE = 328.57185 -- DOF = 65515
>>
>>
>>
>> The "analytical derivatives" line is just a printout from my MYFUNC indicating that it has entered the part where the analytical derivatives are calculated. I don't know how to interpret FJAC_MASK and the "Iter 1..." line shows that mpfit thinks it is done with this iteration.
>>
>> Suggestions?
>>
>> /Mats
>
> Oh, silly me! You must turn on the analytical derivatives using parinfo.mpside=3 and not with autoderivative=0 for the debugging to work.

Thanks for reminding me to document FJAC_MASK. It's just telling you which parameters MPFIT expects explicit derivatives from your user function. All 1s indicates all parameters.

You always have to set MPSIDE=3; that's well documented. :-)

But you are right that AUTODERIVATIVE=0 confuses the derivative debugging feature. There are several layers of options there and it's difficult to make them behave properly and document it well. For the future I think this can be fixed.
Craig
Re: mpfit and analytical derivative debugging [message #80076 is a reply to message #80075] Tue, 08 May 2012 06:53 Go to previous message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den tisdagen den 8:e maj 2012 kl. 15:04:24 UTC+2 skrev Mats Löfdahl:
> I have this fitting problem that I'm solving with mpfit. The code works but the function values are kind of costly to calculate and the penalty for calculating the analytical derivatives once you have calculated the function value is relatively small. So I'm trying to use the AUTODERIVATIVE=0 setting.
>
> I've tested my analytical derivatives against numerical derivatives in a standalone program that does not involve mpfit. Looks fine.
>
> However, there seems to be something wrong because the problem does not converge anymore. (The solution does not change significantly from one iteration to the next.) Most likely an order of magnitude problem because the problem does not go away when I change the sign of the derivatives. (Or something more fundamental that I've misunderstood.)
>
> So I'm setting
>
> parinfo[iparam].mpderiv_debug = 1
> parinfo[iparam].mpderiv_reltol = 1d-3
> parinfo[iparam].mpderiv_abstol = 1d-7
>
> for all parameters, expecting screen output of this sort (from doc header of mpfit.pro):
>
> ; FJAC DEBUG BEGIN
> ; # IPNT FUNC DERIV_U DERIV_N DIFF_ABS DIFF_REL
> ; FJAC PARM 2
> ; 80 -0.7308 0.04233 0.04233 -5.543E-07 -1.309E-05
> ; 99 1.370 0.01417 0.01417 -5.518E-07 -3.895E-05
> ; 118 0.07187 -0.01400 -0.01400 -5.566E-07 3.977E-05
> ; 137 1.844 -0.04216 -0.04216 -5.589E-07 1.326E-05
> ; FJAC DEBUG END
>
> But what I get looks like this:
>
>
> FJAC DEBUG BEGIN
> # IPNT FUNC DERIV_U DERIV_N DIFF_ABS DIFF_REL
> # FJAC_MASK = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
> analytical derivatives
> Iter 1 -- CHI-SQUARE = 328.57185 -- DOF = 65515
>
>
>
> The "analytical derivatives" line is just a printout from my MYFUNC indicating that it has entered the part where the analytical derivatives are calculated. I don't know how to interpret FJAC_MASK and the "Iter 1..." line shows that mpfit thinks it is done with this iteration.
>
> Suggestions?
>
> /Mats

Oh, silly me! You must turn on the analytical derivatives using parinfo.mpside=3 and not with autoderivative=0 for the debugging to work.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Web Site Curator Needed
Next Topic: Re: Matrix multiplication again...

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:58:02 PDT 2025

Total time taken to generate the page: 0.00421 seconds