-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsolution_construcation_sweep_test.go
71 lines (59 loc) · 1.57 KB
/
solution_construcation_sweep_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// © 2019-present nextmv.io inc
package nextroute_test
import (
"context"
"testing"
"github.com/nextmv-io/nextroute"
"github.com/nextmv-io/nextroute/common"
)
func TestSweepOneDepot(t *testing.T) {
input := singleVehiclePlanSingleStopsModel()
input.Vehicles = append(input.Vehicles, vehicles("truck", depot(), 1)...)
model, err := createModel(input)
if err != nil {
t.Fatal(err)
}
solution, err := nextroute.NewSweepSolution(context.Background(), model)
if err != nil {
t.Fatal(err)
}
if len(solution.Vehicles()) != 2 {
t.Errorf("expected 2 vehicles, got %v", len(solution.Vehicles()))
}
}
func TestSweepTwoDepots(t *testing.T) {
input := singleVehiclePlanSingleStopsModel()
location := Location{
Lat: 0,
Lon: 0,
}
input.Vehicles = append(input.Vehicles, vehicles("truck", location, 1)...)
model, err := createModel(input)
if err != nil {
t.Fatal(err)
}
_, err = nextroute.NewSweepSolution(context.Background(), model)
if err != nil {
if err.Error() != "sweep construction, not implemented for multiple start-end locations of input" {
t.Fatal(err)
}
}
}
func TestSweepStartAndEndDifferent(t *testing.T) {
input := singleVehiclePlanSingleStopsModel()
location := Location{
Lat: common.NewInvalidLocation().Latitude(),
Lon: common.NewInvalidLocation().Longitude(),
IsValid: false,
}
input.Vehicles[0].StartLocation = location
input.Vehicles[0].EndLocation = depot()
model, err := createModel(input)
if err != nil {
t.Fatal(err)
}
_, err = nextroute.NewSweepSolution(context.Background(), model)
if err != nil {
t.Fatal(err)
}
}