AMICI icon indicating copy to clipboard operation
AMICI copied to clipboard

Adjoint event

Open paulstapor opened this issue 4 years ago • 13 comments

paulstapor avatar Aug 05 '21 11:08 paulstapor

Codecov Report

Attention: 58 lines in your changes are missing coverage. Please review.

Comparison is base (ec4ee25) 77.21% compared to head (7e32da0) 48.57%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##           develop    #1539       +/-   ##
============================================
- Coverage    77.21%   48.57%   -28.64%     
============================================
  Files           94       94               
  Lines        15089    15149       +60     
============================================
- Hits         11651     7359     -4292     
- Misses        3438     7790     +4352     
Flag Coverage Δ
cpp ?
cpp_python 37.26% <6.25%> (-0.10%) :arrow_down:
petab 53.93% <36.84%> (-0.07%) :arrow_down:
python 61.41% <65.78%> (-15.57%) :arrow_down:
sbmlsuite ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
include/amici/abstract_model.h 0.00% <ø> (ø)
include/amici/backwardproblem.h 0.00% <ø> (-100.00%) :arrow_down:
include/amici/model.h 0.00% <ø> (-61.12%) :arrow_down:
include/amici/model_dae.h 0.00% <ø> (ø)
src/abstract_model.cpp 1.05% <ø> (-5.83%) :arrow_down:
python/sdist/amici/import_utils.py 73.52% <66.66%> (-14.71%) :arrow_down:
include/amici/forwardproblem.h 0.00% <0.00%> (-100.00%) :arrow_down:
src/model.cpp 43.63% <0.00%> (-42.17%) :arrow_down:
src/model_dae.cpp 0.00% <0.00%> (-32.10%) :arrow_down:
src/model_ode.cpp 46.82% <25.00%> (-20.25%) :arrow_down:
... and 3 more

... and 49 files with indirect coverage changes

codecov[bot] avatar Aug 05 '21 11:08 codecov[bot]

Okay, this seems to be indeed the last status of my work on adjoints with events. Sorry it took me so long to actually double-check it. In principle, the implemented algorithm seems to work fine for multiple test models, but it is - for some reason that I failed to understand - inexact, i.e., gradients are off by a little. This problem only occurred for the Leonhardt test model (purely parameter dependent event with state update). However, this little (in the range of a few percent) being off markedly affected the performance of parameter estimation, as I checked in some (by now) deleted file.

I don't really know what to do with this. The work done here enables adjoint computations for a couple of models with events and heaviside. However, it seems to have a bug for certain types of models with events. Possible reasons might be:

  • an error in the implementation
  • a problem with interpolation of the forward solution (which is discontinuous), or, as a result, with the right hand side, or dfdp

paulstapor avatar Feb 10 '22 19:02 paulstapor

Thanks for the update @paulstapor

dweindl avatar Feb 10 '22 21:02 dweindl

Okay, this seems to be indeed the last status of my work on adjoints with events. Sorry it took me so long to actually double-check it. In principle, the implemented algorithm seems to work fine for multiple test models, but it is - for some reason that I failed to understand - inexact, i.e., gradients are off by a little. This problem only occurred for the Leonhardt test model (purely parameter dependent event with state update). However, this little (in the range of a few percent) being off markedly affected the performance of parameter estimation, as I checked in some (by now) deleted file.

I don't really know what to do with this. The work done here enables adjoint computations for a couple of models with events and heaviside. However, it seems to have a bug for certain types of models with events. Possible reasons might be:

  • an error in the implementation
  • a problem with interpolation of the forward solution (which is discontinuous), or, as a result, with the right hand side, or dfdp

when using adjoint sensitivities with events, one should always use polynomial instead of hermite interpolation.

FFroehlich avatar May 12 '22 21:05 FFroehlich

Super late to the party... but could this be the issue of the imprecision?

It seems like Hermite interpolation is used for the forward problem solution, which is also used for the backwards problem.

stephanmg avatar Jan 26 '23 12:01 stephanmg

Super late to the party... but could this be the issue of the imprecision?

It seems like Hermite interpolation is used for the forward problem solution, which is also used for the backwards problem.

Does changing that fix the issue? :)

dweindl avatar Jan 26 '23 12:01 dweindl

Super late to the party... but could this be the issue of the imprecision? It seems like Hermite interpolation is used for the forward problem solution, which is also used for the backwards problem.

Does changing that fix the issue? :)

Super late to the party... but could this be the issue of the imprecision? It seems like Hermite interpolation is used for the forward problem solution, which is also used for the backwards problem.

Does changing that fix the issue? :)

Will give it a try... Update: Seem like this didn't fix it.

stephanmg avatar Jan 26 '23 14:01 stephanmg

Quality Gate Failed Quality Gate failed

Failed conditions

0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Dec 14 '23 10:12 sonarqubecloud[bot]

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

2 New issues
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Jan 17 '24 00:01 sonarqubecloud[bot]