Skip to content

Commit

Permalink
Add the option to generate all combinations of control overrides for …
Browse files Browse the repository at this point in the history
…one intervention.
  • Loading branch information
daemontus committed Sep 28, 2024
1 parent bfec0c0 commit c1eb7b5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion biobalm/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from itertools import combinations, product
from functools import reduce
from typing import Literal, cast
from typing import Literal, cast, Iterator

import networkx as nx # type: ignore
from biodivine_aeon import AsynchronousGraph, BooleanNetwork
Expand Down Expand Up @@ -159,6 +159,19 @@ def __str__(self):
else:
return "unknown strategy: " + self.__repr__()

def all_control_strategies(self) -> Iterator[ControlOverrides]:
"""
Returns all possible combinations of `ControlOverrides` sequences that
can be used to execute this `Intervention`.
Internally, an intervention consists of multiple control steps that
need to be taken sequentially. For each step in the sequence, an intervention
can have multiple options of how to execute it. With this method,
we can generate the actual sequences that arise by combining all the
available options for each step.
"""
return map(lambda x: list(x), product(*self._control))


def succession_control(
succession_diagram: SuccessionDiagram,
Expand Down

0 comments on commit c1eb7b5

Please sign in to comment.