tum-ens / urbs

A linear optimisation model for distributed energy systems
GNU General Public License v3.0
184 stars 131 forks source link

Problem with supim_dict #223

Closed kbareiss closed 4 years ago

kbareiss commented 5 years ago

Problem with supim_dict while building model. multiple runs create not the same key error. Looking at Supim_dict.keys reaveal that some have ('site', 'commodity', 1) and some ('site', 'commodity', nan).

ERROR: Rule failed when generating expression for constraint def_intermittent_supply with index (3001, 'IE', 'Hydro plant', 'Hydro'): KeyError: ('IE', 'Hydro') ERROR: Constructing component 'def_intermittent_supply' from data=None failed: KeyError: ('IE', 'Hydro') Traceback (most recent call last): File "runme.py", line 265, in <module> report_sites_name=report_sites_name) File "runme.py", line 165, in run_scenario prob = urbs.create_model(data, dt, timesteps) File "C:\urbs\urbs\model.py", line 408, in create_model doc='process output = process capacity * supim timeseries') File "C:\Users\KBareiss\Anaconda3\lib\site-packages\pyomo\core\base\block.py", line 540, in __setattr__ self.add_component(name, val) File "C:\Users\KBareiss\Anaconda3\lib\site-packages\pyomo\core\base\block.py", line 980, in add_component val.construct(data) File "C:\Users\KBareiss\Anaconda3\lib\site-packages\pyomo\core\base\constraint.py", line 793, in construct ndx) File "C:\Users\KBareiss\Anaconda3\lib\site-packages\pyomo\core\base\misc.py", line 57, in apply_indexed_rule return rule(model, *index) File "C:\urbs\urbs\model.py", line 821, in def_intermittent_supply_rule if coin in m.com_supim: KeyError: ('IE', 'Hydro')

kbareiss commented 5 years ago

Issue under investigation. It seems like some character combinations force this issue. Will be back with the solution

kbareiss commented 5 years ago

I 'm back! :muscle:

an already existing timeseries in supim excel sheet expand the tuple supim_dict.keys() by a third entry. double entry reveals as they got a value for the third entry: ('site', 'commodity', 1). However only 2 arguments should exist: ('site', 'commodity'). A query in the code (def_intermittent_supply_rule()) should check for existing dataset with same arguments. At an error message would be helpful: "multiple entry for "site"! " if tuple def_intermittent_supply_rule() gets third argument.