Skip to content

Support for event priorities #2730

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

dweindl
Copy link
Member

@dweindl dweindl commented May 16, 2025

Support plain numeric priorities of SBML events (not the arbitrary expressions that SBML would allow).

If there are multiple event assignments to be executed at the same model time, the ones with higher priority values come first.

Closes #2718.

Also:

  • remove an incorrect check for whether we support useValueFromTriggerTime=True

@dweindl dweindl self-assigned this May 16, 2025
Copy link

codecov bot commented May 16, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 77.95%. Comparing base (666a450) to head (4c78dfb).

Files with missing lines Patch % Lines
include/amici/event.h 83.33% 1 Missing ⚠️
python/sdist/amici/de_model_components.py 80.00% 1 Missing ⚠️
python/sdist/amici/sbml_import.py 75.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2730      +/-   ##
===========================================
+ Coverage    77.94%   77.95%   +0.01%     
===========================================
  Files          327      327              
  Lines        23065    23079      +14     
  Branches      1484     1484              
===========================================
+ Hits         17977    17991      +14     
  Misses        5077     5077              
  Partials        11       11              
Flag Coverage Δ
cpp 74.83% <90.90%> (+0.02%) ⬆️
cpp_python 33.65% <50.00%> (+0.02%) ⬆️
petab 39.36% <31.81%> (+<0.01%) ⬆️
python 72.98% <82.60%> (+0.01%) ⬆️

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

Files with missing lines Coverage Δ
python/sdist/amici/de_export.py 95.23% <100.00%> (+0.02%) ⬆️
python/sdist/amici/gradient_check.py 76.36% <100.00%> (+1.12%) ⬆️
python/sdist/amici/swig_wrappers.py 98.41% <ø> (ø)
src/model.cpp 85.51% <100.00%> (ø)
include/amici/event.h 89.47% <83.33%> (-3.86%) ⬇️
python/sdist/amici/de_model_components.py 88.27% <80.00%> (-0.27%) ⬇️
python/sdist/amici/sbml_import.py 78.81% <75.00%> (+0.14%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dweindl dweindl force-pushed the event_priority branch 3 times, most recently from 7126ffc to 0929828 Compare May 16, 2025 14:16
dweindl added 2 commits May 16, 2025 20:33
Support plain numeric priorities of SBML events (not the arbitrary expressions that SBML would allow).

Also removes an incorrect check for whether we support useValueFromTriggerTime.
@dweindl dweindl marked this pull request as ready for review May 16, 2025 19:22
@dweindl dweindl requested a review from a team as a code owner May 16, 2025 19:22
pending_events_.sort([](Event const& a, Event const& b) {
// The priority is NaN if not defined. In this case, the execution
// order is undefined, so this does not need any special treatment.
return a.get_priority() > b.get_priority();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about mixed defined and undefined event priories (sbml spec says we can do whathever we want with undefined prios). Also in the case of equal priority SBML spec says events should be picked randomly.

@@ -736,6 +737,13 @@ def __init__(
self._state_update = state_update
self._initial_value = initial_value

if priority is not None and not priority.is_Number:
raise NotImplementedError(
"Only fixed numbers are currently supported as event priority."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Only fixed numbers are currently supported as event priority."
"Currently, only numeric values are supported as event priority."

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.

2 participants