Skip to content

BUG: linprog, with highs is killed by the OOM killer when called with dense and large matrices #15888

@brunorigal

Description

@brunorigal

Describe your issue.

Hi,
I have a bug when using the highs linprog solver with the code below.

The script is killed by the OOM killer. The problem arises when calling csc_matrix, which itself builds a coo_matrix, which calls the nonzeros method which is supposed to return the indices of non zero (far too many in this dense case).

Is it necessary to call csc_matrix here? It seems very inefficient for dense matrices.
If such a transformation is necessary, it would be better that the code returns a python error to handle the problem correctly.

Reproducing Code Example

from scipy.optimize import linprog
import numpy as np
np.random.seed(0)
n_ctr = 500000
n_var = 500
c_ = np.ones(n_var)
A_ub = np.random.random((n_ctr, n_var))
b_ub = np.zeros((n_ctr, ))

res = linprog(c_, A_ub=A_ub, b_ub=b_ub, method='highs-ds', bounds=(0, None), options={'disp': True})

print('End')

Error message

150075 killed     python highs.py

SciPy/NumPy/Python version information

scipy==1.7.3, numpy==1.22.2, python==3.8.10

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions