or-fusion / pao

A Python Package for Adversarial Optimization
Other
17 stars 15 forks source link

WARNING: Empty constraint block written in LP format #96

Closed buddih09 closed 1 year ago

buddih09 commented 1 year ago

Hello,

Can you please look at this problem that I face with a bilevel problem? I reproduce it with an example problem found in the documentation.

import pyomo.environ as pyo
from pao.pyomo import *

# Create a model object
M = pyo.ConcreteModel()

# Define decision variables
M.x = pyo.Var(bounds=(0,None))
M.y = pyo.Var(bounds=(0,None))

# Define the upper-level objective
M.o = pyo.Objective(expr=M.x - 4*M.y)

# Create a SubModel component to declare a lower-level problem
# The variable M.x is fixed in this lower-level problem
M.L = SubModel(fixed=M.x)

# Define the lower-level objective
M.L.o = pyo.Objective(expr=M.y)

# Define lower-level constraints
M.L.c1 = pyo.Constraint(expr=   -M.x - M.y <= -3)
M.L.c2 = pyo.Constraint(expr= -2*M.x + M.y <=  0)
M.L.c3 = pyo.Constraint(expr=  2*M.x + M.y <= 12)
M.L.c4 = pyo.Constraint(expr=  3*M.x - 2*M.y <=  4)

pyo.SolverFactory('gurobi').solve(M)

The error that I get is:

WARNING: Empty constraint block written in LP format - solver may error
WARNING: Loading a SolverResults object with a warning status into
    model.name="unknown";
      - termination condition: infeasibleOrUnbounded
      - message from solver: Problem proven to be infeasible or unbounded.
buddih09 commented 1 year ago

The issue was related to the use of pyomo solver instead of pao solver.