I ran a simple problem: Objective is Max exp(x[0]+x[1]) Constraints are x[0]+x[1]>=5, 0<=x[0]<=2, 0 <=x[1]<=2. x[0] and x[1] are integers. It is supposed to be infeasible because x[0]+x[1] <=4. But the solver.status =ok and solver.termination_condition = feasible. variables x[0], x[1] and objective contain None. Attached below is Python code
import pandas as pd
import numpy as np
import pyomo.environ as pe
from pyomo.opt import SolverStatus, TerminationCondition
model = pe.ConcreteModel(name="Pyomo Test Optimization")
model.x = pe.Var( [0, 1], within=pe.NonNegativeIntegers, bounds= (0, 2) )
model.objective = pe.Objective(expr=pe.exp(model.x[0] +model.x[1]), sense= pe.maximize)
model.Constraint_Budget_lb= pe.Constraint(expr= model.x[0]+model.x[1] >= 5 )
model.pprint()
results=pe.SolverFactory('mindtpy').solve(model)
print()
print("Results=", results)
status= results.solver.termination_condition
print("############################## Status ############################")
print()
print( "results.solver.status =", results.solver.status)
print("results.solver.termination_condition =", results.solver.termination_condition )
print("SolverStatus.warning =", SolverStatus.warning)
print()
print("Solution:")
print()
print( "pe.value(model.objective)=", pe.value(model.objective) )
print( "Decision variable x =", [model.x[0].value, model.x[1].value ] )
print("################################################################")
Output is shown below
1 Set Declarations
x_index : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 2 : {0, 1}
1 Var Declarations
x : Size=2, Index=x_index
Key : Lower : Value : Upper : Fixed : Stale : Domain
0 : 0 : None : 2 : False : True : NonNegativeIntegers
1 : 0 : None : 2 : False : True : NonNegativeIntegers
1 Objective Declarations
objective : Size=1, Index=None, Active=True
Key : Active : Sense : Expression
None : True : maximize : exp(x[0] + x[1])
1 Constraint Declarations
Constraint_Budget_lb : Size=1, Index=None, Active=True
Key : Lower : Body : Upper : Active
None : 5.0 : x[0] + x[1] : +Inf : True
4 Declarations: x_index x objective Constraint_Budget_lb
---------------------------------------------------------------------------------------------
Mixed-Integer Nonlinear Decomposition Toolbox in Pyomo (MindtPy)
---------------------------------------------------------------------------------------------
For more information, please visit https://pyomo.readthedocs.io/en/stable/contributed_packages/mindtpy.html
Original model has 1 constraints (0 nonlinear) and 0 disjunctions, with 2 variables, of which 0 are binary, 2 are integer, and 0 are continuous.
Objective is nonlinear. Moving it to constraint set.
rNLP is the initial strategy being used.
===============================================================================================
Iteration | Subproblem Type | Objective Value | Primal Bound | Dual Bound | Gap | Time(s)
Initial relaxed NLP problem is infeasible. Problem may be infeasible.
MILP main problem is infeasible. Problem may have no more feasible binary configurations.
MindtPy initialization may have generated poor quality cuts.
MindtPy exiting due to MILP main problem infeasibility.
===============================================================================================
Primal integral : nan
Dual integral : nan
Primal-dual gap integral : nan
Results=
Problem:
- Name: Pyomo Test Optimization
Lower bound: -inf
Upper bound: inf
Number of objectives: 1
Number of constraints: 1
Number of variables: 2
Number of binary variables: 0
Number of integer variables: 2
Number of continuous variables: 0
Number of nonzeros: None
Sense: maximize
Number of disjunctions: 0
Solver:
- Name: MindtPyOA
Status: ok
Message: None
User time: None
System time: None
Wallclock time: None
Termination condition: feasible
Termination message: None
Timing: initialization: 0.050159021047875285
main loop: 0.024332273053005338
main: 0.02267576800659299
main_timer_start_time: 771443.781539982
total: 0.08562357001937926
Iterations: 1
Num infeasible nlp subproblem: 0
Best solution found time: None
Primal integral: nan
Dual integral: nan
Primal dual gap integral: nan
############################## Status ############################
results.solver.status = ok
results.solver.termination_condition = feasible
SolverStatus.warning = warning
Solution:
ERROR: evaluating object as numeric value: x[0]
(object: <class 'pyomo.core.base.var._GeneralVarData'>)
No value for uninitialized NumericValue object x[0]
ERROR: evaluating object as numeric value: objective
(object: <class 'pyomo.core.base.objective.ScalarObjective'>)
No value for uninitialized NumericValue object x[0]
Can you please help me why results.solver.termination_condition = feasible while the solver identified "MindtPy exiting due to MILP main problem infeasibility"?
I tried to change model.x[0]+model.x[1] >= 5 to model.x[0]+model.x[1] >= 4. It was able to find optimal solution. So the question is the wrong flags for results.solver.status and results.solver.termination_condition.