Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjoint sensitivitites wrong? #4

Open
sh-cau opened this issue Jan 23, 2020 · 2 comments
Open

adjoint sensitivitites wrong? #4

sh-cau opened this issue Jan 23, 2020 · 2 comments

Comments

@sh-cau
Copy link

sh-cau commented Jan 23, 2020

Hello,
I tried using the adjoint-family integrators to obtain sensitivities of an arbitrary cost functional

w.r.t. interpolation parameters of a linear system

with a linearly interpolated input (using three points) and compared it to the finite difference approximation of the problem. (I attached some commented matlab code as a .zip-file. Use Matlab->Publish->Publish to get a LaTeX-formatted file of the problem and its Jacobians etc.) The sensitivities differ so much that I suspected the finite difference approximation to be wrong. Because of this, I tried implementing a "brute-force" forward sensitivity analysis aswell as an adjoint sensitivity analysis in ode45 by solving the forward sensitivity equations simultaneously and the backward problem after I obtained the forward solution, respectively (this is not included in the minimal working example in the zip file). They both gave the same solution as the finite difference approximation. Interestingly, though, the quadrature value in MATLODE is the same as int_ryp (in provided file) which I calculated numerically using trapz.
In short:

MATLODE output Quadrature after the solver call is Quad = 64.3645 => same as above with trapz!

  • Finite difference sensitivity

  • MATLODE sensitivity

=> differ significantly?!

Am I missing something here?
Thank you in advance.

mweMatloteIssue.zip

EDIT: included formated LaTeX here additionally to the matlab comments.

@Steven-Roberts
Copy link
Member

Hi @sh-cau, thanks for providing a minimal example to test. I checked in Mathematica to see if the FD version is correct, and indeed it is. We're going through the code now to see if there is a mistake in the config or with MATLODE.

adjoint.zip

@sh-cau
Copy link
Author

sh-cau commented Jan 28, 2020

Thank you @Steven-Roberts,
your help is, again, very much appreciated. Thank you also for providing the mathematica file. I was so into numerical methods that it did not come to my mind to check analytically...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants