get_param
This commit is contained in:
@@ -17,6 +17,7 @@ class ReactionSystemWithConcentrationsParam(ReactionSystem):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.reactions = []
|
self.reactions = []
|
||||||
|
self.parameters = dict()
|
||||||
self.parametric_reactions = []
|
self.parametric_reactions = []
|
||||||
self.meta_reactions = dict()
|
self.meta_reactions = dict()
|
||||||
self.permanent_entities = dict()
|
self.permanent_entities = dict()
|
||||||
@@ -49,6 +50,24 @@ class ReactionSystemWithConcentrationsParam(ReactionSystem):
|
|||||||
if self.max_concentration < def_max_conc:
|
if self.max_concentration < def_max_conc:
|
||||||
self.max_concentration = def_max_conc
|
self.max_concentration = def_max_conc
|
||||||
|
|
||||||
|
def get_param(self, name):
|
||||||
|
if self.has_param(name):
|
||||||
|
return self.parameters[name]
|
||||||
|
else:
|
||||||
|
param = ParameterObj(name)
|
||||||
|
self.add_param(param)
|
||||||
|
return param
|
||||||
|
|
||||||
|
def has_param(self, name):
|
||||||
|
return name in self.parameters
|
||||||
|
|
||||||
|
def add_param(self, param):
|
||||||
|
if param in self.parameters:
|
||||||
|
raise RuntimeError("Parameter {:s} already exists".format(param))
|
||||||
|
param_key = param.name
|
||||||
|
self.parameters[param_key] = param
|
||||||
|
self.parameters[param_key].idx = len(self.parameters)
|
||||||
|
|
||||||
def get_max_concentration_level(self, e):
|
def get_max_concentration_level(self, e):
|
||||||
|
|
||||||
if e in self.max_conc_per_ent:
|
if e in self.max_conc_per_ent:
|
||||||
|
|||||||
@@ -25,9 +25,11 @@ def trivial_param():
|
|||||||
r.add_bg_set_entity(("z", 3))
|
r.add_bg_set_entity(("z", 3))
|
||||||
r.add_bg_set_entity(("final", 1))
|
r.add_bg_set_entity(("final", 1))
|
||||||
|
|
||||||
|
param_p1 = r.get_param("P1")
|
||||||
|
|
||||||
r.add_reaction([("x", 1)], [("c", 1)], [("y", 2)])
|
r.add_reaction([("x", 1)], [("c", 1)], [("y", 2)])
|
||||||
r.add_reaction([("y", 1)], [("c", 1)], [("z", 1)])
|
r.add_reaction([("y", 1)], [("c", 1)], [("z", 1)])
|
||||||
r.add_reaction(ParameterObj("P1"), [("c", 1)], [("final", 1)])
|
r.add_reaction(param_p1, [("c", 1)], [("final", 1)])
|
||||||
|
|
||||||
c = ContextAutomatonWithConcentrations(r)
|
c = ContextAutomatonWithConcentrations(r)
|
||||||
c.add_init_state("0")
|
c.add_init_state("0")
|
||||||
|
|||||||
Reference in New Issue
Block a user