Repository navigation
Expand file tree
/
Copy pathrun_experiment_workflow.py
More file actions
117 lines (92 loc) · 3.57 KB
/
Copy pathrun_experiment_workflow.py
File metadata and controls
117 lines (92 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import argparse
from experiment_config import load_experiment_config
def _normalize_step(config_path: str):
from normalize_standard_traces import main as normalize_standard_traces_main
normalize_standard_traces_main(["--config", config_path])
def _wilcoxon_step(config_path: str):
from wilcoxon_statistical_analysis import main as wilcoxon_main
wilcoxon_main(["--config", config_path])
def _friedman_step(config_path: str):
from friedman_statistical_analysis import main as friedman_main
friedman_main(["--config", config_path])
STEP_ORDER = [
"normalize",
"unified-single",
"unified-hybrids",
"unified-merge",
"merge-hybridization",
"metrics-hybridization",
"metrics-standard",
"plot-metrics",
"wilcoxon",
"friedman",
"plot-genetic-crossing",
"plot-genetic-crossing-line",
]
def _step_handlers(config_path: str):
from compute_metrics_hybridization import compute_metrics_hybridization
from compute_metrics_standard import compute_metrics_standard
from compute_unified_PF import (
compute_hybrid_pareto_front,
compute_single_pareto_front,
merge_pareto_fronts,
)
from do_algorithms_plot_with_replicates import plot_metrics_time_series
from do_plot_genetical_crossing import plot_genetical_crossing
from do_plot_genetical_crossing_line import plot_genetical_crossing_line
from merge_hybridization_cases import merge_hybridization_cases
config = load_experiment_config(config_path)
return {
"normalize": lambda: _normalize_step(config_path),
"unified-single": lambda: compute_single_pareto_front(config),
"unified-hybrids": lambda: compute_hybrid_pareto_front(config),
"unified-merge": lambda: merge_pareto_fronts(config),
"merge-hybridization": lambda: merge_hybridization_cases(config),
"metrics-hybridization": lambda: compute_metrics_hybridization(config),
"metrics-standard": lambda: compute_metrics_standard(config),
"plot-metrics": lambda: plot_metrics_time_series(config),
"wilcoxon": lambda: _wilcoxon_step(config_path),
"friedman": lambda: _friedman_step(config_path),
"plot-genetic-crossing": lambda: plot_genetical_crossing(config),
"plot-genetic-crossing-line": lambda: plot_genetical_crossing_line(config),
}
def build_parser():
parser = argparse.ArgumentParser(description="Run the configured postprocessing workflow")
parser.add_argument(
"--config",
default="configs/config_NSGA2MOCPOMOEATS_codeA.ini",
help="Path to the experiment configuration INI file.",
)
parser.add_argument(
"--step",
action="append",
choices=STEP_ORDER,
help="Run only the selected step. Repeat the flag to run several steps.",
)
parser.add_argument(
"--all",
action="store_true",
help="Run the full postprocessing workflow.",
)
parser.add_argument(
"--list-steps",
action="store_true",
help="List the available workflow steps and exit.",
)
return parser
def main(argv=None):
parser = build_parser()
args = parser.parse_args(argv)
if args.list_steps:
for step in STEP_ORDER:
print(step)
return
if not args.all and not args.step:
parser.error("Use --all or at least one --step.")
selected_steps = STEP_ORDER if args.all else args.step
handlers = _step_handlers(args.config)
for step in selected_steps:
print(f"Running step: {step}")
handlers[step]()
if __name__ == "__main__":
main()