Skip to content

Commit

Permalink
Merge pull request #24 from nextmv-io/add-custom-operator-test
Browse files Browse the repository at this point in the history
Add custom operator test
  • Loading branch information
nmisek authored Mar 18, 2024
2 parents 2ca7f4d + 2c068e7 commit 5b4216f
Show file tree
Hide file tree
Showing 5 changed files with 538 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.21

require (
github.com/nextmv-io/sdk v1.5.0
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3
gonum.org/v1/gonum v0.14.0
)

Expand All @@ -19,4 +18,5 @@ require (
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect
)
49 changes: 49 additions & 0 deletions tests/custom_operators/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"defaults": {
"vehicles": {
"speed": 20,
"start_time": "2023-01-01T06:00:00-06:00",
"end_time": "2023-01-01T10:00:00-06:00"
}
},
"stops": [
{
"id": "Fushimi Inari Taisha",
"location": { "lon": 135.772695, "lat": 34.967146 }
},
{
"id": "Kiyomizu-dera",
"location": { "lon": 135.78506, "lat": 34.994857 }
},
{
"id": "Nijō Castle",
"location": { "lon": 135.748134, "lat": 35.014239 }
},
{
"id": "Kyoto Imperial Palace",
"location": { "lon": 135.762057, "lat": 35.025431 }
},
{
"id": "Gionmachi",
"location": { "lon": 135.775682, "lat": 35.002457 }
},
{
"id": "Kinkaku-ji",
"location": { "lon": 135.728898, "lat": 35.039705 }
},
{
"id": "Arashiyama Bamboo Forest",
"location": { "lon": 135.672009, "lat": 35.017209 }
}
],
"vehicles": [
{
"id": "v1",
"start_location": { "lon": 135.672009, "lat": 35.017209 }
},
{
"id": "v2",
"start_location": { "lon": 135.728898, "lat": 35.039705 }
}
]
}
257 changes: 257 additions & 0 deletions tests/custom_operators/input.json.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
{
"options": {
"check": {
"duration": 30000000000,
"verbosity": "off"
},
"format": {
"disable": {
"progression": true
}
},
"model": {
"constraints": {
"disable": {
"attributes": false,
"capacities": null,
"capacity": false,
"distance_limit": false,
"groups": false,
"maximum_duration": false,
"maximum_stops": false,
"maximum_wait_stop": false,
"maximum_wait_vehicle": false,
"mixing_items": false,
"precedence": false,
"start_time_windows": false,
"vehicle_end_time": false,
"vehicle_start_time": false
},
"enable": {
"cluster": false
}
},
"objectives": {
"capacities": "",
"cluster": 0,
"early_arrival_penalty": 1,
"late_arrival_penalty": 1,
"min_stops": 1,
"travel_duration": 0,
"unplanned_penalty": 1,
"vehicle_activation_penalty": 1,
"vehicles_duration": 1
},
"properties": {
"disable": {
"duration_groups": false,
"durations": false,
"initial_solution": false,
"stop_duration_multipliers": false
}
},
"validate": {
"disable": {
"resources": false,
"start_time": false
},
"enable": {
"matrix": false,
"matrix_asymmetry_tolerance": 20
}
}
},
"solve": {
"duration": 10000000000,
"iterations": 50,
"parallel_runs": 1,
"run_deterministically": true,
"start_solutions": 1
}
},
"solutions": [
{
"objective": {
"name": "1 * vehicles_duration + 1 * unplanned_penalty",
"objectives": [
{
"base": 621.4304640293121,
"factor": 1,
"name": "vehicles_duration",
"value": 621.4304640293121
},
{
"factor": 1,
"name": "unplanned_penalty",
"value": 0
}
],
"value": 621.4304640293121
},
"unplanned": [],
"vehicles": [
{
"id": "v1",
"route": [
{
"arrival_time": "2023-01-01T06:00:00-06:00",
"cumulative_travel_duration": 0,
"end_time": "2023-01-01T06:00:00-06:00",
"start_time": "2023-01-01T06:00:00-06:00",
"stop": {
"id": "v1-start",
"location": {
"lat": 35.017209,
"lon": 135.672009
}
},
"travel_duration": 0
},
{
"arrival_time": "2023-01-01T06:00:00-06:00",
"cumulative_travel_duration": 0,
"end_time": "2023-01-01T06:00:00-06:00",
"start_time": "2023-01-01T06:00:00-06:00",
"stop": {
"id": "Arashiyama Bamboo Forest",
"location": {
"lat": 35.017209,
"lon": 135.672009
}
},
"travel_duration": 0
}
],
"route_duration": 0,
"route_travel_duration": 0
},
{
"id": "v2",
"route": [
{
"arrival_time": "2023-01-01T06:00:00-06:00",
"cumulative_travel_duration": 0,
"end_time": "2023-01-01T06:00:00-06:00",
"start_time": "2023-01-01T06:00:00-06:00",
"stop": {
"id": "v2-start",
"location": {
"lat": 35.039705,
"lon": 135.728898
}
},
"travel_duration": 0
},
{
"arrival_time": "2023-01-01T06:00:00-06:00",
"cumulative_travel_duration": 0,
"end_time": "2023-01-01T06:00:00-06:00",
"start_time": "2023-01-01T06:00:00-06:00",
"stop": {
"id": "Kinkaku-ji",
"location": {
"lat": 35.039705,
"lon": 135.728898
}
},
"travel_duration": 0
},
{
"arrival_time": "2023-01-01T06:02:46-06:00",
"cumulative_travel_distance": 3329,
"cumulative_travel_duration": 166,
"end_time": "2023-01-01T06:02:46-06:00",
"start_time": "2023-01-01T06:02:46-06:00",
"stop": {
"id": "Nijō Castle",
"location": {
"lat": 35.014239,
"lon": 135.748134
}
},
"travel_distance": 3329,
"travel_duration": 166
},
{
"arrival_time": "2023-01-01T06:04:15-06:00",
"cumulative_travel_distance": 5105,
"cumulative_travel_duration": 255,
"end_time": "2023-01-01T06:04:15-06:00",
"start_time": "2023-01-01T06:04:15-06:00",
"stop": {
"id": "Kyoto Imperial Palace",
"location": {
"lat": 35.025431,
"lon": 135.762057
}
},
"travel_distance": 1776,
"travel_duration": 88
},
{
"arrival_time": "2023-01-01T06:06:37-06:00",
"cumulative_travel_distance": 7944,
"cumulative_travel_duration": 397,
"end_time": "2023-01-01T06:06:37-06:00",
"start_time": "2023-01-01T06:06:37-06:00",
"stop": {
"id": "Gionmachi",
"location": {
"lat": 35.002457,
"lon": 135.775682
}
},
"travel_distance": 2839,
"travel_duration": 141
},
{
"arrival_time": "2023-01-01T06:07:37-06:00",
"cumulative_travel_distance": 9145,
"cumulative_travel_duration": 457,
"end_time": "2023-01-01T06:07:37-06:00",
"start_time": "2023-01-01T06:07:37-06:00",
"stop": {
"id": "Kiyomizu-dera",
"location": {
"lat": 34.994857,
"lon": 135.78506
}
},
"travel_distance": 1201,
"travel_duration": 60
},
{
"arrival_time": "2023-01-01T06:10:21-06:00",
"cumulative_travel_distance": 12425,
"cumulative_travel_duration": 621,
"end_time": "2023-01-01T06:10:21-06:00",
"start_time": "2023-01-01T06:10:21-06:00",
"stop": {
"id": "Fushimi Inari Taisha",
"location": {
"lat": 34.967146,
"lon": 135.772695
}
},
"travel_distance": 3280,
"travel_duration": 164
}
],
"route_duration": 621,
"route_travel_distance": 12425,
"route_travel_duration": 621
}
]
}
],
"statistics": {
"run": {
"duration": 0.123,
"iterations": 50
},
"schema": "v1"
},
"version": {
"sdk": "VERSION"
}
}
Loading

0 comments on commit 5b4216f

Please sign in to comment.