Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Bug with scipy.linprog feasibility? (A_ub @ x0 <= b_ub).all() is True —but— linprog(np.zeros_like(x0), A_ub=A_ub, b_ub=b_ub) infeasible

With numpy, scipy at versions

numpy 1.25.0
scipy 1.11.0

the following scipy.optimize.linprog call,

import numpy as np
from scipy.optimize import linprog

A_ub = np.array(
      [[-0.15729144,  0.29943807,  0.29311432],
       [-1.32475528, -2.1125364 , -1.55138585],
       [ 1.00861965,  0.53283629, -0.14939833],
       [ 1.07581479,  0.164022  , -1.19889684]])

b_ub = -np.ones(4)

print(linprog(np.zeros(3),
        A_ub=A_ub,
        b_ub=b_ub))

return unfeasible status,

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

       message: The problem is infeasible. (HiGHS Status 8: model_status is Infeasible; primal_status is At lower/fixed bound)
       success: False
        status: 2
           fun: None
             x: None
           nit: 0

But the problem is actually feasible, since

x0 = np.array([ 229.1748166 , -507.05266751,  512.14005547])
print('x0 is feasible?', (A_ub @ x0 <= b_ub).all())

returns True. Shouldn’t linprog returns a feasible point and a different status code and message in this case?

>Solution :

From the https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.linprog.html:

Note that by default lb = 0 and ub = None.

So x0 = np.array([ 229.1748166 , -507.05266751, 512.14005547]) is not feasible.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading