How to prevent infeasible error with pulp and python?
<p>I have an optimization problem and I write a python program to solve it. I used Pulp with the CPLEX solver:</p>

<pre><code>import pulp

prob = LpProblem("myProblem", LpMinimize)
x = pulp.LpVariable.dicts("p", range( K ), 0, 1, pulp.LpContinuous)
prob += pulp.lpSum( x[k] for k in range( K ) )
...
# Rest of the constraints

status = prob.solve( pulp.CPLEX( msg = 0 ) )
</code></pre>

<p>I get the error:</p>

<pre><code>  File "C:\Anaconda\lib\site-packages\pulp\solvers.py", line 468, in readsol
    raise PulpSolverError, "Unknown status returned by CPLEX: "+statusString
pulp.solvers.PulpSolverError: Unknown status returned by CPLEX: infeasible
</code></pre>

<p>My question is : How can I test if the problem is infeasible or not? I want to prevent this event like if problem is infeasible then return 0.</p>

<p>I tried :</p>

<pre><code>if prob.status == 'infeasible':
    ...
</code></pre>

<p>and I tried </p>

<pre><code>if pulp.LpStatusInfeasible == 'infeasible':
    ...
</code></pre>