TexasEngineer
TexasEngineer

Reputation: 734

How to fix local infeasibility in IPOPT with Python Gekko?

I get a local infeasibility error in IPOPT (v3.12.10).

Converged to a point of local infeasibility. Problem may be infeasible.

I also tried it with the APOPT solver using m.options.SOLVER=1 and get a similar error.

No feasible solution

There are multiple feasible solutions to this problem with two equations and three variables. Solutions to this problem are where the plane intersects the sphere.

from gekko import GEKKO
m = GEKKO()
x=m.Var(); y=m.Var(); z=m.Var()
m.Equations([x**2+y**2+z**2==1,x+z==y])
m.options.SOLVER = 3 # APOPT=1, IPOPT=3
m.solve(debug=0) # debug=0 doesn't stop when unsuccessful
print('Solution 1')
print(x.value[0],y.value[0],z.value[0])

When I add an objective function to maximize z then IPOPT converges to a solution.

# add objective
m.Obj(-z) # maximize z
m.solve()
print('Solution 2')
print(x.value[0],y.value[0],z.value[0])

How can I avoid a failed solution without adding an objective function?

Upvotes: 1

Views: 4056

Answers (1)

John Hedengren
John Hedengren

Reputation: 14356

The starting point at x=0, y=0, and z=0 needs a different initial guess to converge to a solution.

x=m.Var(0.01); y=m.Var(); z=m.Var()

Because many solutions exist, a different solution will be obtained with different initial guess values. The objective function that you tried m.Obj(-z) improves convergence but also makes the solution unique.

All of the solution options in GEKKO are gradient-based nonlinear programming solvers and include APOPT, BPOPT, IPOPT, and others. All of these solvers produce solutions that are only guaranteed to be a local minimum or maximum. They all use the Karush-Kuhn-Tucker conditions to determine when an optimal solution is found. By starting at x=0, y=0, and z=0, the second KKT condition (No Feasible Descent) is satisfied but the first condition is not satisfied (Feasible Constraints). This leads to the error that you observed with the solver reporting a local infeasibility. The point is also called a stationary point where the function's derivative is zero.

Upvotes: 5

Related Questions