-
Notifications
You must be signed in to change notification settings - Fork 2
/
solution_initial_observer.go
107 lines (83 loc) · 2.49 KB
/
solution_initial_observer.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// © 2019-present nextmv.io inc
package nextroute
// InitialSolutionObserver is an observer that is used to detect the constraint
// that is violated by the initial solution.
type InitialSolutionObserver interface {
SolutionObserver
// Constraint returns the constraint that is violated by the initial
// solution. Can be nil if no constraint is violated.
Constraint() ModelConstraint
}
// newInitialSolutionObserver creates a new initial solution observer.
func newInitialSolutionObserver() InitialSolutionObserver {
return &initialSolutionObserver{}
}
type initialSolutionObserver struct {
constraint ModelConstraint
}
// OnSolutionConstraintChecked implements InitialSolutionObserver.
func (i *initialSolutionObserver) OnSolutionConstraintChecked(
constraint ModelConstraint,
feasible bool,
) {
if !feasible {
i.constraint = constraint
}
}
// OnStopConstraintChecked implements InitialSolutionObserver.
func (i *initialSolutionObserver) OnStopConstraintChecked(
_ SolutionStop,
constraint ModelConstraint,
feasible bool,
) {
if !feasible {
i.constraint = constraint
}
}
// OnVehicleConstraintChecked implements InitialSolutionObserver.
func (i *initialSolutionObserver) OnVehicleConstraintChecked(
_ SolutionVehicle,
constraint ModelConstraint,
feasible bool,
) {
if !feasible {
i.constraint = constraint
}
}
func (i *initialSolutionObserver) Constraint() ModelConstraint {
return i.constraint
}
func (i *initialSolutionObserver) OnNewSolution(_ Model) {
}
func (i *initialSolutionObserver) OnNewSolutionCreated(_ Solution) {
}
func (i *initialSolutionObserver) OnCopySolution(_ Solution) {
}
func (i *initialSolutionObserver) OnCopiedSolution(_ Solution) {
}
func (i *initialSolutionObserver) OnCheckConstraint(_ ModelConstraint, _ CheckedAt) {
}
func (i *initialSolutionObserver) OnEstimateIsViolated(constraint ModelConstraint) {
i.constraint = constraint
}
func (i *initialSolutionObserver) OnEstimatedIsViolated(
_ SolutionMove,
_ ModelConstraint,
_ bool,
_ StopPositionsHint,
) {
}
func (i *initialSolutionObserver) OnEstimateDeltaObjectiveScore() {
}
func (i *initialSolutionObserver) OnEstimatedDeltaObjectiveScore(_ float64) {
}
func (i *initialSolutionObserver) OnBestMove(_ Solution) {
}
func (i *initialSolutionObserver) OnBestMoveFound(_ SolutionMove) {
}
func (i *initialSolutionObserver) OnPlan(_ SolutionMove) {
}
func (i *initialSolutionObserver) OnPlanFailed(_ SolutionMove, _ ModelConstraint) {
}
func (i *initialSolutionObserver) OnPlanSucceeded(_ SolutionMove) {
}