forked from ntnuiotenergy/OpenEMPIRE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_run.py
126 lines (113 loc) · 5.12 KB
/
test_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
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
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python
from reader import generate_tab_files
from Empire import run_empire
from scenario_random import generate_random_scenario
from datetime import datetime
from yaml import safe_load
__author__ = "Stian Backe"
__license__ = "MIT"
__maintainer__ = "Stian Backe"
__email__ = "[email protected]"
UserRunTimeConfig= safe_load(open("config_testrun.yaml"))
USE_TEMP_DIR = UserRunTimeConfig["USE_TEMP_DIR"]
temp_dir = UserRunTimeConfig["temp_dir"]
version = UserRunTimeConfig["version"]
Horizon = UserRunTimeConfig["Horizon"]
NoOfScenarios = UserRunTimeConfig["NoOfScenarios"]
lengthRegSeason = UserRunTimeConfig["lengthRegSeason"]
discountrate = UserRunTimeConfig["discountrate"]
WACC = UserRunTimeConfig["WACC"]
solver = UserRunTimeConfig["solver"]
scenariogeneration = UserRunTimeConfig["scenariogeneration"]
fix_sample = UserRunTimeConfig["fix_sample"]
EMISSION_CAP = UserRunTimeConfig["EMISSION_CAP"]
IAMC_PRINT = UserRunTimeConfig["IAMC_PRINT"]
WRITE_LP = UserRunTimeConfig["WRITE_LP"]
PICKLE_INSTANCE = UserRunTimeConfig["PICKLE_INSTANCE"]
#############################
##Non configurable settings##
#############################
NoOfRegSeason = 2
lengthRegSeason = 24
regular_seasons = ["winter", "spring"] #, "summer", "fall"]
NoOfPeakSeason = 2
lengthPeakSeason = 24
LeapYearsInvestment = 5
time_format = "%d/%m/%Y %H:%M"
#######
##RUN##
#######
name = version + '_reg' + str(lengthRegSeason) + \
'_peak' + str(lengthPeakSeason) + \
'_sce' + str(NoOfScenarios)
if scenariogeneration and not fix_sample:
name = name + "_randomSGR"
else:
name = name + "_noSGR"
name = name + str(datetime.now().strftime("_%Y%m%d%H%M"))
workbook_path = 'Data handler/' + version
tab_file_path = 'Data handler/' + version + '/Tab_Files_' + name
scenario_data_path = 'Data handler/' + version + '/ScenarioData'
result_file_path = 'Results' + "\\" + name
FirstHoursOfRegSeason = [lengthRegSeason*i + 1 for i in range(NoOfRegSeason)]
FirstHoursOfPeakSeason = [lengthRegSeason*NoOfRegSeason + lengthPeakSeason*i + 1 for i in range(NoOfPeakSeason)]
Period = [i + 1 for i in range(int((Horizon-2020)/LeapYearsInvestment))]
Scenario = ["scenario"+str(i + 1) for i in range(NoOfScenarios)]
peak_seasons = ['peak'+str(i + 1) for i in range(NoOfPeakSeason)]
Season = regular_seasons + peak_seasons
Operationalhour = [i + 1 for i in range(FirstHoursOfPeakSeason[-1] + lengthPeakSeason - 1)]
HoursOfRegSeason = [(s,h) for s in regular_seasons for h in Operationalhour \
if h in list(range(regular_seasons.index(s)*lengthRegSeason+1,
regular_seasons.index(s)*lengthRegSeason+lengthRegSeason+1))]
HoursOfPeakSeason = [(s,h) for s in peak_seasons for h in Operationalhour \
if h in list(range(lengthRegSeason*len(regular_seasons)+ \
peak_seasons.index(s)*lengthPeakSeason+1,
lengthRegSeason*len(regular_seasons)+ \
peak_seasons.index(s)*lengthPeakSeason+ \
lengthPeakSeason+1))]
HoursOfSeason = HoursOfRegSeason + HoursOfPeakSeason
dict_countries = {"DE": "Germany", "DK": "Denmark", "FR": "France"}
print('++++++++')
print('+EMPIRE+')
print('++++++++')
print('Solver: ' + solver)
print('Scenario Generation: ' + str(scenariogeneration))
print('++++++++')
print('ID: ' + name)
print('++++++++')
if scenariogeneration:
generate_random_scenario(filepath = scenario_data_path,
tab_file_path = tab_file_path,
scenarios = NoOfScenarios,
seasons = regular_seasons,
Periods = len(Period),
regularSeasonHours = lengthRegSeason,
peakSeasonHours = lengthPeakSeason,
dict_countries = dict_countries,
time_format = time_format,
fix_sample = fix_sample)
generate_tab_files(filepath = workbook_path, tab_file_path = tab_file_path)
run_empire(name = name,
tab_file_path = tab_file_path,
result_file_path = result_file_path,
scenariogeneration = scenariogeneration,
scenario_data_path = scenario_data_path,
solver = solver,
temp_dir = temp_dir,
FirstHoursOfRegSeason = FirstHoursOfRegSeason,
FirstHoursOfPeakSeason = FirstHoursOfPeakSeason,
lengthRegSeason = lengthRegSeason,
lengthPeakSeason = lengthPeakSeason,
Period = Period,
Operationalhour = Operationalhour,
Scenario = Scenario,
Season = Season,
HoursOfSeason = HoursOfSeason,
discountrate = discountrate,
WACC = WACC,
LeapYearsInvestment = LeapYearsInvestment,
IAMC_PRINT = IAMC_PRINT,
WRITE_LP = WRITE_LP,
PICKLE_INSTANCE = PICKLE_INSTANCE,
EMISSION_CAP = EMISSION_CAP,
USE_TEMP_DIR = USE_TEMP_DIR)