-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmodel_objective_earliness_test.go
63 lines (54 loc) · 1.3 KB
/
model_objective_earliness_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
// © 2019-present nextmv.io inc
package nextroute_test
import (
"testing"
"github.com/nextmv-io/nextroute"
)
// Simply test that we can add a new earliness objective to the model.
func TestAddEarlinessObjective(t *testing.T) {
model, err := createModel(
input(
vehicleTypes("truck"),
[]Vehicle{
vehicles(
"truck",
depot(),
1,
)[0],
},
planSingleStops(),
planPairSequences(),
),
)
if err != nil {
t.Error(err)
}
if len(model.Objective().Terms()) != 0 {
t.Error("model objective should be empty")
}
targetTimeExpression := nextroute.NewStopTimeExpression("target_time", model.MaxTime())
factorExpression := nextroute.NewStopExpression(
"earliness_penalty_factor",
1.0,
)
earlinessObjective, err := nextroute.NewEarlinessObjective(
targetTimeExpression,
factorExpression,
nextroute.OnArrival,
)
if err != nil {
t.Error(err)
}
_, err = model.Objective().NewTerm(1.0, earlinessObjective)
if err != nil {
t.Error(err)
}
if len(model.Objective().Terms()) != 1 {
t.Error("model objective should have an objective")
}
}
// This test simulates a move on a solution and checks that the objective is
// being measured correctly based on a constant expression.
func TestEarlinessObjective_EstimateDeltaValue(_ *testing.T) {
// TODO: write test here
}