Skip to content

intermittent linprog test failure #7877

@rgommers

Description

@rgommers

Made it fail less often in gh-7874, but running it in a loop still produces a failure sometimes. There's something in linprog or in the test case that's not reproducible.

__________________________________ TestLinprogIPSparse.test_bug_6690 ___________________________________

self = <scipy.optimize.tests.test_linprog.TestLinprogIPSparse object at 0x969b5a0c>

    def test_bug_6690(self):
        # https://github.com/scipy/scipy/issues/6690
        A_eq = np.array([[0., 0., 0., 0.93, 0., 0.65, 0., 0., 0.83, 0.]])
        b_eq = np.array([0.9626])
        A_ub = np.array([[0., 0., 0., 1.18, 0., 0., 0., -0.2, 0.,
                          -0.22],
                         [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                         [0., 0., 0., 0.43, 0., 0., 0., 0., 0., 0.],
                         [0., -1.22, -0.25, 0., 0., 0., -2.06, 0., 0.,
                          1.37],
                         [0., 0., 0., 0., 0., 0., 0., -0.25, 0., 0.]])
        b_ub = np.array([0.615, 0., 0.172, -0.869, -0.022])
        bounds = np.array(
            [[-0.84, -0.97, 0.34, 0.4, -0.33, -0.74, 0.47, 0.09, -1.45, -0.73],
             [0.37, 0.02, 2.86, 0.86, 1.18, 0.5, 1.76, 0.17, 0.32, -0.15]]).T
        c = np.array([-1.64, 0.7, 1.8, -1.06, -1.16,
                      0.26, 2.13, 1.53, 0.66, 0.28])
    
        with suppress_warnings() as sup:
            sup.filter(RuntimeWarning, "scipy.linalg.solve\nIll...")
            sup.filter(OptimizeWarning, "Solving system with option...")
            sol = linprog(c, A_ub=A_ub, b_ub=b_ub, A_eq=A_eq, b_eq=b_eq,
                          bounds=bounds, method=self.method,
                          options=self.options)
>       _assert_success(sol, desired_fun=-1.191, rtol=1e-6)

A_eq       = array([[ 0.  ,  0.  ,  0.  ,  0.93,  0.  ,  0.65,  0.  ,  0.  ,  0.83,  0.  ]])
A_ub       = array([[ 0.  ,  0.  ,  0.  ,  1.18,  0.  ,  0.  ,  0.  , -0.2 ,  0.  ,
       ...       [ 0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  , -0.25,  0.  ,  0.  ]])
b_eq       = array([ 0.9626])
b_ub       = array([ 0.615,  0.   ,  0.172, -0.869, -0.022])
bounds     = array([[-0.84,  0.37],
       [-0.97,  0.02],
       [ 0.34,  2.86],
       [ ...,  1.76],
       [ 0.09,  0.17],
       [-1.45,  0.32],
       [-0.73, -0.15]])
c          = array([-1.64,  0.7 ,  1.8 , -1.06, -1.16,  0.26,  2.13,  1.53,  0.66,  0.28])
self       = <scipy.optimize.tests.test_linprog.TestLinprogIPSparse object at 0x969b5a0c>
sol        =      con: array([ -3.39662796e-08])
     fun: -1.1887295500861423
 message: 'T...     ,
        0.49999936,  0.47024822,  0.09028211,  0.32000054, -0.72920656])
sup        = <numpy.testing.utils.suppress_warnings object at 0x969b858c>

../scipy/scipy/optimize/tests/test_linprog.py:690: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

res =      con: array([ -3.39662796e-08])
     fun: -1.1887295500861423
 message: 'T...     ,
        0.49999936,  0.47024822,  0.09028211,  0.32000054, -0.72920656])
desired_fun = -1.191, desired_x = None, rtol = 1e-06, atol = 1e-08

    def _assert_success(res, desired_fun=None, desired_x=None,
                        rtol=1e-8, atol=1e-8):
        # res: linprog result object
        # desired_fun: desired objective function value or None
        # desired_x: desired solution or None
>       assert_(res.success)
E       AssertionError

atol       = 1e-08
desired_fun = -1.191
desired_x  = None
res        =      con: array([ -3.39662796e-08])
     fun: -1.1887295500861423
 message: 'T...     ,
        0.49999936,  0.47024822,  0.09028211,  0.32000054, -0.72920656])
rtol       = 1e-06

../scipy/scipy/optimize/tests/test_linprog.py:118: AssertionError
============ 1 failed, 12559 passed, 1398 skipped, 124 xfailed, 8 xpassed in 818.10 seconds 

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.optimize

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions