Fix zero sensitivity for conservation laws with parameter-dependent initial values - #3259
Draft
dweindl wants to merge 3 commits into
Draft
Fix zero sensitivity for conservation laws with parameter-dependent initial values#3259dweindl wants to merge 3 commits into
dweindl wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3259 +/- ##
==========================================
- Coverage 78.52% 78.52% -0.01%
==========================================
Files 318 318
Lines 22199 22197 -2
Branches 1490 1491 +1
==========================================
- Hits 17432 17430 -2
Misses 4759 4759
Partials 8 8
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
dweindl
force-pushed
the
fix-dtcldp
branch
2 times, most recently
from
September 9, 2026 15:27
e9b0a2c to
a17ac10
Compare
Add fiddy-based finite differences sensitivity checks to the SBML semantic test suite. Splits the single forward-only sensitivity check into three independent nodes per case (forward/adjoint/consistency), generalizes the retry scaffold, fixes cross-test-node model-parameter contamination, and skips known-affected cases (events/piecewise, zero-state models) with adjoint/forward distinguished where relevant. Disables fiddy's function-call caching by default (pure overhead here, source of a flaky CI failure). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…nitial values A boundary-condition or `constant=true` SBML species with no counteracting rate rule gets dx/dt=0 and is eliminated into a conservation law. `dtcldp` (the sensitivity of a conservation law's total abundance w.r.t. free parameters) was unconditionally hardcoded to zero whenever a conservation law spanned only one species, on the assumption that a single-species total abundance can't depend on a parameter. This breaks as soon as the species' initial value does depend on a parameter (e.g. via an InitialAssignment) -- the chain rule for any other state whose rate law references the eliminated species (via its `tcl` symbol) then silently drops that dependency. Whether a conservation law's total abundance depends on a free parameter can't be decided from the model's own symbolic initial conditions alone: preequilibration (steady-state Newton solve) and PEtab condition-table state reinitialization compute/override initial states and sensitivities at runtime, entirely bypassing the model's compiled `fx0`/`fsx0`. So a species' initial value can depend on a parameter even where the model's own static formula shows no such dependence -- for single- and multi-species conservation laws alike. `dtcldp` is therefore now always emitted as a symbol, never folded to a literal zero. The correct numeric value is always computed at runtime via `fdtotal_cldp`/`fdtotal_cldx_rdata`. Verified on SBML semantic test suite case 00783 (parameter-dependent conservation law, single species): sensitivities now match finite differences, where they were previously hardcoded to zero. Also verified against PEtab test suite cases 0010/0017 (multi-species conservation law under partial preequilibration and reinitialization), which an earlier version of this fix -- one that tried to statically detect the parameter-independent case instead of always emitting a symbol -- broke. AMICI-dev#3249 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A boundary-condition or
constant=trueSBML species with no counteracting rate rule gets dx/dt=0 and is eliminated into a conservation law.dtcldp(the sensitivity of a conservation law's total abundance w.r.t. free parameters) was unconditionally hardcoded to zero whenever a conservation law spanned only one species, on the assumption that a single-species total abundance can't depend on a parameter. This breaks as soon as the species' initial value does depend on a parameter (e.g. via an InitialAssignment) -- the chain rule for any other state whose rate law references the eliminated species (via itstclsymbol) then silently drops that dependency.Whether a conservation law's total abundance depends on a free parameter can't be decided from the model's own symbolic initial conditions alone: preequilibration (steady-state Newton solve) and PEtab condition-table state reinitialization compute/override initial states and sensitivities at runtime, entirely bypassing the model's compiled
fx0/fsx0. So a species' initial value can depend on a parameter even where the model's own static formula shows no such dependence -- for single- and multi-species conservation laws alike.dtcldpis therefore now always emitted as a symbol, never folded to a literal zero. The correct numeric value is always computed at runtime viafdtotal_cldp/fdtotal_cldx_rdata.Verified on SBML semantic test suite case 00783 (parameter-dependent conservation law, single species): sensitivities now match finite differences, where they were previously hardcoded to zero. Also verified against PEtab test suite cases 0010/0017 (multi-species conservation law under partial preequilibration and reinitialization), which an earlier version of this fix -- one that tried to statically detect the parameter-independent case instead of always emitting a symbol -- broke.
Fixes #3249
🤖 Generated with AI assistance.
Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com