-
Notifications
You must be signed in to change notification settings - Fork 4
/
demo_usage.py
40 lines (35 loc) · 1.29 KB
/
demo_usage.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
import argparse
from algorithms.uec import OptimalEnergyFlowUsingUEC
from visualize.ies_plot import plot_optimal_responses
from visualize.ies_plot import plot_optimal_excitations
from visualize.ies_plot import plot_ies_excitations_and_responses
if __name__ == '__main__':
# do arguments parse
parser = argparse.ArgumentParser()
parser.add_argument(
"--instance_file", "-f",
type=str,
help="instance file in Excel format",
default="instance/small case/IES_E9H12G7-v1.xlsx"
)
parser.add_argument(
"--model_type", "-m",
type=str,
help="model type: implicit, explicit, and lazy_explicit",
default="lazy_explicit"
)
args = parser.parse_args()
# do information reading
ies = OptimalEnergyFlowUsingUEC(args.instance_file)
# do modeling and optimization
if args.model_type == "implicit":
ies.optimize_implicit_uec_model()
elif args.model_type == "explicit":
ies.optimize_explicit_uec_model()
elif args.model_type == "lazy_explicit":
ies.optimize_lazy_explicit_uec_model()
# do check and output
print(f"optimal operation cost is {ies.get_optimal_operation_cost():.2f}.")
plot_optimal_excitations(ies)
plot_optimal_responses(ies)
plot_ies_excitations_and_responses(ies)