wouterbles / pyaugmecon

An AUGMECON based multi-objective optimization solver for Pyomo.
Other
24 stars 8 forks source link

KeyError: "Index '0' is not valid for indexed component 'e'" #1

Closed senniraf closed 1 year ago

senniraf commented 1 year ago

When i try to optimize my model, I get the following error:

  File "/home/raffael/development/relaxer/relaxer/optimization/augmecon.py", line 96, in optimize_relaxation
    A.solve()
  File "/home/raffael/.local/share/virtualenvs/relaxer-j_eeIk_e/lib/python3.9/site-packages/pyaugmecon/pyaugmecon.py", line 93, in solve
    self.model.convert_prob()
  File "/home/raffael/.local/share/virtualenvs/relaxer-j_eeIk_e/lib/python3.9/site-packages/pyaugmecon/model.py", line 155, in convert_prob
    self.model.e = Param(
  File "/home/raffael/.local/share/virtualenvs/relaxer-j_eeIk_e/lib/python3.9/site-packages/pyomo/core/base/block.py", line 649, in __setattr__
    self.add_component(name, val)
  File "/home/raffael/.local/share/virtualenvs/relaxer-j_eeIk_e/lib/python3.9/site-packages/pyomo/core/base/block.py", line 1219, in add_component
    val.construct(data)
  File "/home/raffael/.local/share/virtualenvs/relaxer-j_eeIk_e/lib/python3.9/site-packages/pyomo/core/base/param.py", line 755, in construct
    self._construct_from_rule_using_setitem()
  File "/home/raffael/.local/share/virtualenvs/relaxer-j_eeIk_e/lib/python3.9/site-packages/pyomo/core/base/indexed_component.py", line 704, in _construct_from_rule_using_setitem
    self[index] = rule(block, index)
  File "/home/raffael/.local/share/virtualenvs/relaxer-j_eeIk_e/lib/python3.9/site-packages/pyomo/core/base/indexed_component.py", line 607, in __setitem__
    index = self._validate_index(index)
  File "/home/raffael/.local/share/virtualenvs/relaxer-j_eeIk_e/lib/python3.9/site-packages/pyomo/core/base/indexed_component.py", line 788, in _validate_index
    raise KeyError(
KeyError: "Index '0' is not valid for indexed component 'e'"

The pyomo model and the logs are included in the zip-file.

wouterbles commented 1 year ago

Could you send me the Pyomo code for your problem?

senniraf commented 1 year ago

Thanks for the fast response. I fixed the issue. For some reason pipenv installed a wrong version of pyomo. I reinstalled the package and it works now :)