mpbn 4.1__py3-none-any.whl → 4.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mpbn/__init__.py CHANGED
@@ -74,7 +74,8 @@ def s2v(s):
74
74
  def v2s(v):
75
75
  return 1 if v > 0 else 0
76
76
 
77
- def is_dnf_unate(ba, f):
77
+
78
+ def is_dnf(ba, f, test_unate=False):
78
79
  pos_lits = set()
79
80
  neg_lits = set()
80
81
  def is_lit(f):
@@ -98,6 +99,8 @@ def is_dnf_unate(ba, f):
98
99
  return False
99
100
 
100
101
  def test_monotonicity():
102
+ if not test_unate:
103
+ return True
101
104
  both = pos_lits.intersection(neg_lits)
102
105
  return not both
103
106
 
@@ -112,6 +115,9 @@ def is_dnf_unate(ba, f):
112
115
  return test_monotonicity()
113
116
  return False
114
117
 
118
+ def is_dnf_unate(ba, f):
119
+ return is_dnf(ba, f, test_unate=True)
120
+
115
121
  def circuitasp_of_boolfunc(f, i, ba):
116
122
  atoms = []
117
123
  fid = clingo.String(i)
@@ -145,7 +151,7 @@ def circuitasp_of_boolfunc(f, i, ba):
145
151
  return "\n".join(atoms)
146
152
 
147
153
  DEFAULT_ENCODING = "mixed-dnf-bdd"
148
- DEFAULT_BOOLFUNCLIB = os.environ.get("MPBN_BOOLFUNCLIB", "aeon")
154
+ DEFAULT_BOOLFUNCLIB = os.environ.get("MPBN_BOOLFUNCLIB", "pyeda")
149
155
  SUPPORTED_BOOLFUNCLIBS = ["aeon", "pyeda"]
150
156
 
151
157
  class MPBooleanNetwork(minibn.BooleanNetwork):
@@ -215,7 +221,7 @@ class MPBooleanNetwork(minibn.BooleanNetwork):
215
221
  if isinstance(f, str):
216
222
  f = self.ba.parse(f)
217
223
  f = self._autobool(f)
218
- if self.auto_dnf:
224
+ if self.auto_dnf and (not is_dnf(self.ba, f) or self._simplify):
219
225
  f = self._bf_impl.make_dnf_boolfunc(self.ba, f,
220
226
  simplify=self._simplify,
221
227
  try_unate_hard=self.try_unate_hard)
mpbn/simulation.py CHANGED
@@ -188,7 +188,7 @@ def sample_reachable_attractor(f, mem, x, A, depth, W, refresh_rate=10, emit=Non
188
188
  I = set(f)
189
189
  n = len(f)
190
190
  def filter_reachable_attractors(A, x):
191
- H = spread(f, x, I, n)
191
+ H = spread(f, x, I, n)
192
192
  return [(ia,a) for (ia,a) in A if is_subhypercube(a, (x,H))]
193
193
  k = 1
194
194
  x = x.copy()
@@ -201,7 +201,7 @@ def sample_reachable_attractor(f, mem, x, A, depth, W, refresh_rate=10, emit=Non
201
201
  if k % refresh_rate == 0:
202
202
  A = filter_reachable_attractors(A, x)
203
203
  k += 1
204
- return A[0][0]
204
+ return None if (len(A)==0) else A[0][0]
205
205
 
206
206
  def sample_trace(f, mem, x, A, depth, W):
207
207
  if not isinstance(f, MPBNSim): f = MPBNSim(f)
@@ -257,6 +257,8 @@ def estimate_reachable_attractors_probabilities(f, x, A, nb_sims, depth, W):
257
257
  C = {ia: 0 for (ia,_) in A}
258
258
  for _ in tqdm(range(nb_sims)):
259
259
  ia = sample_reachable_attractor(f, mem, x, A, depth, W)
260
+ if (ia is None):
261
+ continue
260
262
  C[ia] += 1
261
263
  for ia, _ in A:
262
264
  C[ia] = (C[ia]*100) / nb_sims
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: mpbn
3
- Version: 4.1
3
+ Version: 4.3.1
4
4
  Summary: Simple implementation of Most Permissive Boolean networks
5
5
  Home-page: https://github.com/bnediction/mpbn
6
6
  Author: Loïc Paulevé
@@ -1,6 +1,6 @@
1
- mpbn/__init__.py,sha256=kbHB9JR5z2XP3FNaf2F06X9TaJM3PVVHzAsltT0_awg,22903
1
+ mpbn/__init__.py,sha256=u1DrXvl-d5zIPQEnWIQedO6JDURjmEg3YWU8a731zWo,23083
2
2
  mpbn/converters.py,sha256=6uCjxaJ2MI19_I1h0Pk9YN6PcDx42_C-Ml8ZRMA9uxg,416
3
- mpbn/simulation.py,sha256=3lk6yu7k2POrSytmtnsGIh596B-qcAgBtl16iZ0vzM4,10594
3
+ mpbn/simulation.py,sha256=DBtJbj1wyarHIbDcxLIuyWRNt2PRbiTjZxwB97cCAvE,10663
4
4
  mpbn/asplib/eval_circuit.asp,sha256=5rIbkVmvobaQwE_gHr0_USccPuI0QUPuzfw_1011hSE,989
5
5
  mpbn/asplib/eval_mixed.asp,sha256=n23pbjtxuWSCerL36Gb6O32bx8_1ukc52l1hQMMs8OE,787
6
6
  mpbn/asplib/mp_attractor.asp,sha256=CawLNxlYBZG2cl8XQAxA6EXEZ89Y9iw20CZ73n97Nu8,185
@@ -18,8 +18,8 @@ tests/test_fixpoints.py,sha256=bdDttzimiby48nVkVL-HXZ2rBldICBRbIZrVVbTGfso,786
18
18
  tests/test_input.py,sha256=mwMKd5UwAIY4Z1uZjYr09Ue8DLxD52CiPSoE-iXytfo,337
19
19
  tests/test_reachability.py,sha256=X7anTwFSIYcV2rltJBOW8TcAJnrt3SjYLqttB0eIL_Q,588
20
20
  tests/test_reachable_attractors.py,sha256=h78kvgmx9rTJWi3r2DZe_abYDxr02MLJ2iLDJUdLESY,540
21
- mpbn-4.1.dist-info/METADATA,sha256=9aJWcxNiK2cgjWBLpmTri09FhaoDlWLIGrd5qRRZEoE,2364
22
- mpbn-4.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
23
- mpbn-4.1.dist-info/entry_points.txt,sha256=CpzAc9SkB-mH_dojzt1N3YgDxy8hniDrIGzSHcPDo8g,68
24
- mpbn-4.1.dist-info/top_level.txt,sha256=oe3jlFHbQ6oIXyE1q7yAAnf1m49oP_jBPUU05d71n74,11
25
- mpbn-4.1.dist-info/RECORD,,
21
+ mpbn-4.3.1.dist-info/METADATA,sha256=z7C1Fvk5lLmvEwel3_R_jX3dNv_EQZTfcrXVGHJGJQw,2366
22
+ mpbn-4.3.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
23
+ mpbn-4.3.1.dist-info/entry_points.txt,sha256=CpzAc9SkB-mH_dojzt1N3YgDxy8hniDrIGzSHcPDo8g,68
24
+ mpbn-4.3.1.dist-info/top_level.txt,sha256=oe3jlFHbQ6oIXyE1q7yAAnf1m49oP_jBPUU05d71n74,11
25
+ mpbn-4.3.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5