Skip to content

Commit

Permalink
Fix a bug in ADF encoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Oct 21, 2024
1 parent 40b1482 commit df29766
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions example/script/bn_to_adf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
bn = BooleanNetwork.from_file(sys.argv[1])

for var in bn.variables():
print(f"s({int(var) + 1})")
print(f"s({int(var) + 1}).")

def convert_function(function):
if function.is_const():
Expand All @@ -28,24 +28,24 @@ def convert_function(function):
raise Error("Parameters not supported.")
if function.is_not():
inner = function.as_not()
return f"not({convert_function(inner)})"
return f"neg({convert_function(inner)})"
if function.is_and():
(a, b) = function.as_and()
return f"and({convert_function(a)},{convert_function(b)})"
return f"and({convert_function(a)}, {convert_function(b)})"
if function.is_or():
(a, b) = function.as_or()
return f"or({convert_function(a)},{convert_function(b)})"
return f"or({convert_function(a)}, {convert_function(b)})"
if function.is_xor():
(a, b) = function.as_xor()
return f"xor({convert_function(a)},{convert_function(b)})"
return f"xor({convert_function(a)}, {convert_function(b)})"
if function.is_imp():
(a, b) = function.as_imp()
return f"imp({convert_function(a)},{convert_function(b)})"
return f"imp({convert_function(a)}, {convert_function(b)})"
if function.is_iff():
(a, b) = function.as_iff()
return f"iff({convert_function(a)},{convert_function(b)})"
return f"iff({convert_function(a)}, {convert_function(b)})"


for var in bn.variables():
function = bn.get_update_function(var)
print(f"ac({int(var) + 1}, {convert_function(function)})")
print(f"ac({int(var) + 1}, {convert_function(function)}).")

0 comments on commit df29766

Please sign in to comment.