Skip to content

Commit

Permalink
TST: optimize.milp: remove problematic timeout/iteration test
Browse files Browse the repository at this point in the history
  • Loading branch information
mdhaber committed Oct 6, 2022
1 parent a6ba7ca commit 6b098c2
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions scipy/optimize/tests/test_milp.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,48 +272,6 @@ def test_infeasible_prob_16609():
np.testing.assert_equal(res.status, 2)


_msg_time = "Time limit reached. (HiGHS Status 13:"
_msg_iter = "Iteration limit reached. (HiGHS Status 14:"


@pytest.mark.skipif(np.intp(0).itemsize < 8,
reason="Unhandled 32-bit GCC FP bug")
@pytest.mark.slow
@pytest.mark.timeout(360)
@pytest.mark.parametrize(["options", "msg"], [({"time_limit": 10}, _msg_time),
({"node_limit": 1}, _msg_iter)])
def test_milp_timeout_16545(options, msg):
# Ensure solution is not thrown away if MILP solver times out
# -- see gh-16545
rng = np.random.default_rng(5123833489170494244)
A = rng.integers(0, 5, size=(100, 100))
b_lb = np.full(100, fill_value=-np.inf)
b_ub = np.full(100, fill_value=25)
constraints = LinearConstraint(A, b_lb, b_ub)
variable_lb = np.zeros(100)
variable_ub = np.ones(100)
variable_bounds = Bounds(variable_lb, variable_ub)
integrality = np.ones(100)
c_vector = -np.ones(100)
res = milp(
c_vector,
integrality=integrality,
bounds=variable_bounds,
constraints=constraints,
options=options,
)

assert res.message.startswith(msg)
assert res["x"] is not None

# ensure solution is feasible
x = res["x"]
tol = 1e-8 # sometimes needed due to finite numerical precision
assert np.all(b_lb - tol <= A @ x) and np.all(A @ x <= b_ub + tol)
assert np.all(variable_lb - tol <= x) and np.all(x <= variable_ub + tol)
assert np.allclose(x, np.round(x))


def test_three_constraints_16878():
# `milp` failed when exactly three constraints were passed
# Ensure that this is no longer the case.
Expand Down

0 comments on commit 6b098c2

Please sign in to comment.