Pyomo / pyomo

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

Add support for PyNumero for discrete variables #1972

Open adowling2 opened 3 years ago

adowling2 commented 3 years ago

Summary

Degeneracy Hunter (https://github.com/IDAES/idaes-pse/blob/main/idaes/core/util/model_diagnostics.py) uses PyNumero to construct/analyze the Jacobian of an optimization problem. Passing an MINLP into PyNumero (via Degeneracy Hunter) triggers the following warnings and error messages:

WARNING | PyNumero does not support discrete variables

And then my Jupyter notebook/Python kernel crashes (on Colab).

Proposal: In PyNumero, relax the discrete variables to continuous, warn the user, and continue.

Rationale

Yes, PyNumero crashes when analyzing a Pyomo model with discrete variables.

Description

See above.

Quick work around: when constructing the MINLP model, manually relax the binary decisions as continuous bounded between 0 and 1. This is not super clean but is easy.

adowling2 commented 3 years ago

@jsiirola @Robbybp Any ideas on this? Is there a quick way to automatically relax all of the binary variables in a MI(N)LP? I can just add this relaxation into Degeneracy Hunter as a workaround.

jsiirola commented 3 years ago

You can use TransformationFactory('core.relax_integer_vars').

(Incidentally, you can use pyomo help -t to get the list of known transformations with (short) descriptions)