-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Labels
defectA clear bug or issue that prevents SciPy from being installed or used as expectedA clear bug or issue that prevents SciPy from being installed or used as expected
Description
Describe your issue.
Why doesn't scipy.optimize.milp give any errors and simply say an optimal solution was found even if one of the bounds was violated?
Reproducing Code Example
import numpy as np
import scipy
integrality = np.array([1] * 5 + [0])
c = np.array([0.0] * 5 + [-1.0])
scipy_bounds = scipy.optimize.Bounds(
lb=np.zeros(6, dtype=float), ub=np.array([3.0] * 4 + [2.0, 1.0], dtype=float)
)
scipy_constraints = [
scipy.optimize.LinearConstraint(A=[3.0, 2.0, 2.0, -2.0, 0.0, 1.0], ub=0.0),
scipy.optimize.LinearConstraint(A=[-3.0, -2.0, -4.0, 2.0, 0.0, 1.0], ub=0.0),
scipy.optimize.LinearConstraint(A=[1.0, 1.0, 1.0, 1.0, -1.0, 0.0], lb=1.0, ub=1.0),
]
result = scipy.optimize.milp(
c=c, integrality=integrality, bounds=scipy_bounds, constraints=scipy_constraints
)
print(result.x)The code above yields [0, 0, 0, 0, -1, 0], which violates the bounds, but it does not raise any errors.
Preferably, the optimization should yield at least one feasible solution, so if you know any good options for it, please let me know 🙏
SciPy/NumPy/Python version and system information
Python 3.11.11
NumPy 2.2.0
Scipy 1.14.1Metadata
Metadata
Assignees
Labels
defectA clear bug or issue that prevents SciPy from being installed or used as expectedA clear bug or issue that prevents SciPy from being installed or used as expected