-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from jcrozum/stubs
Lazy succession diagram
- Loading branch information
Showing
27 changed files
with
1,453 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Benchmarking | ||
|
||
This folder contains several scripts useful for benchmarking. | ||
All `bench_*` scripts solve one "benchmark problem" for a single given network file. | ||
The last line of output of such computation is always a comma-separated list of values with relevant results. | ||
You can then use `run_bench.py` to execute such benchmark script for all networks in a folder. | ||
This will collect the full output of each script, as well as create an agggregate result table. | ||
Each row of such table contains the network name, runtime of the whole script, and its output. | ||
|
||
## Install `nfvsmotifs` | ||
|
||
The benchmark scripts assume `nfvsmotifs` is installed as a package. | ||
To do this, go to the repository root and run `pip install .` | ||
(this step reqires at least `pip` version `23`). | ||
|
||
## Example | ||
|
||
For example, to test how long it takes to generate the succession diagram for minimal trap spaces, | ||
you can use the following: | ||
|
||
``` | ||
# 1h - timeout | ||
# ../bbm-bnet-inputs-true - folder with networks | ||
# bench_sd_expand_min.py - benchmark script | ||
python3 run_bench.py 1h ../bbm-bnet-inputs-true bench_sd_expand_min.py | ||
``` | ||
|
||
You can optionally add `-p X` or `-i` flag at the end of the argument list. | ||
The `-p` flag causes the benchmark to run in parallel in `X` processes. | ||
The `-i` flag causes the benchmark to run in "interactive" mode where the user can skip | ||
individual benchmarks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from biodivine_aeon import BooleanNetwork, SymbolicAsyncGraph, find_attractors | ||
import sys | ||
|
||
# This is a very basic script for running attractor detection usin AEON. | ||
# The results should be comparable to `bench_attractor_search`. | ||
# | ||
# The script only takes one argument: a path to the network file. | ||
|
||
bn = BooleanNetwork.from_file(sys.argv[1]) | ||
bn = bn.infer_regulatory_graph() | ||
|
||
stg = SymbolicAsyncGraph(bn) | ||
|
||
attr = find_attractors(stg) | ||
|
||
print("Attractors:", len(attr)) | ||
|
||
attr_states = stg.empty_colored_vertices() | ||
|
||
for a in attr: | ||
attr_states = attr_states.union(a) | ||
|
||
print("attractors, attractor-states") | ||
print(f"{len(attr)},{attr_states.cardinality()}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from biodivine_aeon import BooleanNetwork | ||
from nfvsmotifs.SuccessionDiagram import SuccessionDiagram | ||
import sys | ||
import nfvsmotifs | ||
|
||
# Print progress and succession diagram size. | ||
nfvsmotifs.SuccessionDiagram.DEBUG = True | ||
|
||
NODE_LIMIT = 1_000_000 | ||
DEPTH_LIMIT = 10_000 | ||
|
||
# This is unfortunately necessary for PyEDA Boolean expression parser (for now). | ||
sys.setrecursionlimit(150000) | ||
|
||
bn = BooleanNetwork.from_file(sys.argv[1]) | ||
bn = bn.infer_regulatory_graph() | ||
|
||
# Compute the succession diagram. | ||
sd = SuccessionDiagram(bn) | ||
fully_expanded = sd.expand_bfs(bfs_level_limit=DEPTH_LIMIT, size_limit=NODE_LIMIT) | ||
assert fully_expanded | ||
|
||
attractor_count = 0 | ||
motif_avoidant_count = 0 | ||
|
||
for node in sd.node_ids(): | ||
attr = sd.node_attractor_seeds(node, compute=True) | ||
attractor_count += len(attr) | ||
if not sd.node_is_minimal(node): | ||
motif_avoidant_count += len(attr) | ||
|
||
print("nodes, attractors, motif-avoidant") | ||
print(f"{len(sd)}, {attractor_count}, {motif_avoidant_count}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from biodivine_aeon import BooleanNetwork | ||
from nfvsmotifs.SuccessionDiagram import SuccessionDiagram | ||
import sys | ||
import nfvsmotifs | ||
|
||
# Print progress and succession diagram size. | ||
nfvsmotifs.SuccessionDiagram.DEBUG = True | ||
|
||
NODE_LIMIT = 1_000_000 | ||
|
||
# This is unfortunately necessary for PyEDA Boolean expression parser (for now). | ||
sys.setrecursionlimit(150000) | ||
|
||
bn = BooleanNetwork.from_file(sys.argv[1]) | ||
bn = bn.infer_regulatory_graph() | ||
|
||
# Compute the succession diagram. | ||
sd = SuccessionDiagram(bn) | ||
fully_expanded = sd.expand_minimal_spaces(size_limit=NODE_LIMIT) | ||
assert fully_expanded | ||
|
||
attractor_count = 0 | ||
motif_avoidant_count = 0 | ||
|
||
# Note that this can contain some motif-avoidant attractors | ||
# multiple times. But we haven't seen motif-avoidant attractors | ||
# in real-world networks so far... | ||
for node in sd.node_ids(): | ||
attr = sd.node_attractor_seeds(node, compute=True) | ||
attractor_count += len(attr) | ||
if not sd.node_is_minimal(node): | ||
motif_avoidant_count += len(attr) | ||
|
||
print("nodes, expanded, attractors, motif-avoidant") | ||
print(f"{len(sd)}, {len(list(sd.expanded_ids()))}, {attractor_count}, {motif_avoidant_count}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from biodivine_aeon import BooleanNetwork | ||
from nfvsmotifs.SuccessionDiagram import SuccessionDiagram | ||
import sys | ||
import nfvsmotifs | ||
|
||
# Print progress and succession diagram size. | ||
nfvsmotifs.SuccessionDiagram.DEBUG = True | ||
|
||
NODE_LIMIT = 1_000_000 | ||
|
||
# This is unfortunately necessary for PyEDA Boolean expression parser (for now). | ||
sys.setrecursionlimit(150000) | ||
|
||
bn = BooleanNetwork.from_file(sys.argv[1]) | ||
bn = bn.infer_regulatory_graph() | ||
|
||
# Compute the succession diagram. | ||
sd = SuccessionDiagram(bn) | ||
fully_expanded = sd.expand_attractor_seeds(size_limit=NODE_LIMIT) | ||
assert fully_expanded | ||
|
||
attractor_count = 0 | ||
motif_avoidant_count = 0 | ||
|
||
for node in sd.expanded_ids(): | ||
attr = sd.node_attractor_seeds(node, compute=True) | ||
attractor_count += len(attr) | ||
if not sd.node_is_minimal(node): | ||
motif_avoidant_count += len(attr) | ||
|
||
print("nodes, expanded, attractors, motif-avoidant") | ||
print(f"{len(sd)}, {len(list(sd.expanded_ids()))}, {attractor_count}, {motif_avoidant_count}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from biodivine_aeon import BooleanNetwork | ||
from nfvsmotifs.SuccessionDiagram import SuccessionDiagram | ||
import sys | ||
import nfvsmotifs | ||
|
||
# Print progress and succession diagram size. | ||
nfvsmotifs.SuccessionDiagram.DEBUG = True | ||
|
||
NODE_LIMIT = 1_000_000 | ||
DEPTH_LIMIT = 10_000 | ||
|
||
# This is unfortunately necessary for PyEDA Boolean expression parser (for now). | ||
sys.setrecursionlimit(150000) | ||
|
||
bn = BooleanNetwork.from_file(sys.argv[1]) | ||
bn = bn.infer_regulatory_graph() | ||
|
||
# Compute the succession diagram. | ||
sd = SuccessionDiagram(bn) | ||
fully_expanded = sd.expand_bfs(bfs_level_limit=DEPTH_LIMIT, size_limit=NODE_LIMIT) | ||
assert fully_expanded | ||
|
||
print(f"Succession diagram size:", len(sd)) | ||
print(f"Minimal traps:", len(sd.minimal_trap_spaces())) | ||
|
||
print("size, expanded, minimal") | ||
print(f"{len(sd)},{len(list(sd.expanded_ids()))},{len(sd.minimal_trap_spaces())}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from biodivine_aeon import BooleanNetwork | ||
from nfvsmotifs.SuccessionDiagram import SuccessionDiagram | ||
import sys | ||
import nfvsmotifs | ||
|
||
# Print progress and succession diagram size. | ||
nfvsmotifs.SuccessionDiagram.DEBUG = True | ||
|
||
NODE_LIMIT = 1_000_000 | ||
DEPTH_LIMIT = 10_000 | ||
|
||
# This is unfortunately necessary for PyEDA Boolean expression parser (for now). | ||
sys.setrecursionlimit(150000) | ||
|
||
bn = BooleanNetwork.from_file(sys.argv[1]) | ||
bn = bn.infer_regulatory_graph() | ||
|
||
# Compute the succession diagram. | ||
sd = SuccessionDiagram(bn) | ||
fully_expanded = sd.expand_dfs(dfs_stack_limit=DEPTH_LIMIT, size_limit=NODE_LIMIT) | ||
assert fully_expanded | ||
|
||
print(f"Succession diagram size:", len(sd)) | ||
print(f"Minimal traps:", len(sd.minimal_trap_spaces())) | ||
|
||
print("size, expanded, minimal") | ||
print(f"{len(sd)},{len(list(sd.expanded_ids()))},{len(sd.minimal_trap_spaces())}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from biodivine_aeon import BooleanNetwork | ||
from nfvsmotifs.trappist_core import trappist_async | ||
import sys | ||
|
||
# A simple script to benchmark minimal trap space detection using trappist. | ||
# The output should be comparable to the output of `bench_sd_construction.py` | ||
# in terms of minimal trap spaces. | ||
# | ||
# There is only one command line argument: a path to the network file. | ||
|
||
sys.setrecursionlimit(150000) | ||
|
||
bn = BooleanNetwork.from_file(sys.argv[1]) | ||
bn = bn.infer_regulatory_graph() | ||
|
||
COUNT = 0 | ||
|
||
def count_all(x): | ||
global COUNT | ||
COUNT += 1 | ||
return True | ||
|
||
trappist_async(bn, on_solution=count_all, problem="min") | ||
|
||
print("Minimal traps:", COUNT) | ||
|
||
print("traps") | ||
print(f"{COUNT}") |
Oops, something went wrong.
a810dc0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage Report