MCPcopy Create free account
hub / github.com/PyVRP/PyVRP / test_solve_custom_params

Function test_solve_custom_params

tests/test_solve.py:89–106  ·  view source on GitHub ↗

Tests that solving an instance with custom solver parameters works as expected by checking how solutions are accepted.

(rc208)

Source from the content-addressed store, hash-verified

87
88
89def test_solve_custom_params(rc208):
90 """
91 Tests that solving an instance with custom solver parameters works as
92 expected by checking how solutions are accepted.
93 """
94
95 def monotonically_decreasing(arr) -> np.bool_:
96 return np.all(np.diff(arr) <= 0)
97
98 # Configure ILS to only accept improving solutions by setting
99 # ``history_length=1``.
100 params = SolveParams(IteratedLocalSearchParams(history_length=1))
101 res = solve(rc208, stop=MaxIterations(20), params=params)
102
103 # The current costs should now be monotonically decreasing. The first datum
104 # is skipped because it's an empty initial solution with penalised cost 0.
105 costs = [datum.current_cost for datum in res.stats.data[1:]]
106 assert_(monotonically_decreasing(costs))

Callers

nothing calls this directly

Calls 5

SolveParamsClass · 0.90
solveFunction · 0.90
MaxIterationsClass · 0.90
monotonically_decreasingFunction · 0.85

Tested by

no test coverage detected