-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.py
More file actions
82 lines (66 loc) · 2.35 KB
/
run.py
File metadata and controls
82 lines (66 loc) · 2.35 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
"""
Main script to run the Handover Optimization Framework.
This script provides a unified command-line interface to:
- Train a PPO-based handover policy.
- Validate handover performance using a PPO policy.
- Benchmark using a standard 3GPP-compliant handover algorithm.
Usage:
python main.py <script>
Arguments:
script: One of 'train_ppo', 'validate_ppo', or 'validate_3gpp'.
"""
import argparse
import os
import sys
from scripts import plot_results, train_ppo, validate_3gpp, validate_ppo
THIS_PATH = os.path.dirname(os.path.abspath(__file__))
def run() -> int:
"""Run the Handover Optimization Framework."""
parser = argparse.ArgumentParser(
description="Handover Optimization Framework\n\n"
"Use this entry point to train and evaluate different handover strategies:\n"
" • 3GPP-standard handover\n"
" • PPO-based handover\n",
formatter_class=argparse.RawTextHelpFormatter,
)
subparsers = parser.add_subparsers(dest="command", help="\nAvailable commands:")
# plot_results
subparsers.add_parser(
"plot_results",
help="Plot the results shown in the paper.",
description="Runs the script that creates the same plots that are shown in the paper.",
)
# train_ppo
subparsers.add_parser(
"train_ppo",
help="Train a PPO policy for handover decisions",
description="Trains a PPO policy to make optimal handover decisions.",
)
# validate_3gpp
subparsers.add_parser(
"validate_3gpp",
help="Validate using 3GPP-compliant handover",
description="Runs the 3GPP-standard handover validation procedure.",
)
# validate_ppo
subparsers.add_parser(
"validate_ppo",
help="Validate using a trained PPO policy",
description="Runs validation using a pre-trained PPO handover policy.",
)
if len(sys.argv) == 1:
parser.print_help()
return 0
args = parser.parse_args()
if args.command == "plot_results":
return plot_results.main(THIS_PATH)
if args.command == "train_ppo":
return train_ppo.main(THIS_PATH)
if args.command == "validate_3gpp":
return validate_3gpp.main(THIS_PATH)
if args.command == "validate_ppo":
return validate_ppo.main(THIS_PATH)
parser.print_help()
return 1
if __name__ == "__main__":
sys.exit(run())