Repository navigation
Conversation
Sub-conditions of SBML event triggers that only depend on symbols that are constant during integration (parameters, constant compartments, species not changed by reactions or rate rules, and expressions over those) are now evaluated exactly via `Piecewise((1, cond), (-1, True))` leaves instead of becoming part of the `Min`/`Max` root function. Previously, e.g., `(x > c) && (u == 0)` resulted in the root function `Min(u, -u, x - c)`, which touches zero without changing sign, so the event was only detected at the end of the next integration step (AMICI-dev#3586). Strict comparisons at the threshold were treated as true (AMICI-dev#3508). `solve_minmax_trigger_for_t` handles these leaves as gates, so such triggers keep explicit trigger times where possible. `contains_periodic_subexpression` no longer treats time-independent functions as periodic, which prevented explicit trigger times for triggers like `time >= exp(p)`. Fixes AMICI-dev#3586. Relates to AMICI-dev#2912 and AMICI-dev#3508. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3587 +/- ##
==========================================
+ Coverage 80.75% 80.77% +0.01%
==========================================
Files 331 331
Lines 23699 23757 +58
Branches 1674 1674
==========================================
+ Hits 19139 19190 +51
- Misses 4554 4561 +7
Partials 6 6
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Sub-conditions of SBML event triggers that only depend on quantities that are constant during integration (parameters, constant compartments, species changed by neither reactions nor rate rules, and expressions depending only on those) are now evaluated exactly via
Piecewise((1, cond), (-1, True))terms, instead of becoming part of the root function.This fixes:
(x > c) && (u == 0), whose root functionMin(u, -u, x - c)touches zero without changing sign. The event was only detected at the end of the next integration step, often the next output time, instead of whenxcrossedc(Event with trigger(x > c) && (p == 0)runs at the next output time instead of whenxcrossesc#3586).!=on such quantities, which were treated as true at their threshold. For example,(p > 0) && (time > 10)withp = 0triggered att = 10(Strict event triggers (>,<) are true when both sides are equal: lost or spurious events at t0, output at the trigger time after the event #3508).Max(t - 5, p0)for(time > 5) || (p0 >= 0)withp0 = 0. Such a trigger prevented the other events of the model from triggering (e.g.,time > 5), andjax.jacfwdfailed ("A linear solver received non-finite (NaN or inf) input").Trigger times are still computed explicitly, without root-finding, where possible:
solve_minmax_trigger_for_ttreats the exact conditions as gates in bothMinandMax. In addition,contains_periodic_subexpressionno longer treats time-independent functions as periodic. Previously, that blocked explicit trigger times for triggers liketime >= exp(p).Not covered: conditions in
piecewiseexpressions, which go through_parse_heaviside_trigger, and==/!=on quantities that change during integration (#2912).Fixes #3586. Relates to #2912, #3508.
🤖 Generated with Claude Code