Skip to content

Sensitivities for AlgebraicRule models#2101

Merged
dweindl merged 1 commit intomainfrom
dae_sensitivity
Jul 16, 2025
Merged

Sensitivities for AlgebraicRule models#2101
dweindl merged 1 commit intomainfrom
dae_sensitivity

Conversation

@dweindl
Copy link
Member

@dweindl dweindl commented May 22, 2023

Support for AlgebraicRules was added in #2017. Sensitivity analysis is not yet supported.

This implements the missing Model_DAE::fdxdotdp and Model_DAE::fsxdot, and imports all SBML test suite models with sensitivity code.

Fixes #2102.

@codecov
Copy link

codecov bot commented May 22, 2023

Codecov Report

❌ Patch coverage is 14.81481% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.66%. Comparing base (e728c2a) to head (0240f7f).
⚠️ Report is 63 commits behind head on main.

Files with missing lines Patch % Lines
src/model_dae.cpp 16.00% 21 Missing ⚠️
src/solver_idas.cpp 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2101      +/-   ##
==========================================
- Coverage   80.31%   79.66%   -0.65%     
==========================================
  Files         330      330              
  Lines       22641    22660      +19     
  Branches     1532     1533       +1     
==========================================
- Hits        18184    18052     -132     
- Misses       4447     4598     +151     
  Partials       10       10              
Flag Coverage Δ
cpp 75.44% <14.81%> (-0.07%) ⬇️
cpp_python 33.76% <0.00%> (-0.03%) ⬇️
petab 39.16% <0.00%> (-0.05%) ⬇️
python 74.42% <14.81%> (-0.07%) ⬇️
sbmlsuite-jax ?

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

Files with missing lines Coverage Δ
include/amici/model_state.h 97.19% <ø> (ø)
src/amici.cpp 74.48% <ø> (ø)
src/solver_idas.cpp 38.71% <0.00%> (ø)
src/model_dae.cpp 31.32% <16.00%> (-2.59%) ⬇️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dweindl
Copy link
Member Author

dweindl commented May 20, 2025

Current state:

[idas_ic:IDAICFailFlag:-13] The linesearch algorithm failed: step too small or too many backtracks.
[OTHER] AMICI simulation failed: IDA routine IDACalcIC failed with error code -13. 

@FFroehlich
Copy link
Member

Current state:

[idas_ic:IDAICFailFlag:-13] The linesearch algorithm failed: step too small or too many backtracks.
[OTHER] AMICI simulation failed: IDA routine IDACalcIC failed with error code -13. 

I remember that we had issues with IC calculation for models where there shouldn't have been problems, even for simulation only.

@dweindl
Copy link
Member Author

dweindl commented May 20, 2025

I remember that we had issues with IC calculation for models where there shouldn't have been problems, even for simulation only.

After a closer look:

For simulation-only, we are fine for all currently tested models.

For forward sensitivities, we have a variety of issues:

  • sundials/src/idas/idas_ic.c:1415: Newton/Linesearch algorithm failed to converge. (-4)
    For the Python-imported Calvetti example (works with the old MATLAB example) if p1 is a parameter
  • [idas_ic:IDAICFailFlag:-13] The linesearch algorithm failed: step too small or too many backtracks.
    For SBML test cases 00039, 00040, 00182, 00184, and many more
  • [idas:IDASolve:ILL_INPUT] At t = 0.000405875, , mxstep steps taken before reaching tout.
    For SBML test case 00575 and others. (Increasing mxsteps is probably not the solution here.)
  • Undeclared dx identifiers d{some x}dt in stau for DAE models with events (potentially related to sympy.matrices.common.ShapeError when importing SBML models with AlgebraicRule and Event #2106)
    For SBML test case 00661 and others.
    -> Fix dx-dependency of fstau #2897

@dweindl dweindl force-pushed the dae_sensitivity branch from 70cdfde to c6455a1 Compare May 21, 2025 10:02
dweindl added a commit to dweindl/AMICI that referenced this pull request Jul 14, 2025
Fixes import of some SBML test cases with algebraic rules (e.g. `00661`). Related to AMICI-dev#2101.
dweindl added a commit that referenced this pull request Jul 14, 2025
Fixes import of some SBML test cases with algebraic rules (e.g. `00661`). Related to #2101.
dweindl added a commit that referenced this pull request Jul 15, 2025
In matlab-imported models, only `M_` is initialized, in Python-imported models only `MSparse_`.
For Python-imported models, `Model_DAE::fsxdot` was incorrectly using the all-zero `M_`, resulting in failures during `IDACalcIC` with FSA enabled.

Related to #2101, #2102.
@dweindl
Copy link
Member Author

dweindl commented Jul 15, 2025

  • [idas_ic:IDAICFailFlag:-13] The linesearch algorithm failed: step too small or too many backtracks.
    For SBML test cases 00039, 00040, 00182, 00184, and many more

  • [idas:IDASolve:ILL_INPUT] At t = 0.000405875, , mxstep steps taken before reaching tout.
    For SBML test case 00575 and others. (Increasing mxsteps is probably not the solution here.)

For future reference: The problem was using the wrong mass matrix. In matlab-imported models, only M_ is initialized, in Python-imported models only MSparse_. Model_DAE::fsxdot was incorrectly using the all-zero M_, resulting in the above failures during IDACalcIC with FSA enabled.

@dweindl dweindl self-assigned this Jul 15, 2025
Support for AlgebraicRules was added in #2017. Sensitivity analysis is not yet supported.

This implements the missing `Model_DAE::fdxdotdp` and `Model_DAE::fsxdot`, and imports all SBML test suite models with sensitivity code.

Fixes #2102.
@dweindl dweindl marked this pull request as ready for review July 15, 2025 10:16
@dweindl dweindl requested a review from a team as a code owner July 15, 2025 10:16
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
11.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@dweindl dweindl added this pull request to the merge queue Jul 16, 2025
Merged via the queue into main with commit 5b630fd Jul 16, 2025
43 of 46 checks passed
@dweindl dweindl deleted the dae_sensitivity branch July 16, 2025 19:07
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

Successfully merging this pull request may close these issues.

Requesting sensitivities for algebraic equations breaks simulation

2 participants