def solve(self, with_duals=False, tee=True, logfile=None, solver=None): logging.info("Optimising using {0}.".format(solver)) if with_duals: self.model.receive_duals() if self.debug: filename = os.path.join(helpers.extend_basic_path("lp_files"), "reegis.lp") logging.info("Store lp-file in {0}.".format(filename)) self.model.write(filename, io_options={"symbolic_solver_labels": True}) self.model.solve(solver=solver, solve_kwargs={ "tee": tee, "logfile": logfile }) self.es.results["main"] = processing.results(self.model) self.es.results["meta"] = processing.meta_results(self.model) self.es.results["param"] = processing.parameter_as_dict(self.es) self.es.results["meta"]["scenario"] = self.scenario_info(solver) self.es.results["meta"]["in_location"] = self.location self.es.results["meta"]["file_date"] = datetime.datetime.fromtimestamp( os.path.getmtime(self.location)) self.es.results["meta"]["oemof_version"] = logger.get_version() self.results = self.es.results["main"]
def run_oemof_sliced(es, index): print('run oemof simulation') om = solph.Model(es) om.solve(solver='cbc') es.results['main'] = processing.results(om) es.results['meta'] = processing.meta_results(om) es.dump(str(Path.cwd() / 'oemof_runs' / 'results_sliced'), f"dump_{index}.oemof") print('oemof done')
def run_oemof(es, output_filename='my_dump.oemof'): print('run oemof simulation') om = solph.Model(es) om.solve(solver='cbc') print('optimization done, processing results') es.results['main'] = processing.results(om) es.results['meta'] = processing.meta_results(om) es.dump(str(Path.cwd() / 'oemof_runs' / 'results'), output_filename) print('oemof done')
def write_results(es, m, p, **arguments): """Write results to CSV-files Parameters ---------- es : :class:`oemof.solph.network.EnergySystem` object Energy system holding nodes, grouping functions and other important information. m : A solved :class:'oemof.solph.models.Model' object for dispatch or investment optimization p: datapackage.Package instance of the input datapackage **arguments : key word arguments Arguments passed from command line """ # get the model name for processing and storing results from input dpkg modelname = p.descriptor['name'].replace(' ', '_') output_base_directory = os.path.join(arguments['--output-directory'], modelname) if not os.path.isdir(output_base_directory): os.makedirs(output_base_directory) meta_results = processing.meta_results(m) meta_results_path = os.path.join(output_base_directory, 'problem.csv') logging.info('Exporting solver information to {}'.format( os.path.abspath(meta_results_path))) pd.DataFrame({ 'objective': { modelname: meta_results['objective']}, 'solver_time': { modelname: meta_results['solver']['Time']}, 'constraints': { modelname: meta_results['problem']['Number of constraints']}, 'variables': { modelname: meta_results['problem']['Number of variables']}})\ .to_csv(meta_results_path) results = processing.results(m) _write_results = { 'default': default_results, 'component': component_results, 'bus': bus_results} \ [arguments['--output-orient']] logging.info('Exporting results to {}'.format( os.path.abspath(output_base_directory))) _write_results(es, results, path=output_base_directory, model=m) return True
p_max = 3000 eta = 0.95 storage = solph.components.GenericStorage( nominal_storage_capacity=4000, initial_storage_level=0.5, inflow_conversion_factor=eta, outflow_conversion_factor=eta, label='storage', inputs={b1: solph.Flow(nominal_value=p_max)}, outputs={b1: solph.Flow(nominal_value=p_max)}) es.add(storage) # solving om = solph.Model(es) logging.info('Build model') om.solve(solver='cbc') logging.info('Solved model') # debug equations should be used with 3 timesteps to have a readable file # om.write('./equations.lp', io_options={'symbolic_solver_labels': True}) es.results['main'] = processing.results(om) es.results['meta'] = processing.meta_results(om) es.dump('results', 'my_dump.oemof') plot_oemof_results(Path.cwd() / 'results', 'my_dump.oemof') plt.show()
om = solph.Model(energysystem) # if tee_switch is true solver messages will be displayed logging.info('Solve the optimization problem') om.solve(solver='cbc', solve_kwargs={'tee': True}) ########################################################################## # Check and plot the results ########################################################################## # check if the new result object is working for custom components results = processing.results(om) custom_storage = views.node(results, 'storage') electricity_bus = views.node(results, 'electricity') meta_results = processing.meta_results(om) pp.pprint(meta_results) my_results = electricity_bus['scalars'] # installed capacity of storage in GWh my_results['storage_invest_GWh'] = ( results[(storage, None)]['scalars']['invest'] / 1e6) # resulting renewable energy share my_results['res_share'] = (1 - results[(pp_gas, bel)]['sequences'].sum() / results[(bel, demand)]['sequences'].sum()) pp.pprint(my_results)
def test_optimise_storage_size(filename="storage_investment.csv", solver='cbc'): global PP_GAS logging.info('Initialize the energy system') date_time_index = pd.date_range('1/1/2012', periods=400, freq='H') energysystem = solph.EnergySystem(timeindex=date_time_index) Node.registry = energysystem full_filename = os.path.join(os.path.dirname(__file__), filename) data = pd.read_csv(full_filename, sep=",") # Buses bgas = solph.Bus(label="natural_gas") bel = solph.Bus(label="electricity") # Sinks solph.Sink(label='excess_bel', inputs={bel: solph.Flow()}) solph.Sink(label='demand', inputs={ bel: solph.Flow(actual_value=data['demand_el'], fixed=True, nominal_value=1) }) # Sources solph.Source(label='rgas', outputs={ bgas: solph.Flow(nominal_value=194397000 * 400 / 8760, summed_max=1) }) solph.Source(label='wind', outputs={ bel: solph.Flow(actual_value=data['wind'], nominal_value=1000000, fixed=True) }) solph.Source(label='pv', outputs={ bel: solph.Flow(actual_value=data['pv'], nominal_value=582000, fixed=True) }) # Transformer PP_GAS = solph.Transformer( label='pp_gas', inputs={bgas: solph.Flow()}, outputs={bel: solph.Flow(nominal_value=10e10, variable_costs=50)}, conversion_factors={bel: 0.58}) # Investment storage epc = economics.annuity(capex=1000, n=20, wacc=0.05) solph.components.GenericStorage( label='storage', inputs={bel: solph.Flow(variable_costs=10e10)}, outputs={bel: solph.Flow(variable_costs=10e10)}, loss_rate=0.00, initial_storage_level=0, invest_relation_input_capacity=1 / 6, invest_relation_output_capacity=1 / 6, inflow_conversion_factor=1, outflow_conversion_factor=0.8, investment=solph.Investment(ep_costs=epc, existing=6851), ) # Solve model om = solph.Model(energysystem) om.receive_duals() om.solve(solver=solver) energysystem.results['main'] = processing.results(om) energysystem.results['meta'] = processing.meta_results(om) # Check dump and restore energysystem.dump()
def rolling_horizon( PV, Storage, SH=8760, PH=120, CH=120, ): iter = 0 start = 0 stop = PH mode = 'simulation' initial_capacity = 0.5 path = 'results' filepath = '/diesel_pv_batt_PH120_P1_B1' components_list = [ 'demand', 'PV', 'storage', 'pp_oil_1', 'pp_oil_2', 'pp_oil_3', 'excess' ] results_list = [] economic_list = [] cost = main.get_cost_dict(PH) file = 'data/timeseries.csv' timeseries = pd.read_csv(file, sep=';') timeseries.set_index(pd.DatetimeIndex(timeseries['timestamp'], freq='H'), inplace=True) timeseries.drop(labels='timestamp', axis=1, inplace=True) timeseries[timeseries['PV'] > 1] = 1 itermax = int((SH / CH) - 1) objective = 0.0 while iter <= itermax: if iter == 0: status = True else: status = False feedin_RH = timeseries.iloc[start:stop] print(str(iter + 1) + '/' + str(itermax + 1)) m = main.create_optimization_model(mode, feedin_RH, initial_capacity, cost, PV, Storage, iterstatus=status)[0] results_el = main.solve_and_create_results(m) objective += processing.meta_results(m)['objective'] initial_capacity = views.node( results_el, 'storage')['sequences'][(('storage', 'None'), 'capacity')][CH - 1] start += CH stop += CH iter += 1 return objective
def test_tuples_as_labels_example(filename="storage_investment.csv", solver='cbc'): logging.info('Initialize the energy system') date_time_index = pd.date_range('1/1/2012', periods=40, freq='H') energysystem = solph.EnergySystem(timeindex=date_time_index) Node.registry = energysystem full_filename = os.path.join(os.path.dirname(__file__), filename) data = pd.read_csv(full_filename, sep=",") # Buses bgas = solph.Bus(label=Label('bus', 'natural_gas', None)) bel = solph.Bus(label=Label('bus', 'electricity', '')) # Sinks solph.Sink(label=Label('sink', 'electricity', 'excess'), inputs={bel: solph.Flow()}) solph.Sink(label=Label('sink', 'electricity', 'demand'), inputs={ bel: solph.Flow(actual_value=data['demand_el'], fixed=True, nominal_value=1) }) # Sources solph.Source(label=Label('source', 'natural_gas', 'commodity'), outputs={ bgas: solph.Flow(nominal_value=194397000 * 400 / 8760, summed_max=1) }) solph.Source(label=Label('renewable', 'electricity', 'wind'), outputs={ bel: solph.Flow(actual_value=data['wind'], nominal_value=1000000, fixed=True) }) solph.Source(label=Label('renewable', 'electricity', 'pv'), outputs={ bel: solph.Flow(actual_value=data['pv'], nominal_value=582000, fixed=True) }) # Transformer solph.Transformer( label=Label('pp', 'electricity', 'natural_gas'), inputs={bgas: solph.Flow()}, outputs={bel: solph.Flow(nominal_value=10e10, variable_costs=50)}, conversion_factors={bel: 0.58}) # Investment storage solph.components.GenericStorage( label=Label('storage', 'electricity', 'battery'), nominal_capacity=204685, inputs={bel: solph.Flow(variable_costs=10e10)}, outputs={bel: solph.Flow(variable_costs=10e10)}, capacity_loss=0.00, initial_capacity=0, invest_relation_input_capacity=1 / 6, invest_relation_output_capacity=1 / 6, inflow_conversion_factor=1, outflow_conversion_factor=0.8, ) # Solve model om = solph.Model(energysystem) om.solve(solver=solver) energysystem.results['main'] = processing.results(om) energysystem.results['meta'] = processing.meta_results(om) # Check dump and restore energysystem.dump() es = solph.EnergySystem() es.restore() # Results results = es.results['main'] meta = es.results['meta'] electricity_bus = views.node(results, 'bus_electricity_') my_results = electricity_bus['sequences'].sum(axis=0).to_dict() storage = es.groups['storage_electricity_battery'] storage_node = views.node(results, storage) my_results['max_load'] = storage_node['sequences'].max()[((storage, None), 'capacity')] commodity_bus = views.node(results, 'bus_natural_gas_None') gas_usage = commodity_bus['sequences'][(('source_natural_gas_commodity', 'bus_natural_gas_None'), 'flow')] my_results['gas_usage'] = gas_usage.sum() stor_invest_dict = { 'gas_usage': 1304112, 'max_load': 0, (('bus_electricity_', 'sink_electricity_demand'), 'flow'): 8239764, (('bus_electricity_', 'sink_electricity_excess'), 'flow'): 22036732, (('bus_electricity_', 'storage_electricity_battery'), 'flow'): 0, (('pp_electricity_natural_gas', 'bus_electricity_'), 'flow'): 756385, (('renewable_electricity_pv', 'bus_electricity_'), 'flow'): 744132, (('renewable_electricity_wind', 'bus_electricity_'), 'flow'): 28775978, (( 'storage_electricity_battery', 'bus_electricity_', ), 'flow'): 0 } for key in stor_invest_dict.keys(): eq_(int(round(my_results[key])), int(round(stor_invest_dict[key]))) # Solver results eq_(str(meta['solver']['Termination condition']), 'optimal') eq_(meta['solver']['Error rc'], 0) eq_(str(meta['solver']['Status']), 'ok') # Problem results eq_(int(meta['problem']['Lower bound']), 37819254) eq_(int(meta['problem']['Upper bound']), 37819254) eq_(meta['problem']['Number of variables'], 280) eq_(meta['problem']['Number of constraints'], 162) eq_(meta['problem']['Number of nonzeros'], 519) eq_(meta['problem']['Number of objectives'], 1) eq_(str(meta['problem']['Sense']), 'minimize') # Objective function eq_(round(meta['objective']), 37819254)
es.add(excess_el, demand_el, el_storage, th_storage, pv, shortage_el, elbus, thbus) # Create the model for optimization and run the optimization opt_model = Model(es) opt_model.solve(solver='cbc') logging.info('Optimization successful') # Collect and plot the results results = processing.results(opt_model) results_el = views.node(results, 'electricity') meta_results = processing.meta_results(opt_model) pp.pprint(meta_results) el_sequences = results_el['sequences'] to_el = { key[0][0]: key for key in el_sequences.keys() if key[0][1] == 'electricity' and key[1] == 'flow' } to_el = [to_el.pop('pv')] + list(to_el.values()) el_prod = el_sequences[to_el] fig, ax = plt.subplots(figsize=(14, 6)) el_prod.plot.area(ax=ax) el_sequences[(('electricity', 'demand_el'), 'flow')].plot(ax=ax,
def run_model_dessau(config_path, results_dir): r""" Create the energy system and run the optimisation model. Parameters ---------- config_path : Path to experiment config results_dir : Directory for results Returns ------- energysystem.results : Dict containing results """ abs_path = os.path.dirname(os.path.abspath(os.path.join(__file__, '..'))) with open(config_path, 'r') as ymlfile: cfg = yaml.load(ymlfile) # load input parameter in_param = pd.read_csv(os.path.join(abs_path, cfg['input_parameter']), index_col=[1, 2])['var_value'] wacc = in_param['general', 'wacc'] # load timeseries demand_heat_timeseries = pd.read_csv(os.path.join(results_dir, cfg['timeseries']['timeseries_demand_heat']), index_col=0, names=['demand_heat'], sep=',')['demand_heat'] print(demand_heat_timeseries.head()) # create timeindex if cfg['debug']: number_timesteps = 200 else: number_timesteps = 8760 date_time_index = pd.date_range('1/1/2017', periods=number_timesteps, freq='H') logging.info('Initialize the energy system') energysystem = solph.EnergySystem(timeindex=date_time_index) ##################################################################### logging.info('Create oemof objects') ##################################################################### bgas = solph.Bus(label="natural_gas", balanced=False) bel = solph.Bus(label="electricity", balanced=False) bth_prim = solph.Bus(label="heat_prim") bth_sec = solph.Bus(label="heat_sec") bth_end = solph.Bus(label="heat_end") energysystem.add(bgas, bth_prim, bth_sec, bth_end, bel) # energysystem.add(solph.Sink(label='excess_heat', # inputs={bth: solph.Flow()})) energysystem.add(solph.Source(label='shortage_heat', outputs={bth_prim: solph.Flow(variable_costs=in_param['shortage_heat','var_costs'])})) # energysystem.add(solph.Source(label='rgas', # outputs={bgas: solph.Flow( # variable_costs=0)})) if cfg['investment']['invest_chp']: energysystem.add(solph.Transformer( label='ccgt', inputs={bgas: solph.Flow(variable_costs=in_param['bgas','price_gas'])}, outputs={bth_prim: solph.Flow( investment=solph.Investment( ep_costs=economics.annuity( capex=in_param['ccgt','capex'], n=in_param['ccgt','inv_period'], wacc=wacc)), variable_costs=0)}, conversion_factors={bth_prim: 0.5})) else: energysystem.add(solph.Transformer( label='ccgt', inputs={bgas: solph.Flow(variable_costs=in_param['bgas','price_gas'])}, outputs={bth_prim: solph.Flow( nominal_value=in_param['ccgt','nominal_value'], variable_costs=0)}, conversion_factors={bth_prim: 0.5})) if cfg['investment']['invest_pth']: energysystem.add(solph.Transformer( label='power_to_heat', inputs={bel: solph.Flow(variable_costs=in_param['bel','price_el'])}, outputs={bth_prim: solph.Flow( investment=solph.Investment( ep_costs=economics.annuity( capex=in_param['power_to_heat','capex'], n=in_param['power_to_heat','inv_period'], wacc=wacc)), variable_costs=0)}, conversion_factors={bth_prim: 1})) else: energysystem.add(solph.Transformer(label='power_to_heat', inputs={bel: solph.Flow(variable_costs=in_param['bel','price_el'])}, outputs={bth_prim: solph.Flow( nominal_value=in_param['power_to_heat','nominal_value'], variable_costs=0)}, conversion_factors={bth_prim: 1})) energysystem.add(solph.Transformer( label='dhn_prim', inputs={bth_prim: solph.Flow()}, outputs={bth_sec: solph.Flow()}, conversion_factors={bth_sec: 1.})) energysystem.add(solph.Transformer( label='dhn_sec', inputs={bth_sec: solph.Flow()}, outputs={bth_end: solph.Flow()}, conversion_factors={bth_end: 1.})) energysystem.add(solph.Sink( label='demand_heat', inputs={bth_end: solph.Flow( actual_value=demand_heat_timeseries, fixed=True, nominal_value=1., summed_min=1)})) energysystem.add(solph.components.GenericStorage( label='storage_heat', nominal_capacity=in_param['storage_heat','nominal_capacity'], inputs={bth_prim: solph.Flow( variable_costs=0, nominal_value=in_param['storage_heat','input_nominal_value'])}, outputs={bth_prim: solph.Flow( nominal_value=in_param['storage_heat','output_nominal_value'])}, capacity_loss=in_param['storage_heat','capacity_loss'], initial_capacity=in_param['storage_heat','initial_capacity'], capacity_max=in_param['storage_heat','nominal_capacity'], inflow_conversion_factor=1, outflow_conversion_factor=1)) energysystem_graph = graph.create_nx_graph(energysystem) graph_file_name = os.path.join(results_dir, 'energysystem_graph.pkl') nx.readwrite.write_gpickle(G=energysystem_graph, path=graph_file_name) ##################################################################### logging.info('Solve the optimization problem') om = solph.Model(energysystem) om.solve(solver=cfg['solver'], solve_kwargs={'tee': True}) if cfg['debug']: filename = os.path.join( oemof.tools.helpers.extend_basic_path('lp_files'), 'app_district_heating.lp') logging.info('Store lp-file in {0}.'.format(filename)) om.write(filename, io_options={'symbolic_solver_labels': True}) ##################################################################### logging.info('Check the results') ##################################################################### energysystem.results['main'] = processing.results(om) energysystem.results['meta'] = processing.meta_results(om) energysystem.results['param'] = processing.parameter_as_dict(om) energysystem.dump(dpath=results_dir + '/optimisation_results', filename='es.dump') return energysystem.results
solph.components.GenericStorage(label='storage', inputs={bel: solph.Flow()}, outputs={bel: solph.Flow()}, nominal_capacity=129100, inflow_conversion_factor=1, outflow_conversion_factor=1)) ############END OF NETWORK##################################################### ####################Start of Optimization and data collecting ################ om = solph.Model(energysystem) om.solve(solver='cbc', solve_kwargs={'tee': True}) energysystem.results['main'] = processing.results(om) energysystem.results['meta'] = processing.meta_results(om) # energysystem.dump(dpath=None, filename=None) # define an alias for shorter calls below (optional) results = energysystem.results['main'] # define an alias for shorter calls below (optional) #results_capacity = energysystem.results['main'] electricity_bus = views.node(results, 'electricity') wind_off_bus = views.node(results, 'electricity_wind_off') pv_bus = views.node(results, 'electricity_pv') sourceX = views.node(results, 'rx') wind_on_hydprid = views.node(results, 'wind_on_hypride')
def rolling_horizon(PH, CH, SH=8760): iter = 0 start = 0 stop = PH mode = 'simulation' initial_capacity=0.5 path = 'results' filepath = '/diesel_pv_batt_PH120_P1_B1' components_list = ['demand', 'PV', 'storage', 'pp_oil_1', 'pp_oil_2', 'pp_oil_3', 'excess'] results_list = [] economic_list = [] cost = main.get_cost_dict( PH ) file = 'data/timeseries.csv' timeseries = pd.read_csv( file, sep=';' ) timeseries.set_index( pd.DatetimeIndex( timeseries['timestamp'], freq='H' ), inplace=True ) timeseries.drop( labels='timestamp', axis=1, inplace=True ) timeseries[timeseries['PV'] > 1] = 1 itermax = int( (SH / CH) - 1 ) time_measure = {} while iter <= itermax: if iter == 0: status = True else: status = False feedin_RH = timeseries.iloc[start:stop] print( str( iter + 1 ) + '/' + str( itermax + 1 ) ) m = main.diesel_only( mode, feedin_RH, initial_capacity, cost, iterstatus=status)[0] results_el = main.solve_and_create_results( m ) results_list.append( main.results_postprocessing( results_el, components_list, time_horizon=CH ) ) economic_list.append( lcoe.get_lcoe( m, results_el, components_list ) ) initial_capacity = views.node( results_el, 'storage' )['sequences'][(('storage', 'None'), 'capacity')][CH - 1] start += CH stop += CH iter += 1 res = pd.concat( results_list, axis=0 ) economics = pd.concat( economic_list, axis=0,keys=range(itermax+1) ) economics.to_csv(path+filepath+str(PH)+ '_lcoe.csv') res.to_csv( path + filepath + str( PH ) + '_.csv' ) meta_results = processing.meta_results( m ) with open( path + filepath + 'meta.txt', 'w' ) as file: file.write( str( meta_results ) )
def test_optimise_storage_size(filename="storage_investment.csv", solver='cbc'): logging.info('Initialize the energy system') date_time_index = pd.date_range('1/1/2012', periods=400, freq='H') energysystem = solph.EnergySystem(timeindex=date_time_index) Node.registry = energysystem full_filename = os.path.join(os.path.dirname(__file__), filename) data = pd.read_csv(full_filename, sep=",") # Buses bgas = solph.Bus(label="natural_gas") bel = solph.Bus(label="electricity") # Sinks solph.Sink(label='excess_bel', inputs={bel: solph.Flow()}) solph.Sink(label='demand', inputs={ bel: solph.Flow(actual_value=data['demand_el'], fixed=True, nominal_value=1) }) # Sources solph.Source(label='rgas', outputs={ bgas: solph.Flow(nominal_value=194397000 * 400 / 8760, summed_max=1) }) solph.Source(label='wind', outputs={ bel: solph.Flow(actual_value=data['wind'], nominal_value=1000000, fixed=True) }) solph.Source(label='pv', outputs={ bel: solph.Flow(actual_value=data['pv'], nominal_value=582000, fixed=True) }) # Transformer solph.Transformer( label="pp_gas", inputs={bgas: solph.Flow()}, outputs={bel: solph.Flow(nominal_value=10e10, variable_costs=50)}, conversion_factors={bel: 0.58}) # Investment storage epc = economics.annuity(capex=1000, n=20, wacc=0.05) solph.components.GenericStorage( label='storage', inputs={bel: solph.Flow(variable_costs=10e10)}, outputs={bel: solph.Flow(variable_costs=10e10)}, capacity_loss=0.00, initial_capacity=0, nominal_input_capacity_ratio=1 / 6, nominal_output_capacity_ratio=1 / 6, inflow_conversion_factor=1, outflow_conversion_factor=0.8, investment=solph.Investment(ep_costs=epc), ) # Solve model om = solph.Model(energysystem) om.solve(solver=solver) energysystem.results['main'] = processing.results(om) energysystem.results['meta'] = processing.meta_results(om) # Check dump and restore energysystem.dump() energysystem = solph.EnergySystem() energysystem.restore() # Results results = energysystem.results['main'] meta = energysystem.results['meta'] electricity_bus = views.node(results, 'electricity') my_results = electricity_bus['sequences'].sum(axis=0).to_dict() storage = energysystem.groups['storage'] my_results['storage_invest'] = results[(storage, None)]['scalars']['invest'] stor_invest_dict = { 'storage_invest': 2046851, (('electricity', 'demand'), 'flow'): 105867395, (('electricity', 'excess_bel'), 'flow'): 211771291, (('electricity', 'storage'), 'flow'): 2350931, (('pp_gas', 'electricity'), 'flow'): 5148414, (('pv', 'electricity'), 'flow'): 7488607, (('storage', 'electricity'), 'flow'): 1880745, (('wind', 'electricity'), 'flow'): 305471851 } for key in stor_invest_dict.keys(): eq_(int(round(my_results[key])), int(round(stor_invest_dict[key]))) # Solver results eq_(str(meta['solver']['Termination condition']), 'optimal') eq_(meta['solver']['Error rc'], 0) eq_(str(meta['solver']['Status']), 'ok') # Problem results eq_(meta['problem']['Lower bound'], 4.2316758e+17) eq_(meta['problem']['Upper bound'], 4.2316758e+17) eq_(meta['problem']['Number of variables'], 2804) eq_(meta['problem']['Number of constraints'], 2805) eq_(meta['problem']['Number of nonzeros'], 7606) eq_(meta['problem']['Number of objectives'], 1) eq_(str(meta['problem']['Sense']), 'minimize') # Objective function eq_(round(meta['objective']), 423167578261665280)
start = time.time() initial_capacity = 0.5 cost_dict = get_cost_dict( PH ) feed = get_timeseries() feed = feed.iloc[:PH] m = create_energysystem_model( sim_mode, feed, initial_capacity, cost_dict )[0] results = solve_and_create_results( m, gap=0.03 ) economic_results = lcoe.get_lcoe( m, results, components_list ).to_csv( path + filepath + 'lcoe.csv' ) results_flows = results_postprocessing( results, components_list, time_horizon=PH ) if sim_mode == 'investment': sizing_df = sizing_results( results, m, sizing_list ) sizing_df.to_csv( path + filepath + 'invest.csv' ) end = time.time() # stop time measure time_measure[PH] = end - start # return time required for the calculation print( time_measure[PH] ) #print time required results_flows.to_csv( path + filepath + str( PH ) + '.csv' ) # save results to .csv meta_results = processing.meta_results( m ) # save meta_results to .csv with open( path + filepath + 'meta.txt', 'w' ) as file: file.write( str( meta_results ) )