-
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++ Implementation of the Tau Hybrid solver #557
Conversation
- Creates platformutils.py, for putting platform-specific wrapper functions - Adds Popen wrapper (`open_simulation`) to "inject" platform-specific kwargs
- Extracts the `sim_kill` lambda into a separate helper function
- Adds new class in platformutils: `SimulationReader` - Handles reading the output of simulation in background thread - Optionally handles timeout
- Define signal handler info as macros - Use `INTERRUPT_*` macros as type definitions - Use `SET_INTERRUPT_HANDLER` as a wrapper around signal installer
gillespy2/solvers/cpp/c_base/tau_hybrid_cpp_solver/TauHybridSimulation.cpp
Show resolved
Hide resolved
gillespy2/solvers/cpp/c_base/tau_hybrid_cpp_solver/TauHybridSolver.h
Outdated
Show resolved
Hide resolved
gillespy2/solvers/cpp/c_base/tau_hybrid_cpp_solver/TauHybridSolver.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only recommendation is a format pass through the C++ source. This looks fantastic, great work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simulations with multiple trajectories are generating constant/near constant results after the first trajectory.
Error occurs with the following models:
- Michaelis Menten
- Opiod
- Tyson 2 State Oscillator
NumPy Tau Hybrid Results for Michaelis Menten
Tau Hybrid C Results for Michaelis Menten
Toogle Switch model is returning strictly deterministic results when they should be stochastic
NumPy Tau Hybrid Results
Tau Hybrid C Solver Results
Specifying >1 for `number_of_trajectories` was resulting in constant output at best, integration errors at worst. - Supply simulation seed to prevent deterministic behavior - Back up `y0` and reset integrator completely on each trajectory - Explicitly initialize partition modes for each species
Species would often get "stuck" on deterministic output. This was due to propensities not being initialized on the first run. - Add propensity computation to beginning of solver loop
- Implement `validate` function to set integrator status based on CVODE return code - Stop trajectory if the timestep is too small
- Fixes issue where fractional initial populations have unexpected results (i.e. Lotka-Volterra model)
Included update to ODE solver to use |
- Revert `SimulationState` enum properties to not use bit packing - Fix incorrect computation of standard deviation, which caused unexpected output - Fix CVODE error caused by uninitialized time value
- Limits the number of sequential invalid states from exceeding 1000 - Prevents "occasionally invalid" output from terminating the simulation - Allow `tau_tol` to be properly accepted as argument
Initial Implementation
This PR only includes the base C++ solver. None of the additional SBML features (rate rules, events, etc.) have been implemented, making this an MVP as it is not yet up to feature parity with the Python implementation. Each additional SBML feature will likely be included as its own PR.
TauHybridCSolver
class to Pythontau_hybrid_cpp_solver
directory to C++ solver basetemplate_opts.h
implementation to support solver-specific argumentsTauHybridCSolver
to C++ solver tests, both variable and non-variableHybrid Data Structures
Extended data structures specific to the Tau Hybrid solver were added to C++. This is to prevent requiring hybrid-specific runtime state from being applied directly to the base
Species
,Reaction
, andModel
classes.Compile Times
As with the ODE C++ solver, the compile step is slow and may give the appearance of poor performance compared to its Python equivalent. The majority of the compile time is due to the Sundials compile dependency, and may be mitigated in the future by caching.
Species Mode Support
Assigning a discrete/stochastic mode value to a species is properly reflected by the C++ solver. This is achieved with the
template_opts.h
"optional" header described above.