Pyomo / pyomo

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

Fix confusing error message in bilevel transform for nonlinear models #29

Closed ghackebeil closed 4 years ago

ghackebeil commented 8 years ago

This transform implicitly assumes it is given a linear model by treating the constraint canonical repn as a LinearCanonicalRepn object. This leads to a confusing error message when the model has nonlinear constraints.

whart222 commented 8 years ago

Do we have a simple example for this?

qtothec commented 7 years ago

I received a message from Mukesh Rungta of Air Liquide with the following toy example:

def pyomo_create_model(options, model_options):
    M = ConcreteModel()
    M.x = Var(bounds=(0,None))
    M.y = Var(bounds=(0,None))
    M.o = Objective(expr=M.x - 4*M.y)

    M.sub = SubModel(fixed=M.x)
    M.sub.o = Objective(expr=M.y*M.x)
    M.sub.c1 = Constraint(expr=-  M.x -   M.y <= -3)
    M.sub.c2 = Constraint(expr=-2*M.x +   M.y <=  0)
    M.sub.c3 = Constraint(expr= 2*M.x +   M.y <= 12)
    M.sub.c4 = Constraint(expr=-3*M.x + 2*M.y <= -4)

    return M

The error message from the MPEC transformation is:

AttributeError: 'GeneralCanonicalRepn' object has no attribute 'variables'
blnicho commented 4 years ago

pyomo.bilevel has been deprecated so closing this.