22import shutil
33import urbs
44
5- input_files = 'single_year_example.xlsx' # for single year file name, for intertemporal folder name
6- input_dir = 'Input'
7- input_path = os .path .join (input_dir , input_files )
5+ def run ():
6+ input_files = 'single_year_example.xlsx' # for single year file name, for intertemporal folder name
7+ input_dir = 'Input'
8+ input_path = os .path .join (input_dir , input_files )
89
9- result_name = 'Run'
10- result_dir = urbs .prepare_result_directory (result_name ) # name + time stamp
10+ result_name = 'Run'
11+ result_dir = urbs .prepare_result_directory (result_name ) # name + time stamp
1112
12- # copy input file to result directory
13- try :
14- shutil .copytree (input_path , os .path .join (result_dir , input_dir ))
15- except NotADirectoryError :
16- shutil .copyfile (input_path , os .path .join (result_dir , input_files ))
17- # copy run file to result directory
18- shutil .copy (__file__ , result_dir )
13+ # copy input file to result directory
14+ try :
15+ shutil .copytree (input_path , os .path .join (result_dir , input_dir ))
16+ except NotADirectoryError :
17+ shutil .copyfile (input_path , os .path .join (result_dir , input_files ))
18+ # copy run file to result directory
19+ shutil .copy (__file__ , result_dir )
1920
20- # objective function
21- objective = 'cost' # set either 'cost' or 'CO2' as objective
21+ # objective function
22+ objective = 'cost' # set either 'cost' or 'CO2' as objective
2223
23- # Choose Solver (cplex, glpk, gurobi, ...)
24- solver = 'gurobi'
24+ # Choose Solver (cplex, glpk, gurobi, ...)
25+ solver = 'gurobi'
2526
26- # simulation timesteps
27- (offset , length ) = (0 , 8760 ) # time step selection
28- timesteps = range (offset , offset + length + 1 )
29- dt = 1 # length of each time step (unit: hours)
27+ # simulation timesteps
28+ (offset , length ) = (0 , 8760 ) # time step selection
29+ timesteps = range (offset , offset + length + 1 )
30+ dt = 1 # length of each time step (unit: hours)
3031
31- # detailed reporting commodity/sites
32- report_tuples = []
32+ # detailed reporting commodity/sites
33+ report_tuples = []
3334
34- # optional: define names for sites in report_tuples
35- report_sites_name = {}
35+ # optional: define names for sites in report_tuples
36+ report_sites_name = {}
3637
37- # plotting commodities/sites
38- plot_tuples = []
38+ # plotting commodities/sites
39+ plot_tuples = []
3940
40- # optional: define names for sites in plot_tuples
41- plot_sites_name = {}
41+ # optional: define names for sites in plot_tuples
42+ plot_sites_name = {}
4243
43- # plotting timesteps
44- plot_periods = {
45- 'all' : timesteps [1 :]
46- }
44+ # plotting timesteps
45+ plot_periods = {
46+ 'all' : timesteps [1 :]
47+ }
4748
48- # add or change plot colors
49- my_colors = {}
50- for country , color in my_colors .items ():
51- urbs .COLORS [country ] = color
49+ # add or change plot colors
50+ my_colors = {}
51+ for country , color in my_colors .items ():
52+ urbs .COLORS [country ] = color
5253
53- # select scenarios to be run
54- scenarios = [
55- urbs .scenario_base
56- ]
54+ # select scenarios to be run
55+ scenarios = [
56+ urbs .scenario_base
57+ ]
5758
58- for scenario in scenarios :
59- prob = urbs .run_scenario (input_path , solver , timesteps , scenario ,
60- result_dir , dt , objective ,
61- plot_tuples = plot_tuples ,
62- plot_sites_name = plot_sites_name ,
63- plot_periods = plot_periods ,
64- report_tuples = report_tuples ,
65- report_sites_name = report_sites_name )
59+ for scenario in scenarios :
60+ prob = urbs .run_scenario (input_path , solver , timesteps , scenario ,
61+ result_dir , dt , objective ,
62+ plot_tuples = plot_tuples ,
63+ plot_sites_name = plot_sites_name ,
64+ plot_periods = plot_periods ,
65+ report_tuples = report_tuples ,
66+ report_sites_name = report_sites_name )
67+
68+ if __name__ == "__main__" :
69+ run ()
0 commit comments