roadrunner  2.6.0
Fast simulator for SBML models
LLVMModelSymbols.h
1 /*
2  * LLVMModelSymbols.h
3  *
4  * Created on: Jul 16, 2013
5  * Author: andy
6  */
7 
8 #ifndef LLVMLLVMModelSymbolsH
9 #define LLVMLLVMModelSymbolsH
10 
11 #include "SymbolForest.h"
12 #include "ASTNodeFactory.h"
13 #include "ModelDataIRBuilder.h"
14 #include <sbml/Model.h>
15 #include <sbml/SBMLVisitor.h>
16 
17 namespace rrllvm
18 {
19 
25 class LLVMModelSymbols: private libsbml::SBMLVisitor
26 {
27  using libsbml::SBMLVisitor::visit;
28 
29 public:
30  LLVMModelSymbols(libsbml::Model const *m, LLVMModelDataSymbols const &sym);
31 
33 
39  libsbml::ASTNode *createStoichiometryNode(int row, int col) const;
40 
44  const SymbolForest& getAssigmentRules() const;
45 
63 
68  const SymbolForest& getInitialValues() const;
69 
70  const SymbolForest& getRateRules() const;
71 
72 protected:
73 
74  enum SpeciesReferenceType {
75  Reactant, Product
76  };
77 
78  virtual bool visit(const libsbml::Compartment &x);
79  virtual bool visit(const libsbml::Species &x);
80  virtual bool visit(const libsbml::AssignmentRule &x);
81 
111  virtual bool visit(const libsbml::InitialAssignment &x);
112 
146  virtual bool visit(const libsbml::RateRule &rule);
147 
152  virtual bool visit(const libsbml::Reaction &x);
153 
162  virtual bool visit(const libsbml::Rule &x);
163 
167  virtual bool visit (const libsbml::Event &event);
168 
177  void processElement(SymbolForest &currentSymbols,
178  const libsbml::SBase *element, const libsbml::ASTNode *math);
179 
183  void processSpecies(SymbolForest &currentSymbols,
184  const libsbml::Species *element, const libsbml::ASTNode *math);
185 
190  const libsbml::ASTNode *getSpeciesReferenceStoichMath(const libsbml::SpeciesReference *reference);
191 
192  SymbolForest initialValues;
193 
194  SymbolForest assignmentRules;
195 
196  SymbolForest initialAssignmentRules;
197 
198  SymbolForest rateRules;
199 
204 
228  typedef std::list<const libsbml::ASTNode*> ASTNodeList;
229 
233  typedef std::map<int, ASTNodeList> IntASTNodeListMap;
234 
239  IntASTNodeListMap reactants;
240  IntASTNodeListMap products;
241  };
242 
248  std::vector<ReactionSymbols> reactions;
249 
250 private:
251  libsbml::Model const
252  *model;
253  const LLVMModelDataSymbols &symbols;
254 };
255 
256 } /* namespace rr */
257 #endif /* LLVMLLVMModelSymbolsH */
Manages a set of ASTNodes.
Definition: ASTNodeFactory.h:28
stores the names of all the symbols in the sbml model and thier indexes in the ModelData arrays.
Definition: LLVMModelDataSymbols.h:128
Hold all the un-evaluated symbolic inforamtion in the model.
Definition: LLVMModelSymbols.h:26
void processSpecies(SymbolForest &currentSymbols, const libsbml::Species *element, const libsbml::ASTNode *math)
specialized logic to write both amounts and concentrations here.
Definition: LLVMModelSymbols.cpp:288
void processElement(SymbolForest &currentSymbols, const libsbml::SBase *element, const libsbml::ASTNode *math)
The only differences in how initialAssigments and assignmentRules are handled is whether they are stu...
Definition: LLVMModelSymbols.cpp:170
std::map< int, ASTNodeList > IntASTNodeListMap
we reference the reactants and products by the species index
Definition: LLVMModelSymbols.h:233
const SymbolForest & getInitialValues() const
contains the intial symbols along with the intial assignments which override the initial values.
Definition: LLVMModelSymbols.cpp:523
libsbml::ASTNode * createStoichiometryNode(int row, int col) const
create an ASTNode for the species id / reaction id std::pair.
Definition: LLVMModelSymbols.cpp:417
std::list< const libsbml::ASTNode * > ASTNodeList
a species can appear more than once in a reaction, there can be several stoichiometries for a species...
Definition: LLVMModelSymbols.h:228
std::vector< ReactionSymbols > reactions
these are indexed by reaction index.
Definition: LLVMModelSymbols.h:248
const SymbolForest & getInitialAssignmentRules() const
only valid before the model is started.
Definition: LLVMModelSymbols.cpp:533
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 stoi...
Definition: LLVMModelSymbols.cpp:394
ASTNodeFactory nodes
all ASTNodes we create are stored here.
Definition: LLVMModelSymbols.h:203
const SymbolForest & getAssigmentRules() const
assignment rules are always active
Definition: LLVMModelSymbols.cpp:518
Similar to a symbol table, except instead of a name / value, we have a name / tree,...
Definition: SymbolForest.h:37
hold the symbols that belong to a reactions.
Definition: LLVMModelSymbols.h:238