forked from tum-ens/urbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_intertemporal.py
109 lines (94 loc) · 3.27 KB
/
run_intertemporal.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
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
import os
import shutil
import urbs
input_files = 'Intertemporal_example' # for single year file name, for intertemporal folder name
input_dir = 'Input'
input_path = os.path.join(input_dir, input_files)
result_name = 'Intertemp'
result_dir = urbs.prepare_result_directory(result_name) # name + time stamp
# copy input file to result directory
try:
shutil.copytree(input_path, os.path.join(result_dir, input_dir))
except NotADirectoryError:
shutil.copyfile(input_path, os.path.join(result_dir, input_files))
# copy run file to result directory
shutil.copy(__file__, result_dir)
# objective function
objective = 'cost' # set either 'cost' or 'CO2' as objective
# Choose Solver (cplex, glpk, gurobi, ...)
solver = 'glpk'
# simulation timesteps
(offset, length) = (0, 8760) # time step selection
timesteps = range(offset, offset+length+1)
dt = 1 # length of each time step (unit: hours)
# detailed reporting commodity/sites
report_tuples = [
(2019, 'North', 'Elec'),
(2019, 'Mid', 'Elec'),
(2019, 'South', 'Elec'),
(2019, ['North', 'Mid', 'South'], 'Elec'),
(2024, 'North', 'Elec'),
(2024, 'Mid', 'Elec'),
(2024, 'South', 'Elec'),
(2024, ['North', 'Mid', 'South'], 'Elec'),
(2029, 'North', 'Elec'),
(2029, 'Mid', 'Elec'),
(2029, 'South', 'Elec'),
(2029, ['North', 'Mid', 'South'], 'Elec'),
(2034, 'North', 'Elec'),
(2034, 'Mid', 'Elec'),
(2034, 'South', 'Elec'),
(2034, ['North', 'Mid', 'South'], 'Elec'),
]
# optional: define names for sites in report_tuples
report_sites_name = {('North', 'Mid', 'South'): 'All'}
# plotting commodities/sites
plot_tuples = [
(2019, 'North', 'Elec'),
(2019, 'Mid', 'Elec'),
(2019, 'South', 'Elec'),
(2019, ['North', 'Mid', 'South'], 'Elec'),
(2024, 'North', 'Elec'),
(2024, 'Mid', 'Elec'),
(2024, 'South', 'Elec'),
(2024, ['North', 'Mid', 'South'], 'Elec'),
(2029, 'North', 'Elec'),
(2029, 'Mid', 'Elec'),
(2029, 'South', 'Elec'),
(2029, ['North', 'Mid', 'South'], 'Elec'),
(2034, 'North', 'Elec'),
(2034, 'Mid', 'Elec'),
(2034, 'South', 'Elec'),
(2034, ['North', 'Mid', 'South'], 'Elec'),
]
# optional: define names for sites in plot_tuples
plot_sites_name = {('North', 'Mid', 'South'): 'All'}
# plotting timesteps
plot_periods = {
'all': timesteps[1:]
}
# add or change plot colors
my_colors = {
'South': (230, 200, 200),
'Mid': (200, 230, 200),
'North': (200, 200, 230)}
for country, color in my_colors.items():
urbs.COLORS[country] = color
# select scenarios to be run
scenarios = [
urbs.scenario_base,
urbs.scenario_stock_prices,
urbs.scenario_co2_limit,
urbs.scenario_co2_tax_mid,
urbs.scenario_no_dsm,
urbs.scenario_north_process_caps,
urbs.scenario_all_together
]
for scenario in scenarios:
prob = urbs.run_scenario(input_path, solver, timesteps, scenario,
result_dir, dt, objective,
plot_tuples=plot_tuples,
plot_sites_name=plot_sites_name,
plot_periods=plot_periods,
report_tuples=report_tuples,
report_sites_name=report_sites_name)