pyomo
pyomo copied to clipboard
MindtPy not working with pyomo.kernel.block
Summary
I am trying to create a model using the pyomo.kernel
part of the library, and wish to use the mindtpy
solver, however I'm coming into issues where it doesn't seem to be able to use the pyomo.kernel block. And just to note, it works fine using a pyomo.environ.ConcreteModel
.
Steps to reproduce the issue
import pyomo.kernel as pmo
# simple example
block = pmo.block()
block.x = pmo.variable()
block.obj = pmo.objective(block.x)
# trying to use the mindtpy solver
opt = pmo.SolverFactory("mindtpy")
opt.solve(block)
Error Message
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/alex/miniconda3/envs/samo/lib/python3.8/site-packages/pyomo/contrib/mindtpy/MindtPy.py", line 82, in solve
solve_data = setup_solve_data(model, config)
File "/home/alex/miniconda3/envs/samo/lib/python3.8/site-packages/pyomo/contrib/mindtpy/util.py", line 611, in setup_solve_data
solve_data.working_model.ipopt_zL_out = Suffix(
File "/home/alex/miniconda3/envs/samo/lib/python3.8/site-packages/pyomo/core/kernel/block.py", line 220, in __setattr__
if (obj.parent is None) or same_obj:
AttributeError: 'Suffix' object has no attribute 'parent'
Information on your system
Pyomo version: 6.2 Python version: 3.8 Operating system: ubuntu 20.04 How Pyomo was installed (PyPI, conda, source): conda Solver (if applicable): mindtpy
Hi Alex. Currently, MindtPy does not support pyomo.kernel
models. If you want to use MindtPy, you need to build your model in pyomo.environ
.
Hi Alex, complementing Zedong's comment, we want to highlight that fixing MindtPy's code to support pyomo.kernel
models would not be a minor update to the code. Since you are the first user that has ever raised the issue of wanting to use MindtPy with such models, we would like to know what applications did you have in mind.
In general, we know that the change is doable (it has to do with the way that kernel
uses suffixes, which we need to derive duals for the algorithm in MindtPy) but we do not have the manpower to make that change right now unless there is a big motivation for it.
On the other hand, we are always open to receiving pull requests in case you are interested in taking the matter on you own hands :)
Hi Both, thanks for getting back to me. To be honest I was just messing around with the different MINLP optimisers and noticed that it wasn't working, so thought I would raise the issue. I switched to pyomo.kernel
, because I wanted to use piecewise_nd
.
I've had a go at making MindtPy work with pyomo.kernel
, I'll make a PR if I get anywhere with it!