roadrunner
2.6.0
Fast simulator for SBML models
|
Base class for all code generation systems; allows compiling and evaluating the model. More...
#include <rrExecutableModel.h>
Public Types | |
enum | ExecutableModelFlags { INTEGRATION = (0x1 << 0) , OPTIMIZE_REACTION_RATE_SELECTION = (0x1 << 1) } |
Public Member Functions | |
ExecutableModel () | |
Returns a human-readable description of the code generation backend, e.g. LLVM, legacy C, etc. More... | |
virtual std::string | getExecutableModelDesc () const =0 |
virtual std::string | getModelName ()=0 |
get the name of the model | |
virtual void | setTime (double _time)=0 |
virtual double | getTime ()=0 |
virtual void | reset ()=0 |
Loads the initial conditions into the current model state. More... | |
virtual int | getNumDepFloatingSpecies ()=0 |
dependent species are defined by rules and the only way to change them is by changing the values on which they depend. | |
virtual int | getNumFloatingSpecies ()=0 |
total number of floating species. | |
virtual int | getFloatingSpeciesIndex (const std::string &eid)=0 |
virtual std::string | getFloatingSpeciesId (size_t index)=0 |
virtual int | getNumIndFloatingSpecies ()=0 |
independent species do are not defined by rules, they typically participate in reactions and can have thier values set at any time. | |
virtual int | getFloatingSpeciesAmounts (size_t len, int const *indx, double *values)=0 |
get the floating species amounts More... | |
virtual int | setFloatingSpeciesAmounts (size_t len, int const *indx, const double *values)=0 |
virtual int | setFloatingSpeciesAmounts (size_t len, int const *indx, const double *values, bool strict)=0 |
virtual int | getFloatingSpeciesAmountRates (size_t len, int const *indx, double *values)=0 |
get the floating species amount rates More... | |
virtual int | getFloatingSpeciesConcentrationRates (size_t len, int const *indx, double *values)=0 |
get the floating species concentration rates More... | |
virtual int | getFloatingSpeciesConcentrations (size_t len, int const *indx, double *values)=0 |
get the floating species concentrations More... | |
virtual int | setFloatingSpeciesConcentrations (size_t len, int const *indx, double const *values)=0 |
set the floating species concentrations More... | |
virtual int | setFloatingSpeciesInitConcentrations (size_t len, int const *indx, double const *values)=0 |
Set the initial concentrations of the floating species. More... | |
virtual int | getFloatingSpeciesInitConcentrations (size_t len, int const *indx, double *values)=0 |
Get the initial concentrations of the floating species, uses the same indexing as the other floating species methods. | |
virtual int | setFloatingSpeciesInitAmounts (size_t len, int const *indx, double const *values)=0 |
Set the initial amounts of the floating species. More... | |
virtual int | getFloatingSpeciesInitAmounts (size_t len, int const *indx, double *values)=0 |
Get the initial amounts of the floating species, uses the same indexing as the other floating species methods. | |
virtual int | getNumBoundarySpecies ()=0 |
get the number of boundary species. | |
virtual int | getBoundarySpeciesIndex (const std::string &eid)=0 |
virtual std::string | getBoundarySpeciesId (size_t index)=0 |
virtual int | getBoundarySpeciesAmounts (size_t len, int const *indx, double *values)=0 |
get the boundary species amounts More... | |
virtual int | getBoundarySpeciesConcentrations (size_t len, int const *indx, double *values)=0 |
get the boundary species concentrations More... | |
virtual int | setBoundarySpeciesConcentrations (size_t len, int const *indx, double const *values)=0 |
set the boundary species concentrations More... | |
virtual int | setBoundarySpeciesAmounts (size_t len, int const *indx, double const *values)=0 |
virtual int | setBoundarySpeciesAmounts (size_t len, int const *indx, double const *values, bool strict)=0 |
virtual int | setBoundarySpeciesInitConcentrations (size_t len, int const *indx, double const *values)=0 |
Set the initial concentrations of the boundary species. More... | |
virtual int | getBoundarySpeciesInitConcentrations (size_t len, int const *indx, double *values)=0 |
Get the initial concentrations of the boundary species, uses the same indexing as the other boundary species methods. | |
virtual int | setBoundarySpeciesInitAmounts (size_t len, int const *indx, double const *values)=0 |
Set the initial amounts of the boundary species. More... | |
virtual int | getBoundarySpeciesInitAmounts (size_t len, int const *indx, double *values)=0 |
Get the initial amounts of the boundary species, uses the same indexing as the other boundary species methods. | |
virtual int | getNumGlobalParameters ()=0 |
get the number of global parameters | |
virtual int | getGlobalParameterIndex (const std::string &eid)=0 |
index of the global parameter id, -1 if it does not exist. | |
virtual std::string | getGlobalParameterId (size_t index)=0 |
id of the indexed global parameter. | |
virtual int | getGlobalParameterValues (size_t len, int const *indx, double *values)=0 |
get the global parameter values More... | |
virtual int | setGlobalParameterValues (size_t len, int const *indx, const double *values)=0 |
virtual int | setGlobalParameterValues (size_t len, int const *indx, const double *values, bool strict)=0 |
virtual int | setGlobalParameterInitValues (size_t len, int const *indx, double const *values)=0 |
Set the initial value of the global parameter. More... | |
virtual int | getGlobalParameterInitValues (size_t len, int const *indx, double *values)=0 |
Get the initial amounts of the global parameter, uses the same indexing as the other global parameter methods. | |
virtual int | getNumCompartments ()=0 |
virtual int | getCompartmentIndexForFloatingSpecies (size_t index)=0 |
virtual int | getCompartmentIndexForBoundarySpecies (size_t index)=0 |
virtual int | getCompartmentIndex (const std::string &eid)=0 |
virtual std::string | getCompartmentId (size_t index)=0 |
virtual int | getCompartmentVolumes (size_t len, int const *indx, double *values)=0 |
get the compartment volumes More... | |
virtual int | setCompartmentVolumes (size_t len, int const *indx, const double *values)=0 |
virtual int | setCompartmentVolumes (size_t len, int const *indx, const double *values, bool strict)=0 |
virtual int | setCompartmentInitVolumes (size_t len, int const *indx, double const *values)=0 |
Set the initial volumes of the compartments. More... | |
virtual int | getCompartmentInitVolumes (size_t len, int const *indx, double *values)=0 |
Get the initial volume of the compartments, uses the same indexing as the other compartment methods. | |
virtual void | getIds (int types, std::list< std::string > &ids)=0 |
populates a given list with all the ids that this class can accept. More... | |
virtual int | getSupportedIdTypes ()=0 |
returns a bit field of the ids that this class supports. | |
virtual double | getValue (const std::string &id)=0 |
gets the value for the given id std::string. More... | |
virtual void | setValue (const std::string &id, double value)=0 |
sets the value coresponding to the given selection stringl | |
virtual int | setStoichiometries (size_t len, int const *indx, const double *values)=0 |
virtual int | setStoichiometries (size_t len, int const *indx, const double *values, bool strict)=0 |
virtual int | setStoichiometry (int index, double value)=0 |
virtual int | setStoichiometry (int speciesIndex, int reactionIndex, double value)=0 |
virtual double | getStoichiometry (int index)=0 |
Get the current stiochiometry value with the given index. More... | |
virtual double | getStoichiometry (int speciesIndex, int reactionIndex)=0 |
Get the current stiochiometry value for the given species / reaction. More... | |
virtual int | getNumConservedMoieties ()=0 |
virtual int | getConservedMoietyIndex (const std::string &eid)=0 |
virtual std::string | getConservedMoietyId (size_t index)=0 |
virtual int | getConservedMoietyValues (size_t len, int const *indx, double *values)=0 |
virtual int | setConservedMoietyValues (size_t len, int const *indx, const double *values)=0 |
virtual int | getNumRateRules ()=0 |
virtual std::vector< std::string > | getRateRuleSymbols () const =0 |
Gets the symbols defined by rate rules, i.e. returns all x such that x' = f(x) is a rule which defines parameter x. More... | |
virtual int | getNumReactions ()=0 |
get the number of reactions the model has | |
virtual int | getReactionIndex (const std::string &eid)=0 |
get the index of a named reaction More... | |
virtual std::string | getReactionId (size_t index)=0 |
get the name of the specified reaction | |
virtual int | getStoichiometryIndex (const std::string &)=0 |
get the index of a named stoichiometry More... | |
virtual int | getStoichiometryIndex (const std::string &, const std::string &)=0 |
get the index of a named stoichiometry More... | |
virtual std::string | getStoichiometryId (size_t index)=0 |
get the name of the specified stoichiometry | |
virtual int | getReactionRates (size_t len, int const *indx, double *values)=0 |
get the std::vector of reaction rates. More... | |
virtual void | getRateRuleValues (double *rateRuleValues)=0 |
get the 'values' i.e. More... | |
virtual int | getRateRuleRates (size_t len, int const *indx, double *values) |
get the 'rates' i.e. More... | |
virtual std::string | getStateVectorId (size_t index)=0 |
get the id of an element of the state std::vector. | |
virtual int | getStateVector (double *stateVector)=0 |
The state std::vector is a std::vector of elements that are defined by differential equations (rate rules) or independent floating species are defined by reactions. More... | |
virtual int | setStateVector (const double *stateVector)=0 |
sets the internal model state to the provided packed state std::vector. More... | |
virtual void | getStateVectorRate (double time, const double *y, double *dydt=0)=0 |
the state std::vector y is the rate rule values and floating species concentrations concatenated. More... | |
virtual void | testConstraints ()=0 |
virtual std::string | getInfo ()=0 |
virtual void | print (std::ostream &stream)=0 |
virtual int | getNumEvents ()=0 |
virtual int | getEventTriggers (size_t len, const int *indx, unsigned char *values)=0 |
get the event status, false if the even is not triggered, true if it is. More... | |
virtual int | applyEvents (double timeEnd, const unsigned char *previousEventStatus, const double *initialState, double *finalState)=0 |
Itterate through all of the current and pending events and apply them. More... | |
virtual void | getEventRoots (double time, const double *y, double *gdot)=0 |
evaluate the event 'roots' – when events transition form triggered - non-triggered or triggered to non-triggered state. More... | |
virtual void | getPiecewiseTriggerRoots (double time, const double *y, double *gdot)=0 |
virtual double | getNextPendingEventTime (bool pop)=0 |
virtual int | getPendingEventSize ()=0 |
virtual void | resetEvents ()=0 |
virtual int | getNumPiecewiseTriggers ()=0 |
We do root-finding for 'piecewise triggers': those times in a piecewise function that transition from one condition to the next. | |
virtual | ~ExecutableModel () |
need a virtual destructor as object implementing this interface can be deleted directly, i.e. More... | |
virtual int | getEventIndex (const std::string &eid)=0 |
Gets the index for an event id. More... | |
virtual std::string | getEventId (size_t index)=0 |
virtual void | getEventIds (std::list< std::string > &)=0 |
virtual void | getAssignmentRuleIds (std::list< std::string > &)=0 |
virtual void | getRateRuleIds (std::list< std::string > &)=0 |
virtual void | getInitialAssignmentIds (std::list< std::string > &)=0 |
virtual void | setEventListener (size_t index, EventListenerPtr eventHandler)=0 |
virtual EventListenerPtr | getEventListener (size_t index)=0 |
virtual double | getFloatingSpeciesAmountRate (size_t index, const double *reactionRates)=0 |
Get the amount rate of change for the i'th floating species given a reaction rates std::vector. More... | |
virtual void | reset (int options)=0 |
reset the model accordign to a bitfield specified by the SelectionRecord::SelectionType values. | |
virtual void | setRandomSeed (int64_t)=0 |
set the seed used by the random number generator. More... | |
virtual int64_t | getRandomSeed ()=0 |
get the seed used by the RNG. | |
virtual double | getRandom ()=0 |
Get a uniform random number between 0 and 1 created by the RNG. More... | |
virtual uint32_t | getFlags () const =0 |
Get the current set of flags. | |
virtual void | setFlags (uint32_t)=0 |
Set certain options that determine the state of the ExecutableModel, these are listed in. | |
void | computeAllRatesOfChange () |
for source compatability | |
virtual void | saveState (std::ostream &out) |
virtual void | setIntegrationStartTime (double time) |
Protected Member Functions | |
void | setIntegration (bool value) |
is integration is currently proceeding. | |
Protected Attributes | |
double | mIntegrationStartTime |
Friends | |
class | RoadRunner |
Base class for all code generation systems; allows compiling and evaluating the model.
The ExecutableModel interface provides a way to access an sbml model that was compiled, JIT'd or interpreted as executable (runnable) module.
An ExecutableModel holds a ModelData structure, all the simulation values are stored in the ModelData struct, i.e. the dynamic state of the model is fully contained in the ModelData structure.
An ExecutableModel should also contain all of the initial conditions, rules, functions and whatever other semantic information that was specified in the sbml model.
rr::ExecutableModel::ExecutableModel | ( | ) |
Returns a human-readable description of the code generation backend, e.g. LLVM, legacy C, etc.
|
inlinevirtual |
need a virtual destructor as object implementing this interface can be deleted directly, i.e.
ExecutableModel *p = createModel(...); delete p;
|
pure virtual |
Itterate through all of the current and pending events and apply them.
If any events trigger a state change which triggers any additional events, these are applied as well. After this method finishes, all events are processed.
timeEnd | model time when the event occured. |
previousEventStatus | array of previous event triggered states. |
initialState | (optional): initial state std::vector, may be NULL, in which the current state is used. |
finalState | (optional): final state std::vector, where the final state is coppied to. May be NULL, in which case, ignored. |
Implemented in rr::CompiledExecutableModel, and rrllvm::LLVMExecutableModel.
|
pure virtual |
get the boundary species amounts
[in] | len | the length of the indx and values arrays. |
[in] | indx | an array of length len of boundary species to return. |
[out] | values | an array of at least length len which will store the returned boundary species amounts. |
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
get the boundary species concentrations
[in] | len | the length of the indx and values arrays. |
[in] | indx | an array of length len of boundary species to return. |
[out] | values | an array of at least length len which will store the returned boundary species amounts. |
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
get the compartment volumes
[in] | len | the length of the indx and values arrays. |
[in] | indx | an array of length len of boundary species to return. |
[out] | values | an array of at least length len which will store the returned boundary species amounts. |
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
Gets the index for an event id.
If there is no event with this id, returns -1.
Implemented in rrllvm::LLVMExecutableModel, and rr::CompiledExecutableModel.
|
pure virtual |
evaluate the event 'roots' – when events transition form triggered - non-triggered or triggered to non-triggered state.
Simplest method is to return 1 for triggered, -1 for not-triggered, so long as there is a zero crossing.
[in] | time | current time |
[in] | y | the state std::vector |
[out] | gdot | result event roots, this is of length numEvents. |
Implemented in rrllvm::LLVMExecutableModel, and rr::CompiledExecutableModel.
|
pure virtual |
get the event status, false if the even is not triggered, true if it is.
The reason this returns an unsigned char instead of a bool array is this array is typically stuffed into an std::vector, and std::vector<bool> is well, weird as it's actually implemented as a bitfield, and can not be used as a C array.
So, on every modern system I'm aware of, bool is an unsigned char, so use that data type here.
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
Get the amount rate of change for the i'th floating species given a reaction rates std::vector.
TODO: This should be merged with getFloatingSpeciesAmountRates, but that will break inteface, will do in next point release.
TODO: If the conversion factor changes in between getting the reaction rates std::vector via getReactionRates
index | index of the desired floating speceis rate. |
reactionRates | pointer to buffer of reaction rates. |
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
get the floating species amount rates
[in] | len | the length of the indx and values arrays. |
[in] | indx | an array of length len of floating species to return. |
[out] | values | an array of at least length len which will store the returned floating species amount rates. |
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
get the floating species amounts
[in] | len | the length of the indx and values arrays. |
[in] | indx | an array of length len of floating species to return. |
[out] | values | an array of at least length len which will store the returned floating species amounts. |
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
get the floating species concentration rates
[in] | len | the length of the indx and values arrays. |
[in] | indx | an array of length len of floating species to return. |
[out] | values | an array of at least length len which will store the returned floating species concentration rates. |
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
get the floating species concentrations
[in] | len | the length of the indx and values arrays. |
[in] | indx | an array of length len of floating species to return. |
[out] | values | an array of at least length len which will store the returned floating species amounts. |
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
get the global parameter values
[in] | len | the length of the indx and values arrays. |
[in] | indx | an array of length len of boundary species to return. |
[out] | values | an array of at least length len which will store the returned boundary species amounts. |
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
populates a given list with all the ids that this class can accept.
ids | a list of strings that will be filled by this class. |
types | the types of ids that are requested. Can be set to 0xffffffff to request all the ids that this class supports. This should by a bitwise OR of the filelds in SelectionRecord::SelectionType |
Implemented in rrllvm::LLVMExecutableModel, and rr::CompiledExecutableModel.
|
pure virtual |
Get a uniform random number between 0 and 1 created by the RNG.
The type of RNG can be specified in the config file with the RANDOM_GENERATOR_TYPE key.
Implemented in rrllvm::LLVMExecutableModel, and rr::CompiledExecutableModel.
|
virtual |
get the 'rates' i.e.
the what the rate rule integrates to, and store it in the given array.
len | the length of the supplied buffer, must be >= reaction rates size. |
indx | pointer to index array. If NULL, then it is ignored and the rates are copied directly into the supplied buffer. |
values | pointer to user supplied buffer where rates will be stored. |
Reimplemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
Gets the symbols defined by rate rules, i.e. returns all x such that x' = f(x) is a rule which defines parameter x.
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
get the 'values' i.e.
the what the rate rule integrates to, and store it in the given array.
The length of rateRuleValues obviously must be the number of rate rules we have.
Implemented in rrllvm::LLVMExecutableModel, and rr::CompiledExecutableModel.
|
pure virtual |
get the index of a named reaction
Implemented in rr::CompiledExecutableModel, and rrllvm::LLVMExecutableModel.
|
pure virtual |
get the std::vector of reaction rates.
len | the length of the supplied buffer, must be >= reaction rates size. |
indx | pointer to index array. If NULL, then it is ignored and the reaction rates are copied directly into the supplied buffer. |
values | pointer to user supplied buffer where rates will be stored. |
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
The state std::vector is a std::vector of elements that are defined by differential equations (rate rules) or independent floating species are defined by reactions.
To get the ids of the state std::vector elements, use getStateVectorId.
copies the internal model state std::vector into the provided buffer.
[out] | stateVector | a buffer to copy the state std::vector into, if NULL, return the size required. |
Implemented in rrllvm::LLVMExecutableModel, and rr::CompiledExecutableModel.
|
pure virtual |
the state std::vector y is the rate rule values and floating species concentrations concatenated.
y is of length numFloatingSpecies + numRateRules.
The state std::vector is packed such that the first n raterule elements are the values of the rate rules, and the last n floatingspecies are the floating species values.
[in] | time | current simulator time |
[in] | y | state std::vector, must be either null, or have a size of that speciefied by getStateVector. If y is null, then the model is evaluated using its current state. If y is not null, then the y is considered the state std::vector. |
[out] | dydt | calculated rate of change of the state std::vector, if null, it is ignored. |
Implemented in rrllvm::LLVMExecutableModel, and rr::CompiledExecutableModel.
|
pure virtual |
Get the current stiochiometry value with the given index.
If either are not valid, NaN is returned.
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
Get the current stiochiometry value for the given species / reaction.
If either are not valid, NaN is returned.
Implemented in rrllvm::LLVMExecutableModel, and rr::CompiledExecutableModel.
|
pure virtual |
get the index of a named stoichiometry
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
get the index of a named stoichiometry
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
gets the value for the given id std::string.
The std::string must be a SelectionRecord std::string that is accepted by this class.
Implemented in rrllvm::LLVMExecutableModel, and rr::CompiledExecutableModel.
|
pure virtual |
Loads the initial conditions into the current model state.
Initial conditions may have been updated at any time externally.
Implemented in rrllvm::LLVMExecutableModel, and rr::CompiledExecutableModel.
|
pure virtual |
set the boundary species concentrations
[in] | len | the length of the indx and values arrays. |
[in] | indx | an array of length len of boundary species to return. |
[in] | values | an array of at least length len which will store the returned boundary species concentrations. |
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
Set the initial amounts of the boundary species.
Takes the same indices as the other boundary species methods.
Note, if a boundary species has an initial assignment rule, than the initial conditions value can only be set by updating the values on which it depends, it can not be set directly.
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
Set the initial concentrations of the boundary species.
Takes the same indices as the other boundary species methods.
Note, if a boundary species has an initial assignment rule, than the initial conditions value can only be set by updating the values on which it depends, it can not be set directly.
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
Set the initial volumes of the compartments.
Takes the same indices as the other compartment methods.
Note, if a compartment has an initial assignment rule, than the initial conditions value can only be set by updating the values on which it depends, it can not be set directly.
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
set the floating species concentrations
[in] | len | the length of the indx and values arrays. |
[in] | indx | an array of length len of floating species to return. |
[in] | values | an array of at least length len which will store the returned boundary species amounts. |
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
Set the initial amounts of the floating species.
Takes the same indices as the other floating species methods.
Note, if a floating species has an initial assignment rule, than the initial conditions value can only be set by updating the values on which it depends, it can not be set directly.
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
Set the initial concentrations of the floating species.
Takes the same indices as the other floating species methods.
Note, if a floating species has an initial assignment rule, than the initial conditions value can only be set by updating the values on which it depends, it can not be set directly.
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
Set the initial value of the global parameter.
Takes the same indices as the other global parameter methods.
Implemented in rrllvm::LLVMExecutableModel.
|
pure virtual |
set the seed used by the random number generator.
This will by definition reset the RNG.
Implemented in rrllvm::LLVMExecutableModel, and rr::CompiledExecutableModel.
|
pure virtual |
sets the internal model state to the provided packed state std::vector.
[in] | stateVector | an array which holds the packed state std::vector, must be at least the size returned by getStateVector. |
Implemented in rrllvm::LLVMExecutableModel, and rr::CompiledExecutableModel.