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

Function test_best_initial_solution

tests/test_IteratedLocalSearch.py:86–101  ·  view source on GitHub ↗

Tests that ILS uses the initial solution to initialise the best found solution.

(rc208)

Source from the content-addressed store, hash-verified

84
85
86def test_best_initial_solution(rc208):
87 """
88 Tests that ILS uses the initial solution to initialise the best found
89 solution.
90 """
91 rng = RandomNumberGenerator(seed=42)
92 pm = PenaltyManager(initial_penalties=([20], 6, 6))
93 ls = LocalSearch(rc208, rng, compute_neighbours(rc208))
94 bks = read_solution("data/RC208.sol", rc208)
95 algo = IteratedLocalSearch(rc208, pm, rng, ls, bks)
96
97 result = algo.run(MaxIterations(0))
98
99 # The best known solution is the initial solution. Since we don't run any
100 # iterations, this should be returned as best solution.
101 assert_equal(result.best, bks)
102
103
104def test_ils_result_has_correct_stats(ok_small):

Callers

nothing calls this directly

Calls 8

runMethod · 0.95
PenaltyManagerClass · 0.90
LocalSearchClass · 0.90
compute_neighboursFunction · 0.90
read_solutionFunction · 0.90
IteratedLocalSearchClass · 0.90
MaxIterationsClass · 0.90

Tested by

no test coverage detected