Repository navigation
Evaluate the reaction rates once per output row of the selections - #1408
Closed
matthiaskoenig wants to merge 1 commit into
Closed
matthiaskoenig wants to merge 1 commit into
matthiaskoenig wants to merge 1 commit into
Conversation
Selecting a reaction rate evaluated all reaction rates of the model for that one value, so an output row with the reaction rates selected was quadratic in the number of reactions. getSelectedValues evaluates them once per row and reads the selected rates from them.
|
Superseded by #1421. But it looks good; I just wanted to add to it. |
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.
Selecting reaction rates in a timecourse made every output row quadratic in the number of reactions:
getValueof a reaction rate callsgetReactionRates(1, &index, ...), andLLVMExecutableModel::getReactionRatesevaluates all reaction rates of the model (evalReactionRatesPtr) for that one value. A row with all R reactions selected therefore evaluated R x R rate laws.For models with many reactions this is most of the time of a simulation. In the PBPK model
glimepiride_body(255 reactions, 165 species, from pkdb_models), CVODE takes 8.5 ms and the output of the reaction rates 50 ms more. Tools which select all entities of a model by default, such as sbmlsim, pay this on every simulation.Change
getSelectedValues(all three overloads) evaluates the reaction rates once per output row when a reaction rate is selected (getSelectedReactionRates, a buffer inRoadRunnerImpl) and reads the selected rates from it (getNthSelectedOutputtakes the rates). The rates are the onesgetValueevaluates, from the same state, so the output does not change.getValueand the other selection types are unchanged.Timings
A variable step simulation over 1440 min (rtol = atol = 1e-10), C++ API, Release build on Linux, best of 5:
The results with the rates and species selected are identical to develop in every digit (
%.17g) for both models.Tests
getSelectedReactionRatesinRoadRunnerAPITests(LLJit and MCJit): the reaction rates selected twice and between species equal the rate laws of the state of every output row, andgetSelectedValues()after the simulation equalsgetValueof each rate.test_cxx_api_RoadRunnerAPITestsLLJitand...MCJit: 161 tests pass each.ModelEditingTests,StateSavingTests) failed underctest -j20and pass with-j1; they pass on their own as well, so I take it they share files between parallel runs.Possible follow-up, not in this PR: the rate selections of species (
S1',FLOATING_AMOUNT_RATE) evaluate the model per value in the same way.