LLVMModelSymbols
-
class LLVMModelSymbols : private libsbml::SBMLVisitor
Hold all the un-evaluated symbolic inforamtion in the model.
TODO: some real docs…
Public Functions
-
LLVMModelSymbols(libsbml::Model const *m, LLVMModelDataSymbols const &sym)
-
~LLVMModelSymbols()
-
libsbml::ASTNode *createStoichiometryNode(int row, int col) const
create an ASTNode for the species id / reaction id std::pair.
This assembles the mess of items stored in the reactions array.
-
const SymbolForest &getAssigmentRules() const
assignment rules are always active
-
const SymbolForest &getInitialAssignmentRules() const
only valid before the model is started.
There cannot be both an InitialAssignment and an AssignmentRule for the same symbol in a model, because both kinds of constructs apply prior to and at the start of simulated time allowing both to exist for a given symbol would result in indeterminism.
conservation: In the case of conserved moieties, these are species that are defined by assignment rules, they however can have initial values defined by initial value or assignment rules.
So, at run time, the assignment rule is active, however before run time, the initial value or initial assignment rule is active.
-
const SymbolForest &getInitialValues() const
contains the intial symbols along with the intial assignments which override the initial values.
-
const SymbolForest &getRateRules() const
Protected Types
-
typedef std::list<const libsbml::ASTNode*> ASTNodeList
a species can appear more than once in a reaction, there can be several stoichiometries for a species both as a product and as a reactant, for example, we could have
A + 2A + B -> A + C
In this case, we calculate the stochiometry for each species as S(A) = -1 -2 + 1 = -1 S(B) = -1 + 0 = -1 S(C) = 0 + 1 = 1
Stochiometries can however change, so we have to delay evaluation of them — if we have a named species reference, we add an ASTNode with a reference to it: this way, when it get evaluated, we can look up to see if we have any assigment rules or intitial assigments overriding the original value. each species has a list of stoichiometry nodes, this way it can appear more than once.
-
typedef std::map<int, ASTNodeList> IntASTNodeListMap
we reference the reactants and products by the species index
Protected Functions
-
virtual bool visit(const libsbml::Compartment &x)
-
virtual bool visit(const libsbml::Species &x)
-
virtual bool visit(const libsbml::AssignmentRule &x)
-
virtual bool visit(const libsbml::InitialAssignment &x)
InitialAssignments override the initial value specified in the element definition.
The actions of all InitialAssignment objects are in general terms the same, but differ in the precise details depending on the type of variable being set:
In the case of a species, an InitialAssignment sets the referenced species initial quantity (concentration or amount) to the value determined by the formula in math. The unit associated with the value produced by the math formula should be equal to the unit associated with the species quantity.
In the case of a species reference, an InitialAssignment sets the initial stoichiometry of the reactant or product referenced by the SpeciesReference object to the value determined by the formula in math. The unit associated with the value produced by the math formula should be consistent with the unit dimensionless, because reactant and product stoichiometries in reactions are dimensionless quantities.
In the case of a compartment, an InitialAssignment sets the referenced compartment’s initial size to the size determined by the formula in math. The unit associated with the value produced by the math formula should be the same as that specified for the compartment’s size.
In the case of a parameter, an InitialAssignment sets the parameter’s initial value to the value of the formula in math. The unit associated with the value produced by the math formula should be the same as parameter’s units attribute value.
-
virtual bool visit(const libsbml::RateRule &rule)
In the case of a species, a RateRule sets the rate of change of the species� quantity (concentration or amount) to the value determined by the formula in math. The unit associated with the rule�s math element should be equal to the unit of the species� quantity (Section 4.6.5) divided by the model-wide unit of time (Section 4.2.4), or in other words, {unit of species quantity}/{unit of time}.
Restrictions: There must not be both a RateRule variable attribute and a SpeciesReference species attribute having the same value, unless that species has its boundaryCondition attribute is set to �true�. This means a rate rule cannot be defined for a species that is created or destroyed in a reaction, unless that species is defined as a boundary condition in the model.
In the case of a species reference, a RateRule sets the rate of change of the stoichiometry of the referenced reactant or product to the value determined by the formula in math. The unit associated with the value produced by the formula should be consistent with {unit derived from dimensionless}/{unit of time}.
In the case of a compartment, a RateRule sets the rate of change of the compartment�s size to the value determined by the formula in math. The unit of the rule�s math element should be identical to the compartment�s units attribute divided by the model-wide unit of time. (In other words, {unit of compartment size}/{unit of time}.)
In the case of a parameter, a RateRule sets the rate of change of the parameter�s value to that determined by the formula in math. The unit associated with the rule�s math element should be equal to the parameter�s units attribute value divided by the model-wide unit of time. (In other words, {parameter units}/{unit of time}.)
-
virtual bool visit(const libsbml::Reaction &x)
visit the reactions so we can get all the SpeciesReferences and stuff them in the initialConditions std::map.
-
virtual bool visit(const libsbml::Rule &x)
tell the acceptor to process all rules, even the ones we don’t handle so the iteration continues over all rules.
The left-hand side (the variable attribute) of an assignment rule can refer to the identifier of a Species, SpeciesReference, Compartment, or global Parameter object in the model (but not a reaction)
-
virtual bool visit(const libsbml::Event &event)
fatal error if we find these, event not supported yet
-
void processElement(SymbolForest ¤tSymbols, const libsbml::SBase *element, const libsbml::ASTNode *math)
The only differences in how initialAssigments and assignmentRules are handled is whether they are stuffed in the initialAssigment or assignmentRules maps.
This figures out what they refer to, and stuffs the AST in the appropriate std::map.
-
void processSpecies(SymbolForest ¤tSymbols, const libsbml::Species *element, const libsbml::ASTNode *math)
specialized logic to write both amounts and concentrations here.
-
const libsbml::ASTNode *getSpeciesReferenceStoichMath(const libsbml::SpeciesReference *reference)
get the MathML element for a SpeciesReference if it is set, otherwise, create a ASTNode from its stoichiometry field.
Protected Attributes
-
SymbolForest initialValues
-
SymbolForest assignmentRules
-
SymbolForest initialAssignmentRules
-
SymbolForest rateRules
-
ASTNodeFactory nodes
all ASTNodes we create are stored here.
-
std::vector<ReactionSymbols> reactions
these are indexed by reaction index.
the stoichiometry matrix is a N species x N reaction matrix.
-
struct ReactionSymbols
hold the symbols that belong to a reactions.
-
LLVMModelSymbols(libsbml::Model const *m, LLVMModelDataSymbols const &sym)