roadrunner  2.6.0
Fast simulator for SBML models
rrRoadRunnerOptions.h
1 /*
2 * rrRoadRunnerOptions.h
3 *
4 * Created on: Sep 9, 2013
5 * Author: andy
6 */
7 
8 #ifndef RRROADRUNNEROPTIONS_H_
9 #define RRROADRUNNEROPTIONS_H_
10 
11 #include "rrExporter.h"
12 #include "Dictionary.h"
13 #include "Integrator.h"
14 
15 #include <string>
16 #include <vector>
17 
18 namespace rr
19 {
20 
27  class RR_DECLSPEC LoadSBMLOptions : public BasicDictionary
28  {
29  public:
30  enum LLVM_BACKEND_VALUES {
31  // keep unique, counting ModelGeneratorOpt
32  MCJIT = (0x1 << 14),
33  LLJIT = (0x1 << 15),
34  // LAZYJIT = (0x1 << 0),
35  };
36 
37  enum LLJIT_OPTIMIZATION_LEVELS {
38  NONE = (0x1 << 16),
39  LESS = (0x1 << 17),
40  DEFAULT = (0x1 << 18),
41  AGGRESSIVE = (0x1 << 19)
42  };
43 
44 
45 
46  // Manually and ineloquently list the backend options for iterating over later.
47  static std::vector<LLVM_BACKEND_VALUES> getAllLLVMBackendValues() {
48  return std::vector<LLVM_BACKEND_VALUES>({
49  MCJIT,
50  LLJIT
51  });
52  };
53 
54  // Manually and ineloquently list the lljit optimization options
55  static std::vector<LLJIT_OPTIMIZATION_LEVELS> getAllLLJitOptimizationValues() {
56  return std::vector<LLJIT_OPTIMIZATION_LEVELS>({
57  NONE,
58  LESS,
59  DEFAULT,
60  AGGRESSIVE
61  });
62  };
63 
65  {
75  CONSERVED_MOIETIES = (0x1 << 0), // => 0x00000001
76 
88  RECOMPILE = (0x1 << 1), // => 0x00000010
89 
99  READ_ONLY = (0x1 << 2), // => 0x00000100
100 
105  MUTABLE_INITIAL_CONDITIONS = (0x1 << 3), // => 0x00001000
106 
111  OPTIMIZE_GVN = (0x1 << 4),
112 
117  OPTIMIZE_CFG_SIMPLIFICATION = (0x1 << 5),
118 
124  OPTIMIZE_INSTRUCTION_COMBINING = (0x1 << 6),
125 
131  OPTIMIZE_DEAD_INST_ELIMINATION = (0x1 << 7),
132 
139  OPTIMIZE_DEAD_CODE_ELIMINATION = (0x1 << 8),
140 
144  OPTIMIZE_INSTRUCTION_SIMPLIFIER = (0x1 << 9),
145 
150  OPTIMIZE = OPTIMIZE_GVN | OPTIMIZE_CFG_SIMPLIFICATION |
151  OPTIMIZE_INSTRUCTION_COMBINING |
152  OPTIMIZE_DEAD_INST_ELIMINATION | OPTIMIZE_DEAD_CODE_ELIMINATION |
153  OPTIMIZE_INSTRUCTION_SIMPLIFIER,
154 
163  USE_MCJIT = (0x1 << 10),
164 
165 
166  LLVM_SYMBOL_CACHE = (0x1 << 11),
167 
171  TURN_ON_VALIDATION = (0x1 << 12),
172 
173 
174  };
175 
176  enum LoadOpt
177  {
181  NO_DEFAULT_SELECTIONS = (0x1 << 0), // => 0x00000001
182 
186  NO_DEFAULT_STEADY_STATE_SELECTIONS = (0x1 << 1) // => 0x00000010
187  };
188 
192  LoadSBMLOptions();
193 
197  LoadSBMLOptions(const Dictionary* dict);
198 
202  std::uint16_t version;
203 
207  std::uint16_t size;
208 
209  std::uint32_t modelGeneratorOpt;
210 
211  std::uint32_t loadFlags;
212 
213 
217  void setItem(const std::string& key, const rr::Setting& value) override;
218 
222  Setting getItem(const std::string& key) const override;
223 
229  bool hasKey(const std::string& key) const override;
230 
234  size_t deleteItem(const std::string& key) override;
235 
239  std::vector<std::string> getKeys() const override;
240 
241  bool getConservedMoietyConversion() const {
242  return modelGeneratorOpt & CONSERVED_MOIETIES;
243  }
244 
245  void setConservedMoietyConversion(bool val) {
246  modelGeneratorOpt = val ?
247  modelGeneratorOpt | CONSERVED_MOIETIES :
248  modelGeneratorOpt & ~CONSERVED_MOIETIES;
249  }
250 
251  void setValidation(bool val) {
252  loadFlags = val ? loadFlags | TURN_ON_VALIDATION : loadFlags & ~TURN_ON_VALIDATION;
253  }
254 
255  void setLLVMBackend(LoadSBMLOptions::LLVM_BACKEND_VALUES val);
256 
257  ~LoadSBMLOptions() override;
258 
259  void setLLJitOptimizationLevel(LLJIT_OPTIMIZATION_LEVELS levels);
260 
261  // void setLLJitNumThreads(int numThreads);
262  //
263  // int getLLJitNumThreads() const;
264 
274  // int llJitNumThreads;
275  private:
276 
277  // load default values;
278  void defaultInit();
279  };
280 
281 
293  class RR_DECLSPEC SimulateOptions //: public BasicDictionary
294  {
295  public:
296 
300  SimulateOptions();
301 
316 
323  int steps;
324 
329  double start;
330 
334  double duration;
335 
336 
343  std::string output_file;
344 
359  std::vector<std::string> variables;
360 
366  std::vector<std::string> amounts;
367 
373  std::vector<std::string> concentrations;
374 
375  /*
376  * A list of the requested output times. If set, the simulator will only
377  * report simulation output at the requested values.
378  */
379  std::vector<double> times;
380 
384  std::string toString() const;
385 
389  std::string toRepr() const;
390 
391  /* Use this method to load SimulateOptions from an SBML file. Previously this was done by
392  * passing the filepath into the SimulateOptions constructor. However, the refactor has
393  * removed some properties from SimulateOptions and placed them in specific integrators. As
394  * a result, both the SimulateOptions and Integrator classes will have methods that allow
395  * users to read an SBML settings file.
396  */
397  void loadSBMLSettings(const std::string& filename);
398 
399  //virtual void setItem(const std::string& key, const rr::Setting& value);
400 
401  virtual void initialize();
402 
403  virtual double getNext(size_t step);
404 
408  virtual void reset();
409 
410  private:
411 
412  double hstep; //Used if we have a duration and number of steps, but not 'times'.
413 
414 
415  };
416 
417 
418 
423  struct RR_DECLSPEC RoadRunnerOptions
424  {
425  enum Options
426  {
434  DISABLE_PYTHON_DYNAMIC_PROPERTIES = (0x1 << 0), // => 0x00000001
435  };
436 
440  std::uint32_t flags;
441 
446  double diffStepSize;
447  double steadyStateThreshold;
448  double fluxThreshold;
449 
454 
455  };
456 
457 
458 } /* namespace rr */
459 #endif /* RRROADRUNNEROPTIONS_H_ */
RoadRunner's Gillespie SSA integrator.
This class is frozen, no new features Basic implementation of the Dictionary interface which uses a s...
Definition: Dictionary.h:140
This class is frozen, no new features A dictionary interface that objects can implement.
Definition: Dictionary.h:30
Options for loading SBML into RoadRunner.
Definition: rrRoadRunnerOptions.h:28
LoadOpt
Definition: rrRoadRunnerOptions.h:177
std::uint16_t size
sizeof this struct
Definition: rrRoadRunnerOptions.h:207
ModelGeneratorOpt
Definition: rrRoadRunnerOptions.h:65
std::uint16_t version
the version this struct
Definition: rrRoadRunnerOptions.h:202
Store a roadrunner option (or setting) as a Variant type.
Definition: Setting.h:78
This class is frozen, no new features RoadRunner simulation options.
Definition: rrRoadRunnerOptions.h:294
std::vector< std::string > variables
The variables (in addition to time) whose values will be saved in the result.
Definition: rrRoadRunnerOptions.h:359
std::string output_file
The ouptut file for simulation results.
Definition: rrRoadRunnerOptions.h:343
std::vector< std::string > amounts
A list of the variable whose output in the results file is in amount (not concentration) units.
Definition: rrRoadRunnerOptions.h:366
int steps
The number of steps at which the output is sampled.
Definition: rrRoadRunnerOptions.h:323
std::vector< std::string > concentrations
A list of the variable whose output in the results file is in concentration (not amount) units.
Definition: rrRoadRunnerOptions.h:373
bool reset_model
reset the model to the initial state.
Definition: rrRoadRunnerOptions.h:305
double duration
The duration of the simulation run, in the model's units of time.
Definition: rrRoadRunnerOptions.h:334
bool structured_result
Simulate should return a raw result matrix without adding any column names.
Definition: rrRoadRunnerOptions.h:310
bool copy_result
Make a copy of the simulation result in Python.
Definition: rrRoadRunnerOptions.h:315
double start
The start time of the simulation time-series data.
Definition: rrRoadRunnerOptions.h:329
C_DECL_SPEC bool rrcCallConv reset(RRHandle handle)
Resets all variables of the model to their current initial values. Does not change the parameters.
A set of options that determine how the top level RoadRunner class should behave.
Definition: rrRoadRunnerOptions.h:424
double jacobianStepSize
step size used for numeric Jacobian calculations.
Definition: rrRoadRunnerOptions.h:445
Options
Definition: rrRoadRunnerOptions.h:426
std::uint32_t flags
a bitmask of the options specified in the Options enumeration.
Definition: rrRoadRunnerOptions.h:440