libRoadRunner C++ API  1.3
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Friends | List of all members
rrllvm::LLVMExecutableModel Class Reference

LLVM executable model. More...

#include <LLVMExecutableModel.h>

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

Public Member Functions

virtual std::string getExecutableModelDesc () const
 Returns a human-readable description of the code generation backend, e.g. LLVM, legacy C, etc. More...
 
 LLVMExecutableModel ()
 
 LLVMExecutableModel (const cxx11_ns::shared_ptr< ModelResources > &resources, LLVMModelData *modelData)
 
virtual string getModelName ()
 
void evalInitialConditions (uint32_t flags=0)
 
virtual void reset ()
 
virtual void reset (int options)
 
virtual int getNumIndFloatingSpecies ()
 
virtual int getNumDepFloatingSpecies ()
 
virtual int getNumFloatingSpecies ()
 
virtual int getNumBoundarySpecies ()
 
virtual int getNumGlobalParameters ()
 
virtual int getGlobalParameterValues (int len, int const *indx, double *values)
 
virtual int getNumReactions ()
 
virtual int getReactionRates (int len, int const *indx, double *values)
 
virtual int getCompartmentVolumes (int len, int const *indx, double *values)
 
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 void getRateRuleValues (double *rateRuleValues)
 
virtual std::string getStateVectorId (int index)
 
virtual int getStateVector (double *stateVector)
 
virtual int setStateVector (const double *stateVector)
 
virtual void getStateVectorRate (double time, const double *y, double *dydt=0)
 
virtual int getFloatingSpeciesAmounts (int len, int const *indx, double *values)
 
virtual int getFloatingSpeciesConcentrations (int len, int const *indx, double *values)
 
virtual int setFloatingSpeciesConcentrations (int len, int const *indx, double const *values)
 
virtual int getBoundarySpeciesAmounts (int len, int const *indx, double *values)
 
virtual int getBoundarySpeciesConcentrations (int len, int const *indx, double *values)
 
virtual int setBoundarySpeciesConcentrations (int len, int const *indx, double const *values)
 
virtual int setBoundarySpeciesAmounts (int len, int const *indx, double const *values)
 
virtual string getGlobalParameterId (int)
 
virtual string getReactionId (int)
 
virtual double getStoichiometry (int speciesIndex, int reactionIndex)
 
virtual int getStoichiometryMatrix (int *rows, int *cols, double **data)
 
virtual int setFloatingSpeciesInitConcentrations (int len, const int *indx, double const *values)
 
virtual int getFloatingSpeciesInitConcentrations (int len, const int *indx, double *values)
 
virtual int setFloatingSpeciesInitAmounts (int len, const int *indx, double const *values)
 
virtual int getFloatingSpeciesInitAmounts (int len, const int *indx, double *values)
 
virtual int setCompartmentInitVolumes (int len, const int *indx, double const *values)
 
virtual int getCompartmentInitVolumes (int len, const int *indx, double *values)
 
virtual void getIds (int types, std::list< std::string > &ids)
 
virtual int getSupportedIdTypes ()
 
virtual double getValue (const std::string &id)
 
virtual void setValue (const std::string &id, double value)
 
virtual void setRandomSeed (int64_t)
 
virtual int64_t getRandomSeed ()
 
virtual double getRandom ()
 
virtual int getEventTriggers (int len, const int *indx, unsigned char *eventState)
 Get status of event triggers. More...
 
virtual int applyEvents (double timeEnd, const unsigned char *previousEventState, const double *initialState, double *finalState)
 
virtual void getEventRoots (double time, const double *y, double *gdot)
 
void assignEvent (uint eventId, double *data)
 
virtual int getEventIndex (const std::string &eid)
 
virtual double getFloatingSpeciesAmountRate (int index, const double *reactionRates)
 
int getRateRueRates (int len, int const *indx, double *values)
 
virtual uint32_t getFlags () const
 
virtual void setFlags (uint32_t val)
 
- Public Member Functions inherited from rr::ExecutableModel
virtual int getGlobalParameterIndex (const std::string &eid)=0
 
virtual int getReactionIndex (const std::string &eid)=0
 
virtual ~ExecutableModel ()
 
void computeAllRatesOfChange ()
 

Friends

template<typename a_type , typename b_type >
void copyCachedModel (a_type *src, b_type *dst)
 

Additional Inherited Members

- Public Types inherited from rr::ExecutableModel
enum  ExecutableModelFlags { INTEGRATION = (0x1 << 0), OPTIMIZE_REACTION_RATE_SELECTION = (0x1 << 1) }
 
- Protected Member Functions inherited from rr::ExecutableModel
void setIntegration (bool value)
 

Detailed Description

LLVM executable model.

Author
ETS

Interface to LLVM executable model.

Constructor & Destructor Documentation

rrllvm::LLVMExecutableModel::LLVMExecutableModel ( )

the default ctor just zeros out all our private bits, then the main construction is handled by the model generator.

rrllvm::LLVMExecutableModel::LLVMExecutableModel ( const cxx11_ns::shared_ptr< ModelResources > &  resources,
LLVMModelData modelData 
)

takes ownership of the LLVMModelData pointer.

Member Function Documentation

int rrllvm::LLVMExecutableModel::applyEvents ( double  timeEnd,
const unsigned char *  previousEventState,
const double *  initialState,
double *  finalState 
)
virtual

erases expired events, and applies ripe events as long as we have ripe events.

Implements rr::ExecutableModel.

void rrllvm::LLVMExecutableModel::assignEvent ( uint  eventId,
double *  data 
)
inline

assign or apply the event using the given data.

void rrllvm::LLVMExecutableModel::evalInitialConditions ( uint32_t  flags = 0)

evaluate the initial conditions specified in the sbml, this entails evaluating all InitialAssigments, AssigmentRules, initial values, etc...

The the model state is fully set.

int rrllvm::LLVMExecutableModel::getBoundarySpeciesAmounts ( int  len,
int const *  indx,
double *  values 
)
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.

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getBoundarySpeciesConcentrations ( int  len,
int const *  indx,
double *  values 
)
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.

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getCompartmentInitVolumes ( int  len,
const int *  indx,
double *  values 
)
virtual

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

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getCompartmentVolumes ( int  len,
int const *  indx,
double *  values 
)
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.

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getEventIndex ( const std::string &  eid)
virtual

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

Implements rr::ExecutableModel.

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

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getEventTriggers ( int  len,
const int *  indx,
unsigned char *  eventState 
)
virtual

Get status of event triggers.

Author
ETS

When len <= 0, returns number of events. Otherwise, sets bits in eventState to the corresponding trigger.

Parameters
[in]lenThe length of indx
[in]indxAn index into eventState
[out]eventStateThe state of the event triggers

Implements rr::ExecutableModel.

virtual std::string rrllvm::LLVMExecutableModel::getExecutableModelDesc ( ) const
inlinevirtual

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

Author
JKM
Date
07/31/2015

Implements rr::ExecutableModel.

virtual uint32_t rrllvm::LLVMExecutableModel::getFlags ( ) const
inlinevirtual

Get the current set of flags

Implements rr::ExecutableModel.

double rrllvm::LLVMExecutableModel::getFloatingSpeciesAmountRate ( int  index,
const double *  reactionRates 
)
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.

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getFloatingSpeciesAmounts ( int  len,
int const *  indx,
double *  values 
)
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.

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getFloatingSpeciesConcentrations ( int  len,
int const *  indx,
double *  values 
)
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.

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getFloatingSpeciesInitAmounts ( int  len,
const int *  indx,
double *  values 
)
virtual

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

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getFloatingSpeciesInitConcentrations ( int  len,
const int *  indx,
double *  values 
)
virtual

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

Implements rr::ExecutableModel.

string rrllvm::LLVMExecutableModel::getGlobalParameterId ( int  index)
virtual

id of the indexed global parameter.

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getGlobalParameterValues ( int  len,
int const *  indx,
double *  values 
)
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.

Implements rr::ExecutableModel.

void rrllvm::LLVMExecutableModel::getIds ( int  types,
std::list< std::string > &  ids 
)
virtual

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

Implements rr::ExecutableModel.

string rrllvm::LLVMExecutableModel::getModelName ( )
virtual

get the name of the model

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getNumBoundarySpecies ( )
virtual

get the number of boundary species.

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getNumDepFloatingSpecies ( )
virtual

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

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getNumFloatingSpecies ( )
virtual

total number of floating species.

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getNumGlobalParameters ( )
virtual

get the number of global parameters

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getNumIndFloatingSpecies ( )
virtual

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

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getNumReactions ( )
virtual

get the number of reactions the model has

Implements rr::ExecutableModel.

double rrllvm::LLVMExecutableModel::getRandom ( )
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.

Implements rr::ExecutableModel.

int64_t rrllvm::LLVMExecutableModel::getRandomSeed ( )
virtual

get the seed used by the RNG.

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getRateRueRates ( int  len,
int const *  indx,
double *  values 
)

calculate rate rule values. TODO redo this function, not very effecient.

std::vector< std::string > rrllvm::LLVMExecutableModel::getRateRuleSymbols ( ) const
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.

Author
JKM
Date
07/31/2015

Reimplemented from rr::ExecutableModel.

void rrllvm::LLVMExecutableModel::getRateRuleValues ( double *  rateRuleValues)
virtual

copy (but do not evaluate) existing rate rules values into a buffer.

Implements rr::ExecutableModel.

string rrllvm::LLVMExecutableModel::getReactionId ( int  index)
virtual

get the name of the specified reaction

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getReactionRates ( int  len,
int const *  indx,
double *  values 
)
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.

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getStateVector ( double *  stateVector)
virtual

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.

Implements rr::ExecutableModel.

std::string rrllvm::LLVMExecutableModel::getStateVectorId ( int  index)
virtual

get the id of an element of the state vector.

Implements rr::ExecutableModel.

void rrllvm::LLVMExecutableModel::getStateVectorRate ( double  time,
const double *  y,
double *  dydt = 0 
)
virtual

where most of the juicy bits occur.

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 of size returned by getStateVector
[out]dydtcalculated rate of change of the state vector, if null, it is ignored.

Implements rr::ExecutableModel.

double rrllvm::LLVMExecutableModel::getStoichiometry ( int  speciesIndex,
int  reactionIndex 
)
virtual

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

If either are not valid, NaN is returned.

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getStoichiometryMatrix ( int *  rows,
int *  cols,
double **  data 
)
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.

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::getSupportedIdTypes ( )
virtual

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

Implements rr::ExecutableModel.

double rrllvm::LLVMExecutableModel::getValue ( const std::string &  id)
virtual

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

Implements rr::ExecutableModel.

void rrllvm::LLVMExecutableModel::reset ( )
virtual

call reset(options) with defaut options.

Implements rr::ExecutableModel.

void rrllvm::LLVMExecutableModel::reset ( int  options)
virtual

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

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::setBoundarySpeciesAmounts ( int  len,
int const *  indx,
double const *  values 
)
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.
[in]valuesan array of at least length len which will store the returned boundary species amounts.
int rrllvm::LLVMExecutableModel::setBoundarySpeciesConcentrations ( int  len,
int const *  indx,
double const *  values 
)
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.
[in]valuesan array of at least length len which will store the returned boundary species amounts.

Implements rr::ExecutableModel.

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

Implements rr::ExecutableModel.

virtual void rrllvm::LLVMExecutableModel::setFlags ( uint32_t  val)
inlinevirtual

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

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::setFloatingSpeciesConcentrations ( int  len,
int const *  indx,
double const *  values 
)
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.

Implements rr::ExecutableModel.

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

Implements rr::ExecutableModel.

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

Implements rr::ExecutableModel.

void rrllvm::LLVMExecutableModel::setRandomSeed ( int64_t  seed)
virtual

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

Implements rr::ExecutableModel.

int rrllvm::LLVMExecutableModel::setStateVector ( const double *  stateVector)
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.

Implements rr::ExecutableModel.

void rrllvm::LLVMExecutableModel::setValue ( const std::string &  id,
double  value 
)
virtual

sets the value coresponding to the given selection stringl

Implements rr::ExecutableModel.

Friends And Related Function Documentation

template<typename a_type , typename b_type >
void copyCachedModel ( a_type *  src,
b_type *  dst 
)
friend

copy the cached model fields between a cached model, and a executable model.

We don't want to have ExecutableModel inherit from CahcedModel because they do compleltly different things, and have completly differnt deletion semantics


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