routific 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +129 -110
- data/lib/routific/location.rb +7 -2
- data/lib/routific/vehicle.rb +7 -2
- data/lib/routific/visit.rb +7 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 816c3c547394292568835be244e80f7e3042a2bf
|
4
|
+
data.tar.gz: 7699025ca637127d31938cf3f0737ff14a881ef7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca55300f37e6c0659b33c89d6bd57eba44b2e80eefc668bad6f1c38bf8817d7ffa144d8f8b99c0598bbb2c61f0ef3699c61b9ebcaa4284cfcbda26b389a1ea88
|
7
|
+
data.tar.gz: fffe66b45b0f2f52b0c8882f328c7960c6637c5fb963f1d924ef902db9c539e0e4b6b3db2a4725d70407a65b4d8f2dffb044476b57041b3c53d64878cd24d1b7
|
data/README.md
CHANGED
@@ -1,150 +1,169 @@
|
|
1
1
|
Routific Ruby Gem
|
2
2
|
=================
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
Logistics companies struggle with this challenge every day; most of them are still manually scheduling their fleet with a team of dispatchers.
|
7
|
-
|
8
|
-
Routific can automate this process, and optimize it. The savings are tremendous: less fuel, and fewer vehicles, drivers and dispatchers.
|
4
|
+
[](http://travis-ci.org/asoesilo/routific-gem)
|
9
5
|
|
10
|
-
|
6
|
+
This Ruby Gem assists users to easily access the [Routific API][1], which is a practical and scalable solution to the Vehicle Routing Problem.
|
11
7
|
|
12
|
-
[1]: https://routific.com
|
8
|
+
[1]: https://routific.com/developers
|
13
9
|
|
14
10
|
Installing
|
15
11
|
----------
|
16
12
|
|
17
|
-
|
13
|
+
`gem install routific`
|
18
14
|
|
19
15
|
Usage
|
20
16
|
-----
|
21
|
-
Remember to require it before using it
|
17
|
+
Remember to require it and instantiate it with your token before using it
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require 'routific'
|
21
|
+
routific = Routific.new(--API_KEY--)
|
22
|
+
```
|
23
|
+
|
24
|
+
### Instance methods
|
25
|
+
|
26
|
+
`routific.setLocation( id, params )`
|
27
|
+
|
28
|
+
Sets a location with the specified ID and parameters
|
29
|
+
|
30
|
+
Required arguments in params:
|
31
|
+
|
32
|
+
- lat: Latitude of this location
|
33
|
+
- lng: Longitude of this location
|
34
|
+
|
35
|
+
Optional arguments in params:
|
22
36
|
|
23
|
-
|
37
|
+
- name: Name of this location
|
24
38
|
|
25
|
-
|
39
|
+
`routific.setVisit( id, [params] )`
|
26
40
|
|
27
|
-
|
41
|
+
Sets a visit for the specified location using the specified parameters
|
28
42
|
|
29
|
-
|
30
|
-
|
31
|
-
- lat: Latitude of this location
|
32
|
-
- lng: Longitude of this location
|
43
|
+
Optional arguments in params:
|
33
44
|
|
34
|
-
|
35
|
-
|
45
|
+
- start: the earliest time for this visit. Default value is 00:00, if not specified.
|
46
|
+
- end: the latest time for this visit. Default value is 23:59, if not specified.
|
47
|
+
- duration: the length of this visit in minutes
|
48
|
+
- demand: the capacity that this visit requires
|
36
49
|
|
37
|
-
|
50
|
+
`routific.setVehicle( id, params )`
|
38
51
|
|
39
|
-
|
52
|
+
Sets a vehicle with the specified ID and parameters
|
40
53
|
|
41
|
-
|
42
|
-
- start: the earliest time for this visit. Default value is 00:00, if not specified.
|
43
|
-
- end: the latest time for this visit. Default value is 23:59, if not specified.
|
44
|
-
- duration: the length of this visit in minutes
|
45
|
-
- demand: the capacity that this visit requires
|
54
|
+
Required arguments in params:
|
46
55
|
|
47
|
-
|
56
|
+
- start_location: ID of start location for this vehicle
|
48
57
|
|
49
|
-
|
50
|
-
|
51
|
-
Required arguments in params:
|
52
|
-
- start_location: ID of start location for this vehicle
|
58
|
+
Optional arguments in params:
|
53
59
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
- capacity: the capacity that this vehicle can load
|
60
|
+
- end_location: ID of end location for this vehicle
|
61
|
+
- shift_start: this vehicle's start shift time (e.g. '08:00'). Default value is 00:00, if not specified.
|
62
|
+
- shift_end: this vehicle's end shift time (e.g. '17:00'). Default value is 23:59, if not specified.
|
63
|
+
- capacity: the capacity that this vehicle can load
|
59
64
|
|
60
|
-
|
65
|
+
`routific.getRoute()`
|
61
66
|
|
62
|
-
|
63
|
-
fleet information
|
64
|
-
> routific.getRoute()
|
67
|
+
Returns the route using the previously provided network, visits and fleet information
|
65
68
|
|
66
|
-
The following class methods are available:
|
67
69
|
|
68
|
-
|
69
|
-
> Routific.setToken( token )
|
70
|
+
### Class methods
|
70
71
|
|
71
|
-
|
72
|
-
> Routific.getRoute( id, [params] )
|
72
|
+
`Routific.setToken( token )`
|
73
73
|
|
74
|
-
|
74
|
+
Sets the default access token to use
|
75
|
+
|
76
|
+
`Routific.getRoute( id, [params] )`
|
77
|
+
|
78
|
+
Returns the route using the specified access token, network, visits and fleet information
|
79
|
+
|
80
|
+
|
81
|
+
Both getRoute functions return the Route object, which has the following attributes:
|
75
82
|
|
76
83
|
- status: A sanity check, will always be success when the HTTP code is 200
|
77
84
|
- fitness: Total travel-time, representing the fitness score of the solution (less is better)
|
78
|
-
- unserved: List of visits that could not be scheduled.
|
85
|
+
- unserved: List of visits that could not be scheduled.
|
79
86
|
- vehicleRoutes: The optimized schedule
|
80
87
|
|
81
88
|
Examples
|
82
89
|
--------
|
83
90
|
Example 1:
|
84
91
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
92
|
+
```ruby
|
93
|
+
require 'routific'
|
94
|
+
|
95
|
+
routific = Routific.new(--API_KEY--)
|
96
|
+
|
97
|
+
routific.setLocation("order_1", {
|
98
|
+
"name" => "6800 Cambie",
|
99
|
+
"lat" => 49.227107,
|
100
|
+
"lng" => -123.1163085,
|
101
|
+
})
|
102
|
+
|
103
|
+
routific.setLocation("depot", {
|
104
|
+
"name" => "800 Kingsway",
|
105
|
+
"lat" => 49.2553636,
|
106
|
+
"lng" => -123.0873365,
|
107
|
+
})
|
108
|
+
|
109
|
+
routific.setVisit("order_1", {
|
110
|
+
"start" => "9:00",
|
111
|
+
"end" => "12:00",
|
112
|
+
"duration" => 10,
|
113
|
+
})
|
114
|
+
|
115
|
+
routific.setVehicle("vehicle_1", {
|
116
|
+
"start_location" => "depot",
|
117
|
+
"end_location" => "depot",
|
118
|
+
"shift_start" => "8:00",
|
119
|
+
"shift_end" => "12:00",
|
120
|
+
})
|
121
|
+
|
122
|
+
route = routific.getRoute()
|
123
|
+
```
|
124
|
+
|
113
125
|
Example 2:
|
114
126
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
127
|
+
```ruby
|
128
|
+
require 'routific'
|
129
|
+
|
130
|
+
Routific.setToken(--API_KEY--)
|
131
|
+
|
132
|
+
network = {
|
133
|
+
"order_1" => {
|
134
|
+
"name" => "6800 Cambie",
|
135
|
+
"lat" => 49.227107,
|
136
|
+
"lng" => -123.1163085
|
137
|
+
},
|
138
|
+
"depot" => {
|
139
|
+
"name" => "800 Kingsway",
|
140
|
+
"lat" => 49.2553636,
|
141
|
+
"lng" => -123.0873365
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
visits = {
|
146
|
+
"order_1" => {
|
147
|
+
"start" => "9:00",
|
148
|
+
"end" => "12:00",
|
149
|
+
"duration" => 10
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
fleet = {
|
154
|
+
"vehicle_1" => {
|
155
|
+
"start-location" => "depot",
|
156
|
+
"end-location" => "depot",
|
157
|
+
"shift-start" => "8:00",
|
158
|
+
"shift-end" => "12:00"
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
data = {
|
163
|
+
network: network,
|
164
|
+
visits: visits,
|
165
|
+
fleet: fleet
|
166
|
+
}
|
167
|
+
|
168
|
+
route = Routific.getRoute(data)
|
169
|
+
```
|
data/lib/routific/location.rb
CHANGED
@@ -19,14 +19,19 @@ class Location
|
|
19
19
|
@name = params["name"]
|
20
20
|
end
|
21
21
|
|
22
|
-
# Returns the JSON representation of this object
|
23
22
|
def to_json(options = nil)
|
23
|
+
as_json(options).to_json
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the JSON representation of this object
|
27
|
+
# def to_json(options = nil)
|
28
|
+
def as_json(options = nil)
|
24
29
|
jsonData = {}
|
25
30
|
jsonData["name"] = self.name if self.name
|
26
31
|
jsonData["lat"] = self.lat
|
27
32
|
jsonData["lng"] = self.lng
|
28
33
|
|
29
|
-
jsonData
|
34
|
+
jsonData
|
30
35
|
end
|
31
36
|
|
32
37
|
private
|
data/lib/routific/vehicle.rb
CHANGED
@@ -23,8 +23,13 @@ class Vehicle
|
|
23
23
|
@capacity = params["capacity"]
|
24
24
|
end
|
25
25
|
|
26
|
+
def to_json(options=nil)
|
27
|
+
as_json(options).to_json
|
28
|
+
end
|
29
|
+
|
26
30
|
# Returns the JSON representation of this object
|
27
|
-
def to_json(options = nil)
|
31
|
+
# def to_json(options = nil)
|
32
|
+
def as_json(options = nil)
|
28
33
|
jsonData = {}
|
29
34
|
jsonData["start-location"] = self.start_location
|
30
35
|
jsonData["end-location"] = self.end_location if self.end_location
|
@@ -32,7 +37,7 @@ class Vehicle
|
|
32
37
|
jsonData["shift-end"] = self.shift_end if self.shift_end
|
33
38
|
jsonData["capacity"] = self.capacity if self.capacity
|
34
39
|
|
35
|
-
jsonData
|
40
|
+
jsonData
|
36
41
|
end
|
37
42
|
|
38
43
|
private
|
data/lib/routific/visit.rb
CHANGED
@@ -16,14 +16,19 @@ class Visit
|
|
16
16
|
@demand = params["demand"]
|
17
17
|
end
|
18
18
|
|
19
|
+
def to_json(options)
|
20
|
+
as_json(options).to_json
|
21
|
+
end
|
22
|
+
|
19
23
|
# Returns the JSON representation of this object
|
20
|
-
def to_json(options = nil)
|
24
|
+
# def to_json(options = nil)
|
25
|
+
def as_json(options = nil)
|
21
26
|
jsonData = {}
|
22
27
|
jsonData["start"] = self.start if self.start
|
23
28
|
jsonData["end"] = self.end if self.end
|
24
29
|
jsonData["duration"] = self.duration if self.duration
|
25
30
|
jsonData["demand"] = self.demand if self.demand
|
26
31
|
|
27
|
-
jsonData
|
32
|
+
jsonData
|
28
33
|
end
|
29
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: routific
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Kuo
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|