libRoadRunner C++ API  1.3
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Types | Public Member Functions | Protected Member Functions | List of all members
rr::ExecutableModel Class Referenceabstract

Base class for all code generation systems; allows compiling and evaluating the model. More...

#include <rrExecutableModel.h>

Inheritance diagram for rr::ExecutableModel:
rrllvm::LLVMExecutableModel

Public Types

enum  ExecutableModelFlags { INTEGRATION = (0x1 << 0), OPTIMIZE_REACTION_RATE_SELECTION = (0x1 << 1) }
 

Public Member Functions

virtual std::string getExecutableModelDesc () const =0
 Returns a human-readable description of the code generation backend, e.g. LLVM, legacy C, etc. More...
 
virtual std::string getModelName ()=0
 
virtual void reset ()=0
 
virtual int getNumDepFloatingSpecies ()=0
 
virtual int getNumFloatingSpecies ()=0
 
virtual int getNumIndFloatingSpecies ()=0
 
virtual int getFloatingSpeciesAmounts (int len, int const *indx, double *values)=0
 
virtual int getFloatingSpeciesConcentrations (int len, int const *indx, double *values)=0
 
virtual int setFloatingSpeciesConcentrations (int len, int const *indx, double const *values)=0
 
virtual int setFloatingSpeciesInitConcentrations (int len, int const *indx, double const *values)=0
 
virtual int getFloatingSpeciesInitConcentrations (int len, int const *indx, double *values)=0
 
virtual int setFloatingSpeciesInitAmounts (int len, int const *indx, double const *values)=0
 
virtual int getFloatingSpeciesInitAmounts (int len, int const *indx, double *values)=0
 
virtual int getNumBoundarySpecies ()=0
 
virtual int getBoundarySpeciesAmounts (int len, int const *indx, double *values)=0
 
virtual int getBoundarySpeciesConcentrations (int len, int const *indx, double *values)=0
 
virtual int setBoundarySpeciesConcentrations (int len, int const *indx, double const *values)=0
 
virtual int getNumGlobalParameters ()=0
 
virtual int getGlobalParameterIndex (const std::string &eid)=0
 
virtual std::string getGlobalParameterId (int index)=0
 
virtual int getGlobalParameterValues (int len, int const *indx, double *values)=0
 
virtual int getCompartmentVolumes (int len, int const *indx, double *values)=0
 
virtual int setCompartmentInitVolumes (int len, int const *indx, double const *values)=0
 
virtual int getCompartmentInitVolumes (int len, int const *indx, double *values)=0
 
virtual void getIds (int types, std::list< std::string > &ids)=0
 
virtual int getSupportedIdTypes ()=0
 
virtual double getValue (const std::string &id)=0
 
virtual void setValue (const std::string &id, double value)=0
 
virtual int getStoichiometryMatrix (int *rows, int *cols, double **data)=0
 
virtual double getStoichiometry (int speciesIndex, int reactionIndex)=0
 
virtual std::vector< std::string > getRateRuleSymbols () const
 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
 
virtual int getReactionIndex (const std::string &eid)=0
 
virtual std::string getReactionId (int index)=0
 
virtual int getReactionRates (int len, int const *indx, double *values)=0
 
virtual void getRateRuleValues (double *rateRuleValues)=0
 
virtual std::string getStateVectorId (int index)=0
 
virtual int getStateVector (double *stateVector)=0
 
virtual int setStateVector (const double *stateVector)=0
 
virtual void getStateVectorRate (double time, const double *y, double *dydt=0)=0
 
virtual int getEventTriggers (int len, const int *indx, unsigned char *values)=0
 
virtual int applyEvents (double timeEnd, const unsigned char *previousEventStatus, const double *initialState, double *finalState)=0
 
virtual void getEventRoots (double time, const double *y, double *gdot)=0
 
virtual ~ExecutableModel ()
 
virtual int getEventIndex (const std::string &eid)=0
 
virtual double getFloatingSpeciesAmountRate (int index, const double *reactionRates)=0
 
virtual void reset (int options)=0
 
virtual void setRandomSeed (int64_t)=0
 
virtual int64_t getRandomSeed ()=0
 
virtual double getRandom ()=0
 
virtual uint32_t getFlags () const =0
 
virtual void setFlags (uint32_t)=0
 
void computeAllRatesOfChange ()
 

Protected Member Functions

void setIntegration (bool value)
 

Detailed Description

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 shoud also contain all of the initial condisions, rules, functions and whatever other semantic information that was specified in the sbml model.

Member Enumeration Documentation

Enumerator
INTEGRATION 

A simulation is currently running. This means that the model should not have to re-calculate the reaction rate vector as it was calculated in the previous integration step.

OPTIMIZE_REACTION_RATE_SELECTION 

optimize not-recalculating the reaction rates during selection.

Constructor & Destructor Documentation

virtual rr::ExecutableModel::~ExecutableModel ( )
inlinevirtual

need a virtual destructor as object implementing this interface can be deleted directly, i.e. ExecutableModel *p = createModel(...); delete p;

Member Function Documentation

virtual int rr::ExecutableModel::applyEvents ( double  timeEnd,
const unsigned char *  previousEventStatus,
const double *  initialState,
double *  finalState 
)
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.

Parameters
timeEndmodel time when the event occured.
previousEventStatusarray of previous event triggered states.
initialState(optional): initial state vector, may be NULL, in which the current state is used.
finalState(optional): final state vector, where the final state is coppied to. May be NULL, in which case, ignored.

Implemented in rrllvm::LLVMExecutableModel.

void rr::ExecutableModel::computeAllRatesOfChange ( )
inline

for source compatability

virtual int rr::ExecutableModel::getBoundarySpeciesAmounts ( int  len,
int const *  indx,
double *  values 
)
pure virtual

get the boundary species amounts

Parameters
[in]lenthe length of the indx and values arrays.
[in]indxan array of length len of boundary species to return.
[out]valuesan array of at least length len which will store the returned boundary species amounts.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getBoundarySpeciesConcentrations ( int  len,
int const *  indx,
double *  values 
)
pure virtual

get the boundary species concentrations

Parameters
[in]lenthe length of the indx and values arrays.
[in]indxan array of length len of boundary species to return.
[out]valuesan array of at least length len which will store the returned boundary species amounts.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getCompartmentInitVolumes ( int  len,
int const *  indx,
double *  values 
)
pure virtual

Get the initial volume of the compartments, uses the same indexing as the other compartment methods.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getCompartmentVolumes ( int  len,
int const *  indx,
double *  values 
)
pure virtual

get the compartment volumes

Parameters
[in]lenthe length of the indx and values arrays.
[in]indxan array of length len of boundary species to return.
[out]valuesan array of at least length len which will store the returned boundary species amounts.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getEventIndex ( const std::string &  eid)
pure virtual

Gets the index for an event id. If there is no event with this id, returns -1.

Implemented in rrllvm::LLVMExecutableModel.

virtual void rr::ExecutableModel::getEventRoots ( double  time,
const double *  y,
double *  gdot 
)
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.

Parameters
time[in]current time
y[in]the state vector
gdot[out]result event roots, this is of length numEvents.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getEventTriggers ( int  len,
const int *  indx,
unsigned char *  values 
)
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.

virtual std::string rr::ExecutableModel::getExecutableModelDesc ( ) const
pure virtual

Returns a human-readable description of the code generation backend, e.g. LLVM, legacy C, etc.

Author
JKM
Date
07/31/2015

Implemented in rrllvm::LLVMExecutableModel.

virtual uint32_t rr::ExecutableModel::getFlags ( ) const
pure virtual

Get the current set of flags

Implemented in rrllvm::LLVMExecutableModel.

virtual double rr::ExecutableModel::getFloatingSpeciesAmountRate ( int  index,
const double *  reactionRates 
)
pure virtual

Get the amount rate of change for the i'th floating species given a reaction rates 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 vector via getReactionRates

Parameters
indexindex of the desired floating speceis rate.
reactionRatespointer to buffer of reaction rates.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getFloatingSpeciesAmounts ( int  len,
int const *  indx,
double *  values 
)
pure virtual

get the floating species amounts

Parameters
[in]lenthe length of the indx and values arrays.
[in]indxan array of length len of boundary species to return.
[out]valuesan array of at least length len which will store the returned boundary species amounts.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getFloatingSpeciesConcentrations ( int  len,
int const *  indx,
double *  values 
)
pure virtual

get the floating species concentrations

Parameters
[in]lenthe length of the indx and values arrays.
[in]indxan array of length len of boundary species to return.
[out]valuesan array of at least length len which will store the returned boundary species amounts.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getFloatingSpeciesInitAmounts ( int  len,
int const *  indx,
double *  values 
)
pure virtual

Get the initial amounts of the floating species, uses the same indexing as the other floating species methods.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getFloatingSpeciesInitConcentrations ( int  len,
int const *  indx,
double *  values 
)
pure virtual

Get the initial concentrations of the floating species, uses the same indexing as the other floating species methods.

Implemented in rrllvm::LLVMExecutableModel.

virtual std::string rr::ExecutableModel::getGlobalParameterId ( int  index)
pure virtual

id of the indexed global parameter.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getGlobalParameterIndex ( const std::string &  eid)
pure virtual

index of the global parameter id, -1 if it does not exist.

virtual int rr::ExecutableModel::getGlobalParameterValues ( int  len,
int const *  indx,
double *  values 
)
pure virtual

get the global parameter values

Parameters
[in]lenthe length of the indx and values arrays.
[in]indxan array of length len of boundary species to return.
[out]valuesan array of at least length len which will store the returned boundary species amounts.

Implemented in rrllvm::LLVMExecutableModel.

virtual void rr::ExecutableModel::getIds ( int  types,
std::list< std::string > &  ids 
)
pure virtual

populates a given list with all the ids that this class can accept.

Parameters
idsa list of strings that will be filled by this class.
typesthe 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.

virtual std::string rr::ExecutableModel::getModelName ( )
pure virtual

get the name of the model

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getNumBoundarySpecies ( )
pure virtual

get the number of boundary species.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getNumDepFloatingSpecies ( )
pure virtual

dependent species are defined by rules and the only way to change them is by changing the values on which they depend.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getNumFloatingSpecies ( )
pure virtual

total number of floating species.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getNumGlobalParameters ( )
pure virtual

get the number of global parameters

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getNumIndFloatingSpecies ( )
pure virtual

independent species do are not defined by rules, they typically participate in reactions and can have thier values set at any time.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getNumReactions ( )
pure virtual

get the number of reactions the model has

Implemented in rrllvm::LLVMExecutableModel.

virtual double rr::ExecutableModel::getRandom ( )
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.

virtual int64_t rr::ExecutableModel::getRandomSeed ( )
pure virtual

get the seed used by the RNG.

Implemented in rrllvm::LLVMExecutableModel.

virtual std::vector<std::string> rr::ExecutableModel::getRateRuleSymbols ( ) const
inlinevirtual

Gets the symbols defined by rate rules, i.e. returns all x such that x' = f(x) is a rule which defines parameter x.

Author
JKM
Date
07/31/2015

Reimplemented in rrllvm::LLVMExecutableModel.

virtual void rr::ExecutableModel::getRateRuleValues ( double *  rateRuleValues)
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.

virtual std::string rr::ExecutableModel::getReactionId ( int  index)
pure virtual

get the name of the specified reaction

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getReactionIndex ( const std::string &  eid)
pure virtual

get the index of a named reaction

Returns
>= 0 on success, < 0 on failure.
virtual int rr::ExecutableModel::getReactionRates ( int  len,
int const *  indx,
double *  values 
)
pure virtual

get the vector of reaction rates.

Parameters
lenthe length of the suplied buffer, must be >= reaction rates size.
indxpointer to index array. If NULL, then it is ignored and the reaction rates are copied directly into the suplied buffer.
valuespointer to user suplied buffer where rates will be stored.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getStateVector ( double *  stateVector)
pure virtual

The state vector is a 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 vector elements, use getStateVectorId.

copies the internal model state vector into the provided buffer.

Parameters
[out]stateVectora buffer to copy the state vector into, if NULL, return the size required.
Returns
the number of items coppied into the provided buffer, if stateVector is NULL, returns the length of the state vector.

Implemented in rrllvm::LLVMExecutableModel.

virtual std::string rr::ExecutableModel::getStateVectorId ( int  index)
pure virtual

get the id of an element of the state vector.

Implemented in rrllvm::LLVMExecutableModel.

virtual void rr::ExecutableModel::getStateVectorRate ( double  time,
const double *  y,
double *  dydt = 0 
)
pure virtual

the state vector y is the rate rule values and floating species concentrations concatenated. y is of length numFloatingSpecies + numRateRules.

The state 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.

Parameters
[in]timecurrent simulator time
[in]ystate 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 vector.
[out]dydtcalculated rate of change of the state vector, if null, it is ignored.

Implemented in rrllvm::LLVMExecutableModel.

virtual double rr::ExecutableModel::getStoichiometry ( int  speciesIndex,
int  reactionIndex 
)
pure virtual

Get the current stiochiometry value for the given species / reaction.

If either are not valid, NaN is returned.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getStoichiometryMatrix ( int *  rows,
int *  cols,
double **  data 
)
pure virtual

allocate a block of memory and copy the stochiometric values into it, and return it.

The caller is responsible for freeing the memory that is referenced by data.

Parameters
[out]rowswill hold the number of rows in the matrix.
[out]colswill hold the number of columns in the matrix.
[out]dataa pointer which will hold a newly allocated memory block.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::getSupportedIdTypes ( )
pure virtual

returns a bit field of the ids that this class supports.

Implemented in rrllvm::LLVMExecutableModel.

virtual double rr::ExecutableModel::getValue ( const std::string &  id)
pure virtual

gets the value for the given id string. The string must be a SelectionRecord string that is accepted by this class.

Implemented in rrllvm::LLVMExecutableModel.

virtual void rr::ExecutableModel::reset ( )
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.

virtual void rr::ExecutableModel::reset ( int  options)
pure virtual

reset the model accordign to a bitfield specified by the SelectionRecord::SelectionType values.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::setBoundarySpeciesConcentrations ( int  len,
int const *  indx,
double const *  values 
)
pure virtual

set the boundary species concentrations

Parameters
[in]lenthe length of the indx and values arrays.
[in]indxan array of length len of boundary species to return.
[in]valuesan array of at least length len which will store the returned boundary species amounts.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::setCompartmentInitVolumes ( int  len,
int const *  indx,
double const *  values 
)
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.

virtual void rr::ExecutableModel::setFlags ( uint32_t  )
pure virtual

Set certain options that determine the state of the ExecutableModel, these are listed in

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::setFloatingSpeciesConcentrations ( int  len,
int const *  indx,
double const *  values 
)
pure virtual

set the floating species concentrations

Parameters
[in]lenthe length of the indx and values arrays.
[in]indxan array of length len of boundary species to return.
[in]valuesan array of at least length len which will store the returned boundary species amounts.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::setFloatingSpeciesInitAmounts ( int  len,
int const *  indx,
double const *  values 
)
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.

virtual int rr::ExecutableModel::setFloatingSpeciesInitConcentrations ( int  len,
int const *  indx,
double const *  values 
)
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.

void rr::ExecutableModel::setIntegration ( bool  value)
inlineprotected

is integration is currently proceeding.

virtual void rr::ExecutableModel::setRandomSeed ( int64_t  )
pure virtual

set the seed used by the random number generator. This will by definition reset the RNG.

Implemented in rrllvm::LLVMExecutableModel.

virtual int rr::ExecutableModel::setStateVector ( const double *  stateVector)
pure virtual

sets the internal model state to the provided packed state vector.

Parameters
[in]anarray which holds the packed state vector, must be at least the size returned by getStateVector.
Returns
the number of items copied from the state vector, negative on failure.

Implemented in rrllvm::LLVMExecutableModel.

virtual void rr::ExecutableModel::setValue ( const std::string &  id,
double  value 
)
pure virtual

sets the value coresponding to the given selection stringl

Implemented in rrllvm::LLVMExecutableModel.


The documentation for this class was generated from the following file: