or-fusion / pao

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

Problem in solving the modified example model. #91

Open yhy0258 opened 1 year ago

yhy0258 commented 1 year ago

Hi, I copy the code of Simple Examples and modify the domain of the lower level variable to type integer. M.y = pe.Var(bounds=(0,None),within=pe.Integers) The whole code is provided as follows.

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

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

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

# Define the upper-level objective
M.o = pe.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 = pe.Objective(expr=M.y)

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

# Create a solver and apply it
with Solver('pao.pyomo.PCCG',mip_solver="cplex") as solver:
    results = solver.solve(M)

# The final solution is loaded into the model
print(M.x.value)
print(M.y.value)

Then an error returns RuntimeError: ERROR! ERROR! Master: Could not find optimal solution, however, a solution x=4, y=4 can be found when the domain of variables is set to real.

yhy0258 commented 1 year ago

This issue happens by using the solver PCCG with mip_solver Cplex, GLPK, and Gurobi.