Skip to content

Commit

Permalink
more detail about symbolic context + rename argument
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrozum committed Mar 8, 2024
1 parent c9ffc84 commit a8f82c3
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions balm/petri_net_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def restrict_petrinet_to_subspace(


def network_to_petrinet(
network: BooleanNetwork, ctx: SymbolicContext | None = None
network: BooleanNetwork, symbolic_context: SymbolicContext | None = None
) -> DiGraph:
"""
Convert a Boolean network to a Petri net.
Expand All @@ -278,9 +278,11 @@ def network_to_petrinet(
----------
network : BooleanNetwork
The network to convert.
ctx : SymbolicContext | None
The context used for the symbolic conversion. If not given, a new one
will be created from the network.
symbolic_context : SymbolicContext | None
The context used for the symbolic conversion, as an
`biodivine_aeon.SymbolicContext` object. This is a mapping from the
network nodes to BDD variables that preserves variable ordering in BDDs.
If not given, a new one will be created from the network.
Returns
-------
Expand All @@ -305,8 +307,8 @@ def network_to_petrinet(
f"Parametrized networks are not supported. Found implicit parameters: {names}."
)

if ctx is None:
ctx = SymbolicContext(network)
if symbolic_context is None:
symbolic_context = SymbolicContext(network)

pn = DiGraph()

Expand All @@ -328,8 +330,8 @@ def network_to_petrinet(
assert len(network.predecessors(var)) == 0
continue

function_bdd = ctx.mk_update_function(update_function)
var_bdd = ctx.mk_network_variable(var)
function_bdd = symbolic_context.mk_update_function(update_function)
var_bdd = symbolic_context.mk_network_variable(var)

p_bdd = function_bdd.l_and(var_bdd.l_not())
n_bdd = function_bdd.l_not().l_and(var_bdd)
Expand All @@ -339,11 +341,16 @@ def network_to_petrinet(

# Add 0->1 edges.
_create_transitions(
pn, ctx.bdd_variable_set(), places, var_name, p_bdd, go_up=True
pn, symbolic_context.bdd_variable_set(), places, var_name, p_bdd, go_up=True
)
# Add 1-> 0 edges.
_create_transitions(
pn, ctx.bdd_variable_set(), places, var_name, n_bdd, go_up=False
pn,
symbolic_context.bdd_variable_set(),
places,
var_name,
n_bdd,
go_up=False,
)

return pn
Expand Down

1 comment on commit a8f82c3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
balm
   control.py1141488%102, 114, 120, 124, 129, 138–154, 472, 475, 488
   interaction_graph_utils.py30487%6–8, 145–146
   motif_avoidant.py148299%25, 171
   petri_net_translation.py1491193%22–26, 79, 136, 305–306, 330–331, 340, 449
   space_utils.py129497%25–27, 252, 278
   succession_diagram.py2571694%6, 184–189, 197, 257–258, 268, 274, 390, 580, 772, 810, 847
   symbolic_utils.py26388%10–12, 44
   trappist_core.py1833084%11–15, 52, 54, 89, 165, 212, 214, 216, 244–247, 251–253, 273–279, 337, 339, 369, 417, 419, 450, 502
balm/_sd_algorithms
   compute_attractor_seeds.py30197%8
   expand_attractor_seeds.py51590%6, 42, 97–102
   expand_bfs.py28196%6
   expand_dfs.py30197%6
   expand_minimal_spaces.py37295%6, 31
   expand_source_SCCs.py164696%19–21, 91, 101, 143, 287
   expand_to_target.py31390%6, 38, 43
TOTAL146810393% 

Tests Skipped Failures Errors Time
361 0 💤 0 ❌ 0 🔥 37.413s ⏱️

Please sign in to comment.