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

Add strategies analysis script skeleton

- Add schedgen-strategies.py script
- Add to setup.py
- Add basic placeholder analysis function
- Add comment that discusses what we want
parent b8f983a4
No related tags found
No related merge requests found
#!/usr/bin/env python3
import argparse
from schedgen.parsers.gridtpt import GridTPT
from schedgen.parsers.csvresult import CSVResult
from schedgen.opt.helper import file_or_dir_path
import pandas as pd
args_parser = argparse.ArgumentParser(
description="Analyzes a set of strategies."
)
args_parser.add_argument(
"-l",
"--logics",
dest="logics",
metavar="L",
nargs="*",
default=["all"],
type=str,
help="The logics to analyze, comma separated, 'all' for all logics.",
)
args_parser.add_argument(
"-d",
"--data",
metavar="DIR",
required=True,
dest="data",
help="Location of experimental data. A folder if the GridTPT parser is selected, a CSV file if the CSV parser is selected.",
type=file_or_dir_path,
)
args_parser.add_argument(
"-c",
"--csv",
dest="csv",
action="store_true",
help="Use CSV instead of the GridTPT parser to read data.",
)
def clip_inf(max):
return lambda x: max if x == float("inf") else x
def calculate_strategy_statistics(series):
stats = {}
noinf = series.replace([float("inf")], float("nan"))
stats["Solved"] = noinf.notna().sum()
stats["Unsolved"] = noinf.isna().sum()
return pd.Series(stats)
if __name__ == "__main__":
args = args_parser.parse_args()
logics = args.logics
if not args.csv:
experiments = list(args.data.glob("**/*.txt"))
if "all" in logics:
filter = None
else:
filter = logics
if args.csv:
r = CSVResult(args.data, filter)
else:
r = GridTPT(args.data, filter)
exps = r.frame.copy()
# Rows are strategies, columns are benchmarks
exps = exps.T
strategy_stats = exps.apply(calculate_strategy_statistics, axis=1)
print(strategy_stats)
"""
What goes here:
- General stats
- Number of bencharks
- Unsolved benchmarks
- Aggregates of the strategies (min, max, avg)
- For strategies:
- Solved benchmarks
- Unsolved
- Paar 2 score
- min, max, avg, variety score
-> all of this goes into a dict for easy json output, but there
will also be text output.
Use:
"""
......@@ -37,6 +37,7 @@ setup(
"schedgen/schedgen-simulate.py",
"schedgen/schedgen-visualize.py",
"schedgen/schedgen-query.py"
"schedgen/schedgen-strategies.py",
],
license="BSD 3-Clause License",
classifiers=[
......
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