You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are cases when constraints are not satisfied in MINLP problems when using latest main (4a5bf8a), but the problem is reported as feasible and optimal after solve. The problem only occurs for some solvers that use NL Writer and with export_defined_variables=True.
The following example shows the problem, but only couenne gives the wrong answer. See #3235 for some more discussion of this. I have also seen the same issue for mindpty using ipopt and cbc, but for some reason this example works fine for mindtpy and I have not yet managed to replicate the mindtpy issue on a manageably small problem.
Steps to reproduce the issue
The following code replicates the problem
frompyomo.environimport*defcreate_model():
model=ConcreteModel()
model.p1=Var(within=PositiveReals, bounds=(1, 2))
model.p2=Var(within=PositiveReals, bounds=(1, 2))
model.t1=Var(within=Boolean, bounds=(0, 1))
model.t2=Var(within=Boolean, bounds=(0, 1))
model.f_expr=Expression(expr=
(model.p1*model.t1+model.p2*model.t2)
)
model.const_t=Constraint(expr=(model.t1+model.t2==1))
model.const2=Constraint(expr=(model.f_expr<=1.0))
# just maximize the the expression we are constraining to <= 1model.OBJ=Objective(expr=model.f_expr, sense=maximize)
returnmodeldefsolve(solver, export_defined_variables):
model=create_model()
opt=SolverFactory(solver)
try:
name=opt.namesol=opt.options.solverexceptAttributeError:
name=opt.__class__.__name__sol=""try:
ifsolver=="mindtpy":
ifnotexport_defined_variables:
# not sure how to switch this off for mindtpyreturnoptResult=opt.solve(model, mip_solver="cbc")
else:
optResult=opt.solve(model, export_defined_variables=export_defined_variables)
solverOutput=optResult["Solver"][0]
termCond=solverOutput["Termination condition"]
iftermCond!="optimal":
raiseException(f"Termination condition: {termCond}")
exceptExceptionase:
print(f"{name}:{sol}:export_defined_variables:{export_defined_variables}{e}")
returnprint(f"{name}:{sol}:export_defined_variables:{export_defined_variables}{value(model.OBJ)}")
forexport_defined_variablesin [False, True]:
forsolverin ["ipopt", "scip", "bonmin", "couenne", "mindtpy"]:
solve(solver, export_defined_variables)
Pyomo version: main (4a5bf8a)
Python version: 3.11.6
Operating system: Red Hat Enterprise Linux release 8.8 (Ootpa)
How Pyomo was installed (PyPI, conda, source): PyPI
Solver (if applicable): see above, all solvers were downloaded from the AMPL Portal (https://portal.ampl.com/user/ampl/download)
The text was updated successfully, but these errors were encountered:
Summary
There are cases when constraints are not satisfied in MINLP problems when using latest main (4a5bf8a), but the problem is reported as feasible and optimal after solve. The problem only occurs for some solvers that use NL Writer and with
export_defined_variables=True
.The following example shows the problem, but only
couenne
gives the wrong answer. See #3235 for some more discussion of this. I have also seen the same issue formindpty
usingipopt
andcbc
, but for some reason this example works fine formindtpy
and I have not yet managed to replicate themindtpy
issue on a manageably small problem.Steps to reproduce the issue
The following code replicates the problem
Output:
Information on your system
Pyomo version: main (4a5bf8a)
Python version: 3.11.6
Operating system: Red Hat Enterprise Linux release 8.8 (Ootpa)
How Pyomo was installed (PyPI, conda, source): PyPI
Solver (if applicable): see above, all solvers were downloaded from the AMPL Portal (https://portal.ampl.com/user/ampl/download)
The text was updated successfully, but these errors were encountered: