-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmodel_complexity.go
53 lines (47 loc) · 1.54 KB
/
model_complexity.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
// © 2019-present nextmv.io inc
package nextroute
// Cost is type to indicate the cost of a function.
type Cost uint64
const (
// Constant is a constant cost function.
Constant Cost = 0
// LinearVehicle is a linear cost function with respect to the number of
// vehicles.
LinearVehicle = 1
// LinearStop is a linear cost function with respect to the number of stops.
LinearStop = 2
// QuadraticVehicle is a quadratic cost function with respect to the number
// of vehicles.
QuadraticVehicle = 3
// QuadraticStop is a quadratic cost function with respect to the number of
// stops.
QuadraticStop = 4
// ExponentialVehicle is an exponential cost function with respect to the
// number of vehicles.
ExponentialVehicle = 5
// ExponentialStop is an exponential cost function with respect to the
// number of stops.
ExponentialStop = 6
// CrazyExpensive is a function that is so expensive that it should never
// be used.
CrazyExpensive = 7
)
var costNames = map[Cost]string{
Constant: `O(1)`,
LinearVehicle: `O(ModelVehicle)`,
LinearStop: `O(Stop)`,
QuadraticVehicle: `O(ModelVehicle^2)`,
QuadraticStop: `O(Stop^2)`,
ExponentialVehicle: `O(2^ModelVehicle`,
ExponentialStop: `O(2^Stop)`,
CrazyExpensive: `O(no)`,
}
// String returns the name of the cost.
func (cost Cost) String() string {
return costNames[cost]
}
// Complexity is the interface for constraints that have a complexity.
type Complexity interface {
// EstimationCost returns the cost of the Estimation function.
EstimationCost() Cost
}