-
Notifications
You must be signed in to change notification settings - Fork 32
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
C++ Hybrid Solver: Events #594
Merged
Merged
Conversation
This file contains 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
- Added `Event` class - Added basic macros for event parameters and their associated static methods
In order to accommodate for SBML features, parameters must be vectorized instead of global variables. - Added `get_parameters` and `get_constants` template functions - Heap-allocates data for each type of variable - Replaced all references in C++ solver to parameters with vectorized equivalents - Replaced call to `sanitized_parameter_names` with manual sanitization in Python model - Instead of `P0, P1, etc` parameters are `P[0], P[1], etc` for variables and `C[0], C[1], etc` for constants - Modified rate rules to accept vectorized parameters - Removed `IPropensityFunction` and replaced with static `propensity` method - Static member of the `Reaction` class
- Added `execute` member methods to assign variables to state vecs - Added `use_state` member method to save the current state for later execution - Implemented rule of 5 for `Event` class - Implemented template injection functions - Added new implementation of `use_events`, no longer uses lambdas - Added new `assign` static method to dispatch event assignments
- Added `species_id` and `param_id` dicts to `SanitizedModel` class - Maps un-sanitized species/parameter names to their IDs - Modified `TauHybridCSolver` options to provide definitions - Defs for: events, # of events, assignments, # of event assignments
- Modified `TauHybridCSolver` template option generation to use a globally unique assignment ID - Added a (currently useless) call to `use_events` just to test
- Updated template to determine `use_trigger_state` and `persistent` flags - Updated event eval functions (`trigger`, `delay`, `priority`) to support expressions - Added `EventExecution` object to represent execution state of event - Call `Even#get_execution` to use, saves state automatically - Added `execution_time` property to execution state - Moved persistent state from `Event` to `EventExecution` - Removed `Event` as "unsupported SBML feature" in Python solver
Still missing trigger state memory (currently executes constantly) - Added events vector to solver function signature - Added priority queues to Hybrid solver iteration - Added comparison operators to `EventExecution` object - Moved `priority` method from `Event` to `EventExecution` - Added copy of assignments list on copy/move constructors - Fixed sizing issue for event template - Fixed off-by-1 error when generating assignment IDs in Python
- Added `is_persistent()` method to `Event` class - Added `volatile_queue` list for events that need to be re-checked continuously
- Added methods to `Integrator` class to enable root-finding - Modified trigger pipeline to fire detected events without using trigger calls directly
All triggers are evaluated at the end of every iteration. No root-finding is performed. - Removed calls to `use_events()` in integrator.cpp - Added `trigger_state` to track transition state of each trigger
Goal is to use new layout where root-finder can search for both events and reactions. - Added `Integrator#use_events` and `Integrator#use_reactions` - Updated `Integrator#integrate` to use new layout
- Added "trigger pool" data set to track event trigger state - Added "roots found" return parameters to `integrate()` method
Parameter bug was caused by parameters never been templated as variable (always constants). - Fixed bug where parameter assignments are ignored - Added `variable` member to `SanitizedModel` - Removed `variable` param from `SanitizedModel#get_template`, instead pulls from `self` - Updated docstrings in new integrator methods - Updated root-finder return to apply direct reactions - Fixed parameter overrides not applying - Added array to track which parameters have overrides
- Added comprehensive test cases for event features - Fixed non-persistent triggers by reordering volatile trigger checks - Fixed delay time checks - Fixed calls to `memcpy` in `EventExecution`'s copy constructor
- Added `initial_value` handling to template gen - Added initial value as macro parameter for `EVENT`
Comp - Moved event execution code to separate `EventList` class - Contains exact same code, just abstracted away - Added check to trigger state at beginning of trajectory - Moved first trajectory value to be after events have been processed
- Bug occurred when stochastic event fired - Root-finder list was never cleared - Errant `continue` skipped over state update code - Bug occurred when array is not zero-initialized - Caused compiler-specific bug where stochastic events were impossible to find
seanebum
approved these changes
Jan 6, 2022
BryanRumsey
approved these changes
Jan 7, 2022
…ts, and Function Definitions.
…ature/cpp-hybrid-events
briandrawert
approved these changes
Jan 7, 2022
Merged
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.
Adds features of SBML
Event
objects (and their related objects, includingEventTrigger
s andEventAssignments
) to the C++ hybrid solver, as referenced in SBML Language Specification v3.2.Major Changes
Event
,EventList
,EventExecution
classes to C++ back endIPropensityFunction
interface with static call tomap_propensity
test_hybrid_c_events.py
for unit testing the hybrid solver's event triggersEvent
triggers and direct reactions (only when Events are found)Closes #628