ecell / ecell4_base

An integrated software environment for multi-algorithm, multi-timescale, multi-spatial-representation simulation of various cellular phenomena
https://ecell4.e-cell.org/
GNU General Public License v3.0
62 stars 23 forks source link

Rule-based modeling with guards #86

Open kaizu opened 8 years ago

kaizu commented 8 years ago

Something like:

with reaction_rules():
    X(p=_1) > X(p=_1 + 1) | (_1 < 5) | k
    # will generate "X(p=1) > X(p=2) | k" and so on.

Of course, this is completely wrong in the current semantics.

See https://en.wikipedia.org/wiki/Guard_%28computer_science%29

kaizu commented 8 years ago

In this case, the following might be enough:

with reaction_rules():
    for i in range(5):
        X(p=ac("int{}".format(i))) > X(p=ac("int{}".format(i + 1))) | k

where ac returns a AnyCallable object with the given name. This will generate X(p=int1) > X(p=int2) | k.

kaizu commented 8 years ago

The following expression is available now.

with reaction_rules():
    _eval; _int = lambda i: _eval("int{}".format(i))
    for i in range(5):
        X(p=_int(i)) > X(p=_int(i + 1)) | k

See https://github.com/ecell/ecell4/commit/e7f903557a0e2da846403168823e981b0b6b4fc5

However, this is not rule-based.