ADiGator-GPOPS-II, Warning-derivative of discontinuous sign function
A MATLAB Automatic Differentiation Tool
Brought to you by:
anilvrao2,
weinstein87
Hi,
I'm using ADiGator on my GPOPS implementation. It's working fine but I receive some warnings (see below) when running my code (I don't know if they have any impact though). It looks like I have a discontinuous sign function but as it is in a function generated by ADiGator, I don't know how to deal with that. Any guidance would be helpful. I can attach my files or give you more details if needed. Many thanks.
Antoine
Call to adigator:
Transforming user function: 'musdynEndpoint_Antoine'
taking derivatives wrt: 'v'...
Printing derivatives to file 'musdynEndpoint_AntoineADiGatorGrd'
Successfully transformed user function 'musdynEndpoint_Antoine' to derivative function 'musdynEndpoint_AntoineADiGatorGrd'
Total file generation time: 1.7604
Call to adigator:
Transforming user function: 'musdynContinous_Antoine'
taking derivatives wrt: 'V'...
Printing derivatives to file 'musdynContinous_AntoineADiGatorGrd'
Successfully transformed user function 'musdynContinous_Antoine' to derivative function 'musdynContinous_AntoineADiGatorGrd'
Total file generation time: 3.6152
Call to adigator:
Transforming user function: 'musdynEndpoint_AntoineADiGatorGrd'
taking derivatives wrt: 'v'...
Printing derivatives to file 'musdynEndpoint_AntoineADiGatorHes'
Successfully transformed user function 'musdynEndpoint_AntoineADiGatorGrd' to derivative function 'musdynEndpoint_AntoineADiGatorHes'
Total file generation time: 1.2419
Call to adigator:
Transforming user function: 'musdynContinous_AntoineADiGatorGrd'
taking derivatives wrt: 'V'...
Warning: derivative of discontinuous sign function - making derivatives zero
Hi Antoine,
It looks like you have an y = abs(x) in your continuous function. ADiGator uses derivative rule dy = sgn(x), which it then differentiates again. The warning is just that the sgn() function is piecewise constant and that the coded derivative rule is always zero (dydy = 0 in this example). I placed the warning in there a few years ago - since then I have coded derivative rules for other discontinuous functions (min, max, etc.) with no warnings, so I should probably just remove it.
My reasoning for the warning in the first place is that Newton based methods (like those used by IPOPT and SNOPT) have some assumptions made regarding how many continuous derivatives a function has, but it is pretty common to just ignore those assumptions (especially if you converge in an area away from the discontinuity).
Hope this helps!
-Matt
Hi Matt,
Thanks very much for the answer!
Antoine