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

Function test_merge_two

tests/test_DurationSegment.py:22–43  ·  view source on GitHub ↗

Tests merging two duration segments.

()

Source from the content-addressed store, hash-verified

20
21
22def test_merge_two():
23 """
24 Tests merging two duration segments.
25 """
26 ds1 = DurationSegment(5, 0, 0, 5, 0)
27 ds2 = DurationSegment(0, 5, 3, 6, 0)
28
29 mat = np.asarray([[1, 4], [1, 2]])
30 merged = DurationSegment.merge(mat[0, 1], ds1, ds2)
31
32 # There is no release time. The first stop (ds1) takes already has five
33 # duration, and starts at time 0. Then, we have to drive for 4 units
34 # (mat(0, 1) = 4) to get to the second stop (ds2). This second segment has
35 # 5 time warp, and we arrive there at time 5 + 4 = 9, which is 9 - 6 = 3
36 # after its closing time window. So we get a final time warp of 5 + 3 = 8.
37 assert_equal(merged.time_warp(), 8)
38
39 # Now, let's add a bit of release time (3), so that the total time warp
40 # should become 8 + 3 = 11.
41 ds2 = DurationSegment(0, 5, 3, 6, 3)
42 merged = DurationSegment.merge(mat[0, 1], ds1, ds2)
43 assert_equal(merged.time_warp(), 11)
44
45
46def test_merging_two_previously_merged_duration_segments():

Callers

nothing calls this directly

Calls 2

DurationSegmentClass · 0.85
mergeMethod · 0.45

Tested by

no test coverage detected