Skip to content

Commit

Permalink
removed seconds from result directory and filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
ojdo committed Jun 23, 2015
1 parent 680bd5f commit e05634a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions runme.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def scenario_all_together(data):
def prepare_result_directory(result_name):
""" create a time stamped directory within the result folder """
# timestamp for result directory
now = datetime.now().strftime('%Y%m%dT%H%M%S')
now = datetime.now().strftime('%Y%m%dT%H%M')

# create result directory if not existent
result_dir = os.path.join('result', '{}-{}'.format(result_name, now))
Expand Down Expand Up @@ -98,7 +98,7 @@ def run_scenario(input_file, timesteps, scenario, result_dir, plot_periods={}):

# refresh time stamp string and create filename for logfile
now = prob.created
log_filename = os.path.join(result_dir, '{}-{}.log').format(sce, now)
log_filename = os.path.join(result_dir, '{}.log').format(sce)

# solve model and read results
optim = SolverFactory('glpk') # cplex, glpk, gurobi, ...
Expand All @@ -109,17 +109,17 @@ def run_scenario(input_file, timesteps, scenario, result_dir, plot_periods={}):
# write report to spreadsheet
urbs.report(
prob,
os.path.join(result_dir, '{}-{}.xlsx').format(sce, now),
os.path.join(result_dir, '{}.xlsx').format(sce),
prob.com_demand, prob.sit)

# store optimisation problem for later re-analysis
urbs.save(
prob,
os.path.join(result_dir, '{}-{}.pgz').format(sce, now))
os.path.join(result_dir, '{}.pgz').format(sce))

urbs.result_figures(
prob,
os.path.join(result_dir, '{}-{}'.format(sce,now)),
os.path.join(result_dir, '{}'.format(sce)),
plot_title_prefix=sce.replace('_', ' ').title(),
periods=plot_periods)
return prob
Expand Down Expand Up @@ -156,7 +156,6 @@ def run_scenario(input_file, timesteps, scenario, result_dir, plot_periods={}):
scenario_co2_limit,
scenario_north_process_caps,
scenario_all_together]
#scenarios = scenarios[:1] # select by slicing

for scenario in scenarios:
prob = run_scenario(input_file, timesteps, scenario,
Expand Down
6 changes: 3 additions & 3 deletions urbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def create_model(data, timesteps=None, dt=1):
"""
m = pyomo.ConcreteModel()
m.name = 'URBS'
m.created = datetime.now().strftime('%Y%m%dT%H%M%S')
m.created = datetime.now().strftime('%Y%m%dT%H%M')

# Optional
if not timesteps:
Expand Down Expand Up @@ -202,7 +202,7 @@ def create_model(data, timesteps=None, dt=1):
# tranmission (e.g. hvac, hvdc, pipeline...)
m.tra = pyomo.Set(
initialize=m.transmission.index.get_level_values('Transmission').unique(),
doc='Set of tranmission technologies')
doc='Set of transmission technologies')

# storage (e.g. hydrogen, pump storage)
m.sto = pyomo.Set(
Expand Down Expand Up @@ -369,7 +369,7 @@ def create_model(data, timesteps=None, dt=1):
doc='Energy content of storage (MWh) in timestep')

# Equation declarations
# equation bodies are defined in separate functions, refered to here by
# equation bodies are defined in separate functions, referred to here by
# their name in the "rule" keyword.

# commodity
Expand Down

0 comments on commit e05634a

Please sign in to comment.