Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
franlucc committed Jul 13, 2023
2 parents 3dff597 + 63bd004 commit 8960bec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 62 deletions.
11 changes: 8 additions & 3 deletions benchmark/evaluator/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def run_simulation(program: str, state:dict,constraint: str, timeout:int, robot_
raise e


def evaluate_trace(completions_file, eval_file, asp_file="benchmark/evaluator/robot.lp", asp_timeout=20, debug_dir="debug", print_completions=False):
def evaluate_trace(completions_file, eval_file, asp_file="benchmark/evaluator/robot.lp", asp_timeout=20, debug_dir="debug", print_completions=False, test_filter=None):
completions = []

with open(Path(completions_file), 'r') as f:
Expand All @@ -93,9 +93,14 @@ def evaluate_trace(completions_file, eval_file, asp_file="benchmark/evaluator/ro
os.makedirs(debug_dir)

evaluated_completions = []

if test_filter is not None:
print("Filtering tests with regex: {}".format(test_filter))
for i, example_completion in enumerate(completions):
program = example_completion["completion"]
if test_filter is not None:
# Check if example_completion["name"] matches test_filter regex.
if not re.search(test_filter, example_completion["name"]):
continue
if print_completions:
print("\ncompletion {}:{}\n".format(i, program))
for num_state, test in enumerate(example_completion["tests"]):
Expand All @@ -112,7 +117,7 @@ def evaluate_trace(completions_file, eval_file, asp_file="benchmark/evaluator/ro

evaluated_ex["model"] = model
evaluated_ex["is_sat"] = (is_sat == "SAT")
print("completion {}, state {}: sat is {}".format(i, num_state, evaluated_ex["is_sat"]))
print("completion {}, task {}, state {}: sat is {}".format(i, example_completion["name"], num_state, evaluated_ex["is_sat"]))

# write result to file for debugging
open(f"{debug_dir}/gen{i}_state{num_state}.lp", "a").write(f"\n% IS SAT: "+str(evaluated_ex["is_sat"]))
Expand Down
Loading

0 comments on commit 8960bec

Please sign in to comment.