Pyomo / pyomo

An object-oriented algebraic modeling language in Python for structured optimization problems.
https://www.pyomo.org
Other
1.98k stars 507 forks source link

GDP Basic Steps - Error after Hull reformulation #843

Closed RomeoV closed 3 years ago

RomeoV commented 5 years ago

Summary

I implemented a complete GDP example using basic steps and solving via reformulation to MINLP.
After setting up the base model I can reformulate via BigM and CHull just fine. But after I apply a basic step between two disjunctions, the reformulation via CHull fails (see error below). BigM works just fine though.

How to reproduce

Check out the example file in the branch in my fork. In the method solve_basic_step_model(), change reformulation to use CHull instead of BigM and then run the example file.

Error log

[2] Solving basic step model
Traceback (most recent call last):
  File "basic_step.py", line 78, in <module>
    solve_basic_step_model()
  File "basic_step.py", line 60, in solve_basic_step_model
    m_bs_chull = TransformationFactory('gdp.chull').create_using(m_base)
  File "/home/romeo/Documents/CMU/Research/pyomo/pyomo/core/base/plugin.py", line 254, in create_using
    new_model = self._create_using(model, **kwds)
  File "/home/romeo/Documents/CMU/Research/pyomo/pyomo/core/base/plugin.py", line 274, in _create_using
    self._apply_to(instance, **kwds)
  File "/home/romeo/Documents/CMU/Research/pyomo/pyomo/gdp/plugins/chull.py", line 205, in _apply_to
    self._transformBlock(t, transBlock)
  File "/home/romeo/Documents/CMU/Research/pyomo/pyomo/gdp/plugins/chull.py", line 264, in _transformBlock
    self._transformBlockData(obj[i], transBlock)
  File "/home/romeo/Documents/CMU/Research/pyomo/pyomo/gdp/plugins/chull.py", line 275, in _transformBlockData
    self._transformDisjunction(disjunction, transBlock)
  File "/home/romeo/Documents/CMU/Research/pyomo/pyomo/gdp/plugins/chull.py", line 349, in _transformDisjunction
    self._transformDisjunctionData(obj[i], transBlock, i)
  File "/home/romeo/Documents/CMU/Research/pyomo/pyomo/gdp/plugins/chull.py", line 429, in _transformDisjunctionData
    localVars[disjunct])
  File "/home/romeo/Documents/CMU/Research/pyomo/pyomo/gdp/plugins/chull.py", line 589, in _transform_disjunct
    zero_substitute_map)
  File "/home/romeo/Documents/CMU/Research/pyomo/pyomo/gdp/plugins/chull.py", line 616, in _transform_block_components
    zero_substitute_map)
  File "/home/romeo/Documents/CMU/Research/pyomo/pyomo/gdp/plugins/chull.py", line 682, in _transform_block_on_disjunct
    block, disjunct, infodict, var_substitute_map, zero_substitute_map)
  File "/home/romeo/Documents/CMU/Research/pyomo/pyomo/gdp/plugins/chull.py", line 602, in _transform_block_components
    for name, obj in list(iteritems(block.component_map())):
AttributeError: 'IndexedBlock' object has no attribute 'component_map'
qtothec commented 5 years ago

In some part of the chull transformation, an IndexedBlock is being passed in where a _BlockData is expected. This'll probably take a couple hours of troubleshooting.

emma58 commented 3 years ago

I just tried this, and it works on main now. No idea what fixed it, unfortunately...