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

Function test_shuffle

tests/search/test_PerturbationManager.py:36–52  ·  view source on GitHub ↗

Tests shuffling and drawing random number of perturbations.

()

Source from the content-addressed store, hash-verified

34
35
36def test_shuffle():
37 """
38 Tests shuffling and drawing random number of perturbations.
39 """
40 params = PerturbationParams(1, 10)
41 manager = PerturbationManager(params)
42
43 rng = RandomNumberGenerator(seed=42)
44 for _ in range(10): # all samples should be within bounds
45 manager.shuffle(rng)
46 assert_(1 <= manager.num_perturbations() <= 10)
47
48 params = PerturbationParams(0, 0)
49 manager = PerturbationManager(params)
50 for _ in range(10): # same, but now we can only draw one outcome: 0
51 manager.shuffle(rng)
52 assert_equal(manager.num_perturbations(), 0)
53
54
55def test_num_perturbations_randomness():

Callers

nothing calls this directly

Calls 4

shuffleMethod · 0.95
PerturbationParamsClass · 0.90
PerturbationManagerClass · 0.90

Tested by

no test coverage detected