openCEMorg / openCEM

Capacity Expansion Model and Optimiser for the Australian National Energy Market
GNU General Public License v3.0
18 stars 5 forks source link

Model has no attribute 'nem_disp_ratio' #20

Closed oliverstory closed 4 years ago

oliverstory commented 4 years ago

I'm getting an error when trying to run the provided scenario01 (first attempt at a model run after installing and getting the test suite to run) - see output below.

Any ideas?

Thanks Oliver

(opencem) ~/energy_modelling/openCEM
oliver@hakea$ ./msolve.py scenario01.cfg 
openCEM msolve.py: Runtime 0:00:00.002164 (pre solver)
ERROR: Rule failed when generating expression for constraint
    con_operating_reserve with index (1, '2019-07-01 00:00:00'):
    AttributeError: 'AbstractModel' object has no attribute 'nem_disp_ratio'
ERROR: Constructing component 'con_operating_reserve' from data=None failed:
        AttributeError: 'AbstractModel' object has no attribute
        'nem_disp_ratio'
Traceback (most recent call last):
  File "./msolve.py", line 93, in <module>
    X.solve()
  File "/home/oliver/energy_modelling/openCEM/cemo/multi.py", line 803, in solve
    inst = model.create_instance(year_template)
  File "/home/oliver/miniconda3/envs/opencem/lib/python3.7/site-packages/pyomo/core/base/PyomoModel.py", line 735, in create_instance
    profile_memory=profile_memory )
  File "/home/oliver/miniconda3/envs/opencem/lib/python3.7/site-packages/pyomo/core/base/PyomoModel.py", line 792, in load
    profile_memory=profile_memory)
  File "/home/oliver/miniconda3/envs/opencem/lib/python3.7/site-packages/pyomo/core/base/PyomoModel.py", line 856, in _load_model_data
    self._initialize_component(modeldata, namespaces, component_name, profile_memory)
  File "/home/oliver/miniconda3/envs/opencem/lib/python3.7/site-packages/pyomo/core/base/PyomoModel.py", line 910, in _initialize_component
    declaration.construct(data)
  File "/home/oliver/miniconda3/envs/opencem/lib/python3.7/site-packages/pyomo/core/base/constraint.py", line 779, in construct
    ndx)
  File "/home/oliver/miniconda3/envs/opencem/lib/python3.7/site-packages/pyomo/core/base/misc.py", line 57, in apply_indexed_rule
    return rule(model, *index)
  File "/home/oliver/energy_modelling/openCEM/cemo/rules.py", line 186, in con_operating_reserve
    >= model.nem_disp_ratio * model.region_net_demand[region, time]
  File "/home/oliver/miniconda3/envs/opencem/lib/python3.7/site-packages/pyomo/core/base/block.py", line 551, in __getattr__
    % (self.__class__.__name__, val))
AttributeError: 'AbstractModel' object has no attribute 'nem_disp_ratio'
jotaigna commented 4 years ago

This is a known issue and a fix will be pushed shortly. Thank you for raising it

jotaigna commented 4 years ago

The issue arises if the configuration file does not expliclity state nem_disp_ratio. Commit e65c293db620b98f0737ac309d85c410ccfa694b allows a default declaration of nem_disp_ratio if one is not specified.

jotaigna commented 4 years ago

Tested on Linux and Windows with scenario01.cfg and head.