29
29
# knowledge of the CeCILL license and that you accept its terms.
30
30
#
31
31
32
+
33
+ from colomoto import minibn
34
+
35
+ import networkx as nx
36
+ from functools import reduce
37
+
32
38
import bonesis
33
39
40
+ def prune_domain_for_marker (f , M ):
41
+ def get_doi (g ):
42
+ return reduce (set .union , (nx .ancestors (g , m ) for m in M ), set (M ))
43
+ if isinstance (f , minibn .BooleanNetwork ):
44
+ keep = get_doi (f .influence_graph ())
45
+ return f .__class__ ({i : f [i ] for i in keep })
46
+ else :
47
+ return f .subgraph (get_doi (f ))
48
+
34
49
def marker_reprogramming_fixpoints (f , M , k , at_least_one = True , ** some_opts ):
35
50
bo = bonesis .BoNesis (f )
36
51
control = bo .Some (max_size = k , ** some_opts )
@@ -57,6 +72,7 @@ def trapspace_reprogramming(f, M, k, algorithm="cegar", **some_opts):
57
72
Returns mutations which ensure that all the minimal trap spaces match with
58
73
the given marker `M`.
59
74
"""
75
+ f = prune_domain_for_marker (f , M )
60
76
if algorithm == "cegar" :
61
77
meth = _trapspace_reprogramming_cegar
62
78
else :
@@ -75,6 +91,7 @@ def _trapspace_reprogramming_complementary(f, M, k, **some_opts):
75
91
return bad_control .complementary_assignments ()
76
92
77
93
def source_marker_reprogramming (f , z , M , k , ** some_opts ):
94
+ f = prune_domain_for_marker (f , M )
78
95
bo = bonesis .BoNesis (f )
79
96
bad_control = bo .Some (max_size = k , ** some_opts )
80
97
with bo .mutant (bad_control ):
0 commit comments