Skip to content

Commit

Permalink
improved benchmarks generators
Browse files Browse the repository at this point in the history
  • Loading branch information
damianoazzolini committed Dec 2, 2024
1 parent 1d14766 commit 4bd56c5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
12 changes: 9 additions & 3 deletions benchmark/map/generate_graph_coloring_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,21 @@ def main():

for idx, l in enumerate(already_in):
if idx in selected_query_atoms:
prefix = "map "
if args.aspmc:
print(f"{prob_atoms[idx]}::edge({l[0]},{l[1]}).")
print(f"query(edge({l[0]},{l[1]})).")
else:
print(f"map {prob_atoms[idx]}::edge({l[0]},{l[1]}).")
else:
prefix = ""
print(f"{prob_atoms[idx]}::edge({l[0]},{l[1]}).")

print(f"{prefix}{prob_atoms[idx]}::edge({l[0]},{l[1]}).")

flat_list = [item for sublist in already_in for item in sublist]
for j in range(1, max(flat_list) + 1):
print(f"node({j}).")

if args.aspmc:
print("evidence(qr).")


if __name__ == "__main__":
Expand Down
9 changes: 8 additions & 1 deletion benchmark/map/generate_map_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,16 @@ def print_query_atoms(args : argparse.Namespace):

for idx, p in enumerate(prob_atoms):
if idx in selected_query_atoms:
print(f"map {p}::a{idx}.")
if args.aspmc:
print(f"{p}::a{idx}.")
print(f"query(a{idx}).")
else:
print(f"map {p}::a{idx}.")
else:
print(f"{p}::a{idx}.")

if args.aspmc:
print("evidence(qr).")

def generate_first_type_programs(args : argparse.Namespace):
"""
Expand Down
15 changes: 14 additions & 1 deletion benchmark/map/generate_reachability_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def parse_args():
type=float,
default=-1
)

command_parser.add_argument(
"--aspmc",
help="Generate aspmc version with shifted negation",
action="store_true"
)

command_parser.add_argument(
"--seed",
Expand Down Expand Up @@ -68,16 +74,23 @@ def print_query_atoms(args : argparse.Namespace):

for idx, p in enumerate(prob_atoms):
if idx in selected_query_atoms:
print(f"map {p}::node({idx}).")
if args.aspmc:
print(f"{p}::node({idx}).")
print(f"query(node({idx})).")
else:
print(f"map {p}::node({idx}).")
else:
print(f"{p}::node({idx}).")

if args.aspmc:
print("evidence(qr).")

def main():
"""
Main.
"""
args = parse_args()
print(f"% {args}")
random.seed(args.seed)

print("reaches(X,Y) :- edge(X,Y), node(X), node(Y).")
Expand Down
15 changes: 11 additions & 4 deletions benchmark/map/generate_smokers_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def main():
Main body.
"""
args = parse_args()
print(f"% {args}")
if args.n < 1:
print("n must be at least 2.")
sys.exit()
Expand All @@ -84,7 +85,7 @@ def main():

if args.aspmc:
print("smokes(X) :- asthma(X), \+ nsmokes(X).")
print("nsmokes(X) ; nsmoke(X) :- asthma(X), \+ smokes(X).")
print("nsmokes(X) :- asthma(X), \+ smokes(X).")
else:
print("smokes(X) ; nsmokes(X) :- asthma(X).")

Expand Down Expand Up @@ -113,14 +114,20 @@ def main():

for prob, f, idx in zip(prob_atoms,expanded_names,range(0,n_prob_f)):
if idx in selected_query_atoms:
prefix = "map "
if args.aspmc:
print(f"{prob}::{f}.")
print(f"query({f}).")
else:
print(f"map {prob}::{f}.")
else:
prefix = ""
print(f"{prob}::{f}.")

print(f"{prefix}{prob}::{f}.")

for i in range(1, args.n + 1):
print(f"qr:- smokes({i}).")

if args.aspmc:
print("evidence(qr).")

if __name__ == "__main__":
main()

0 comments on commit 4bd56c5

Please sign in to comment.