0

I'm trying to optimize the following 2d linear program using cvxopt:

A = np.array([[1, 0],
              [1, 0],
              [0, -1],
              [0, 1],
              ], dtype=np.float)
b = np.array([2,
              4,
              1,
              1,
              ], dtype=np.float)
c = np.array([-1,0])

A = matrix(A)
b = matrix(b)
c = matrix(c)

sol = solvers.lp(c,A,b)
print sol

Essentially, it's a box with constraints on positive x, positive y, and negative y, with a redundant constraint on positive x and no constraint on negative x. The output I get is:

{'status': 'dual infeasible', 
 'dual slack': None, 
 'iterations': 5, 
 'residual as primal infeasibility certificate': None, 
 'relative gap': None, 
 'dual objective': None, 
 'residual as dual infeasibility certificate': 3.039926013128332e-09, 
 'gap': None, 's': <4x1 matrix, tc='d'>, 
 'primal infeasibility': None, 
 'dual infeasibility': None, 
 'primal objective': -1.0, 
 'primal slack': 5.32208560659015e-09, 
 'y': None, 
 'x': <2x1 matrix, tc='d'>, 
 'z': None}

The issue is that the LP is unbounded in the negative x direction, so the primal objective should be infinity. I'm not sure why cvxopt is returning -1.0 as the primal objective, at the equally confusing (-1.0, 0) optimal point.

Is there a way for cvxopt to tell me that the solution is infinity?

Nick Sweet
  • 2,030
  • 3
  • 31
  • 48
  • `dual infeasible` is the same as saying `primal unbounded` so the output is technically correct. Since the optimization status is **not a success**, you should not rely on the value being returned by CVXOPT as being incorrect and handle those cases as either being `-float('infinity')` or some other very large negative number, whichever makes your program behave correctly (TM). – musically_ut Aug 26 '15 at 18:43

1 Answers1

0

As @musically_ut mentioned, "dual infeasible is the same as saying primal unbounded". In my case, I was able to use this along with the optimal point output (-1.0, 0) to determine whether my objective was unbounded negatively or positively.

Nick Sweet
  • 2,030
  • 3
  • 31
  • 48