14 # ifndef rrExecutableModelH
15 # define rrExecutableModelH
19 #include "rrOSSpecifics.h"
20 #include "rrException.h"
21 #include "sbml/SBMLDocument.h"
30 #include "tr1proxy/rr_memory.h"
36 class ExecutableModel;
57 HALT_SIMULATION = (0x1 << 0),
59 virtual uint onTrigger(
ExecutableModel *model,
size_t eventIndex,
const std::string &eventId) = 0;
61 virtual uint onAssignment(
ExecutableModel *model,
size_t eventIndex,
const std::string &eventId) = 0;
76 resultCode(resultCode) {
77 msg =
"EventHandlerException, resultCode: ";
80 case EventListener::HALT_SIMULATION:
81 msg +=
"HALT_SIMULATION";
89 virtual const char *what()
const throw() {
93 uint getResultCode()
const {
128 virtual std::string getExecutableModelDesc()
const = 0;
135 virtual void setTime(
double _time) = 0;
137 virtual double getTime() = 0;
164 virtual int getFloatingSpeciesIndex(
const std::string &eid) = 0;
166 virtual std::string getFloatingSpeciesId(
size_t index) = 0;
193 virtual int setFloatingSpeciesAmounts(
size_t len,
int const *indx,
194 const double *values) = 0;
205 virtual int setFloatingSpeciesAmounts(
size_t len,
int const* indx,
206 const double* values,
bool strict) = 0;
251 double const *values) = 0;
264 double const *values) = 0;
284 double const *values) = 0;
309 virtual int getBoundarySpeciesIndex(
const std::string &eid) = 0;
311 virtual std::string getBoundarySpeciesId(
size_t index) = 0;
345 double const *values) = 0;
355 virtual int setBoundarySpeciesAmounts(
size_t len,
int const* indx,
356 double const* values) = 0;
367 virtual int setBoundarySpeciesAmounts(
size_t len,
int const* indx,
368 double const* values,
bool strict) = 0;
381 double const* values) = 0;
401 double const* values) = 0;
454 virtual int setGlobalParameterValues(
size_t len,
int const *indx,
455 const double *values) = 0;
466 virtual int setGlobalParameterValues(
size_t len,
int const* indx,
467 const double* values,
bool strict) = 0;
475 double const *values) = 0;
495 virtual int getNumCompartments() = 0;
497 virtual int getCompartmentIndexForFloatingSpecies(
size_t index) = 0;
499 virtual int getCompartmentIndexForBoundarySpecies(
size_t index) = 0;
501 virtual int getCompartmentIndex(
const std::string &eid) = 0;
503 virtual std::string getCompartmentId(
size_t index) = 0;
524 virtual int setCompartmentVolumes(
size_t len,
int const *indx,
525 const double *values) = 0;
536 virtual int setCompartmentVolumes(
size_t len,
int const* indx,
537 const double* values,
bool strict) = 0;
550 double const *values) = 0;
577 virtual void getIds(
int types, std::list<std::string> &ids) = 0;
588 virtual double getValue(
const std::string &
id) = 0;
593 virtual void setValue(
const std::string &
id,
double value) = 0;
608 virtual int setStoichiometries(
size_t len,
int const *indx,
609 const double *values) = 0;
620 virtual int setStoichiometries(
size_t len,
int const* indx,
621 const double* values,
bool strict) = 0;
629 virtual int setStoichiometry(
int index,
double value) = 0;
638 virtual int setStoichiometry(
int speciesIndex,
int reactionIndex,
double value) = 0;
655 virtual int getNumConservedMoieties() = 0;
657 virtual int getConservedMoietyIndex(
const std::string &eid) = 0;
659 virtual std::string getConservedMoietyId(
size_t index) = 0;
661 virtual int getConservedMoietyValues(
size_t len,
int const *indx,
double *values) = 0;
663 virtual int setConservedMoietyValues(
size_t len,
int const *indx,
664 const double *values) = 0;
666 virtual int getNumRateRules() = 0;
739 virtual int getRateRuleRates(
size_t len,
int const* indx,
double* values);
793 virtual void testConstraints() = 0;
795 virtual std::string
getInfo() = 0;
797 virtual void print(std::ostream &stream) = 0;
804 virtual int getNumEvents() = 0;
832 virtual int applyEvents(
double timeEnd,
const unsigned char *previousEventStatus,
833 const double *initialState,
double *finalState) = 0;
849 virtual void getPiecewiseTriggerRoots(
double time,
const double* y,
double* gdot) = 0;
851 virtual double getNextPendingEventTime(
bool pop) = 0;
853 virtual int getPendingEventSize() = 0;
855 virtual void resetEvents() = 0;
883 virtual std::string getEventId(
size_t index) = 0;
885 virtual void getEventIds(std::list<std::string>&) = 0;
887 virtual void getAssignmentRuleIds(std::list<std::string>&) = 0;
889 virtual void getRateRuleIds(std::list<std::string>&) = 0;
891 virtual void getInitialAssignmentIds(std::list<std::string>&) = 0;
893 virtual void setEventListener(
size_t index,
EventListenerPtr eventHandler) = 0;
911 const double *reactionRates) = 0;
917 virtual void reset(
int options) = 0;
955 INTEGRATION = (0x1 << 0),
960 OPTIMIZE_REACTION_RATE_SELECTION = (0x1 << 1),
972 virtual void saveState(std::ostream &out) {
973 out <<
"Saving state not implemented for this model type";
976 virtual void setIntegrationStartTime(
double time);
978 friend class RoadRunner;
982 double mIntegrationStartTime;
988 uint32_t flags = getFlags();
990 flags |= INTEGRATION;
992 flags &= ~INTEGRATION;
1006 RR_DECLSPEC std::ostream &operator<<(std::ostream &stream, ExecutableModel *model);
Definition: rrExecutableModel.h:73
Notifies the user of SBML events.
Definition: rrExecutableModel.h:54
Base class for all code generation systems; allows compiling and evaluating the model.
Definition: rrExecutableModel.h:118
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.
ExecutableModelFlags
Definition: rrExecutableModel.h:949
virtual void getIds(int types, std::list< std::string > &ids)=0
populates a given list with all the ids that this class can accept.
virtual int getBoundarySpeciesConcentrations(size_t len, int const *indx, double *values)=0
get the boundary species concentrations
virtual int setBoundarySpeciesConcentrations(size_t len, int const *indx, double const *values)=0
set the boundary species concentrations
virtual double getRandom()=0
Get a uniform random number between 0 and 1 created by the RNG.
virtual int getSupportedIdTypes()=0
returns a bit field of the ids that this class supports.
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...
virtual void reset()=0
Loads the initial conditions into the current model state.
virtual double getStoichiometry(int index)=0
Get the current stiochiometry value with the given index.
virtual int setFloatingSpeciesInitConcentrations(size_t len, int const *indx, double const *values)=0
Set the initial concentrations of the floating species.
virtual int getNumDepFloatingSpecies()=0
dependent species are defined by rules and the only way to change them is by changing the values on w...
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 no...
virtual std::string getStoichiometryId(size_t index)=0
get the name of the specified stoichiometry
virtual int setBoundarySpeciesInitConcentrations(size_t len, int const *indx, double const *values)=0
Set the initial concentrations of the boundary species.
virtual int getStoichiometryIndex(const std::string &)=0
get the index of a named stoichiometry
virtual void setFlags(uint32_t)=0
Set certain options that determine the state of the ExecutableModel, these are listed in.
virtual int getReactionRates(size_t len, int const *indx, double *values)=0
get the std::vector of reaction rates.
virtual int getStoichiometryIndex(const std::string &, const std::string &)=0
get the index of a named stoichiometry
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.
virtual int setStateVector(const double *stateVector)=0
sets the internal model state to the provided packed state std::vector.
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.
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 ...
virtual std::string getModelName()=0
get the name of the model
virtual int getNumBoundarySpecies()=0
get the number of boundary species.
virtual int setGlobalParameterInitValues(size_t len, int const *indx, double const *values)=0
Set the initial value of the global parameter.
virtual std::string getGlobalParameterId(size_t index)=0
id of the indexed global parameter.
virtual int getStateVector(double *stateVector)=0
The state std::vector is a std::vector of elements that are defined by differential equations (rate r...
virtual int64_t getRandomSeed()=0
get the seed used by the RNG.
virtual int setBoundarySpeciesInitAmounts(size_t len, int const *indx, double const *values)=0
Set the initial amounts of the boundary species.
virtual ~ExecutableModel()
need a virtual destructor as object implementing this interface can be deleted directly,...
Definition: rrExecutableModel.h:870
virtual void getRateRuleValues(double *rateRuleValues)=0
get the 'values' i.e.
virtual int setCompartmentInitVolumes(size_t len, int const *indx, double const *values)=0
Set the initial volumes of the compartments.
virtual uint32_t getFlags() const =0
Get the current set of flags.
virtual int getReactionIndex(const std::string &eid)=0
get the index of a named reaction
virtual int getBoundarySpeciesAmounts(size_t len, int const *indx, double *values)=0
get the boundary species amounts
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...
virtual int getCompartmentVolumes(size_t len, int const *indx, double *values)=0
get the compartment volumes
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 define...
virtual int getNumFloatingSpecies()=0
total number of floating species.
virtual int getNumPiecewiseTriggers()=0
We do root-finding for 'piecewise triggers': those times in a piecewise function that transition from...
virtual void setRandomSeed(int64_t)=0
set the seed used by the random number generator.
virtual int getNumGlobalParameters()=0
get the number of global parameters
virtual int getFloatingSpeciesConcentrationRates(size_t len, int const *indx, double *values)=0
get the floating species concentration rates
virtual int setFloatingSpeciesInitAmounts(size_t len, int const *indx, double const *values)=0
Set the initial amounts of the floating species.
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...
virtual int getGlobalParameterIndex(const std::string &eid)=0
index of the global parameter id, -1 if it does not exist.
virtual std::string getStateVectorId(size_t index)=0
get the id of an element of the state std::vector.
virtual int getFloatingSpeciesAmounts(size_t len, int const *indx, double *values)=0
get the floating species amounts
virtual void reset(int options)=0
reset the model accordign to a bitfield specified by the SelectionRecord::SelectionType values.
virtual void setValue(const std::string &id, double value)=0
sets the value coresponding to the given selection stringl
virtual int getNumReactions()=0
get the number of reactions the model has
virtual int getNumIndFloatingSpecies()=0
independent species do are not defined by rules, they typically participate in reactions and can have...
void computeAllRatesOfChange()
for source compatability
Definition: rrExecutableModel.h:966
virtual int getFloatingSpeciesAmountRates(size_t len, int const *indx, double *values)=0
get the floating species amount rates
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.
virtual int getEventIndex(const std::string &eid)=0
Gets the index for an event id.
virtual std::string getReactionId(size_t index)=0
get the name of the specified reaction
virtual double getValue(const std::string &id)=0
gets the value for the given id std::string.
void setIntegration(bool value)
is integration is currently proceeding.
Definition: rrExecutableModel.h:987
virtual int setFloatingSpeciesConcentrations(size_t len, int const *indx, double const *values)=0
set the floating species concentrations
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 ...
virtual int getGlobalParameterValues(size_t len, int const *indx, double *values)=0
get the global parameter values
virtual double getStoichiometry(int speciesIndex, int reactionIndex)=0
Get the current stiochiometry value for the given species / reaction.
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 int getFloatingSpeciesConcentrations(size_t len, int const *indx, double *values)=0
get the floating species concentrations
C_DECL_SPEC bool rrcCallConv saveState(RRHandle handle, const char *filename)
Save a road runner instance's state to a platform-specific binary file.
C_DECL_SPEC char *rrcCallConv getInfo(RRHandle handle)
Retrieve info about current state of roadrunner, e.g. loaded model, conservationAnalysis etc.
cxx11_ns::shared_ptr< EventListener > EventListenerPtr
listeners are shared objects, so use std smart pointers to manage them.
Definition: rrExecutableModel.h:71