-
Notifications
You must be signed in to change notification settings - Fork 19
/
run.py
executable file
·63 lines (52 loc) · 2.28 KB
/
run.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
run.py: PREP-SHOT Entry Point
=============================
██████ ██████ ███████ ██████ ███████ █ █ █████ ███████
█ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █
██████ ██████ ███████ ██████ ███████ ███████ ███████ █ █ █
█ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █
█ █ █ ███████ █ ███████ █ █ █████ █
This script serves as the main entry point for the PREP-SHOT. It initializes
the model, loads the configuration data, parses command line arguments,
and starts the primary process.
Usage:
To run this script from the command line, use the following command:
$ python run.py --<param> <value>
or simply:
$ python run.py
or:
$ ./run.py
Author:
Zhanwei LIU <[email protected]>
Last Updated:
2024-07-11
"""
import os
from prepshot.set_up import initialize_environment
from prepshot.model import create_model
from prepshot.solver import solve_model
from prepshot.output_data import save_result
# Name of the configuration and parameters files located in the same directory
# as `run.py`.
CONFIG_FILENAME = 'config.json'
PARAMS_FILENAME = 'params.json'
def main():
"""Main function for the PREP-SHOT model.
"""
root_dir = os.path.dirname(os.path.abspath(__file__))
config_files = {
"filepath": root_dir,
"config_filename": os.path.join(root_dir, CONFIG_FILENAME),
"params_filename": os.path.join(root_dir, PARAMS_FILENAME),
}
parameters = initialize_environment(config_files)
model = create_model(parameters)
solved = solve_model(model, parameters)
if solved:
save_result(model)
if __name__ == "__main__":
main()