Skip to content
Snippets Groups Projects
Commit 6c6410f0 authored by Hans-Jörg's avatar Hans-Jörg
Browse files

Add support for calculating the PAR-2 score of a schedule

parent d2dd4984
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,13 @@ args_parser.add_argument(
type=float,
help="Total time available to the schedule in seconds.",
)
args_parser.add_argument(
"-s",
"--score",
dest="score",
action="store_true",
help="Print scores (such as PAR-2) instead of lists.",
)
args_parser.add_argument(
"-q",
"--query",
......@@ -71,6 +78,9 @@ if __name__ == "__main__":
args = args_parser.parse_args()
logics = args.logics
timeout = args.time
if args.score and timeout == float("inf"):
print("Error: calculating scores needs a finite timeout.")
exit(1)
if not args.csv:
experiments = list(args.data.glob("**/*.txt"))
......@@ -119,14 +129,32 @@ if __name__ == "__main__":
# help="Either: schedule, best, compare-best, compare-all.",
if args.query in ["all", "schedule"]:
if args.query == "all":
print("Benchmarks solved by the schedule:")
print(exps[sc].to_string())
if args.score:
if args.query == "all":
print("Schedule scores:")
print(f"Solves: {len(exps[sc].loc[exps[sc] <= timeout])}")
print(f"Solving time: {exps[sc].loc[exps[sc] <= timeout].sum():.2f}")
exps[sc].loc[exps[sc] > timeout] = 2 * timeout
print(f"PAR-2 score: {exps[sc].sum():.2f}")
exps[sc].loc[exps[sc] > timeout] = float("inf")
else:
if args.query == "all":
print("Benchmarks solved by the schedule:")
print(exps[sc].to_string())
if args.query in ["all", "best"]:
if args.query == "all":
print("\nBenchmarks solved by the theoretical best solver:")
print(solved_best.to_string())
if args.score:
if args.query == "all":
print("\nTheoretical best solver scores:")
print(f"Solves: {len(solved_best.loc[solved_best <= timeout])}")
print(f"Solving time: {solved_best.loc[solved_best <= timeout].sum():.2f}")
solved_best.loc[solved_best > timeout] = 2 * timeout
print(f"PAR-2 score: {solved_best.sum():.2f}")
solved_best.loc[solved_best > timeout] = float("inf")
else:
if args.query == "all":
print("\nBenchmarks solved by the theoretical best solver:")
print(solved_best.to_string())
if args.query in ["all", "unsolved"]:
if args.query == "all":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment