Skip to content

Commit

Permalink
Reactivating golden file tests, adding start level test
Browse files Browse the repository at this point in the history
  • Loading branch information
merschformann committed Mar 1, 2024
1 parent 80c3d32 commit a245ac1
Show file tree
Hide file tree
Showing 4 changed files with 298 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/golden/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestMain(m *testing.M) {
func TestGolden(t *testing.T) {
golden.FileTests(
t,
"testdata/template_input.json",
"testdata",
golden.Config{
Args: []string{
"-solve.duration", "10s",
Expand Down
54 changes: 54 additions & 0 deletions tests/golden/testdata/start_level.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"defaults": {
"vehicles": {
"speed": 20
},
"stops": {
"quantity": -1
}
},
"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",
"capacity": 4,
"start_level": 0,
"start_location": { "lon": 135.772695, "lat": 34.967146 }
},
{
"id": "v2",
"capacity": 4,
"start_level": 4,
"start_location": { "lon": 135.728898, "lat": 35.039705 }
}
]
}
230 changes: 230 additions & 0 deletions tests/golden/testdata/start_level.json.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
{
"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": 365.6409371878048,
"factor": 1,
"name": "vehicles_duration",
"value": 365.6409371878048
},
{
"base": 3000000,
"factor": 1,
"name": "unplanned_penalty",
"value": 3000000
}
],
"value": 3000365.6409371877
},
"unplanned": [
{
"id": "Arashiyama Bamboo Forest",
"location": {
"lat": 35.017209,
"lon": 135.672009
}
},
{
"id": "Kinkaku-ji",
"location": {
"lat": 35.039705,
"lon": 135.728898
}
},
{
"id": "Kyoto Imperial Palace",
"location": {
"lat": 35.025431,
"lon": 135.762057
}
}
],
"vehicles": [
{
"id": "v1",
"route": [
{
"cumulative_travel_duration": 0,
"stop": {
"id": "v1-start",
"location": {
"lat": 34.967146,
"lon": 135.772695
}
},
"travel_duration": 0
},
{
"cumulative_travel_duration": 0,
"stop": {
"id": "Fushimi Inari Taisha",
"location": {
"lat": 34.967146,
"lon": 135.772695
}
},
"travel_duration": 0
},
{
"cumulative_travel_distance": 3280,
"cumulative_travel_duration": 164,
"stop": {
"id": "Kiyomizu-dera",
"location": {
"lat": 34.994857,
"lon": 135.78506
}
},
"travel_distance": 3280,
"travel_duration": 164
},
{
"cumulative_travel_distance": 4481,
"cumulative_travel_duration": 224,
"stop": {
"id": "Gionmachi",
"location": {
"lat": 35.002457,
"lon": 135.775682
}
},
"travel_distance": 1201,
"travel_duration": 60
},
{
"cumulative_travel_distance": 7311,
"cumulative_travel_duration": 365,
"stop": {
"id": "Nijō Castle",
"location": {
"lat": 35.014239,
"lon": 135.748134
}
},
"travel_distance": 2830,
"travel_duration": 141
}
],
"route_duration": 365,
"route_travel_distance": 7311,
"route_travel_duration": 365
},
{
"id": "v2",
"route": [
{
"cumulative_travel_duration": 0,
"stop": {
"id": "v2-start",
"location": {
"lat": 35.039705,
"lon": 135.728898
}
},
"travel_duration": 0
}
],
"route_duration": 0,
"route_travel_duration": 0
}
]
}
],
"statistics": {
"result": {
"custom": {
"activated_vehicles": 1,
"max_duration": 365,
"max_stops_in_vehicle": 4,
"max_travel_duration": 365,
"min_duration": 365,
"min_stops_in_vehicle": 4,
"min_travel_duration": 365,
"unplanned_stops": 3
},
"duration": 0.123,
"value": 3000365.6409371877
},
"run": {
"duration": 0.123,
"iterations": 50
},
"schema": "v1"
},
"version": {
"sdk": "VERSION"
}
}
13 changes: 13 additions & 0 deletions tests/golden/testdata/start_level.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Start level example (start_level.json)

This example demonstrates the use of the `start_level` parameter of the capacity
feature.

Find some notes about the example below:

- All stops have a `-1` quantity (all pickups), hence, the vehicles can service
as many as they have capacity but no more.
- The first vehicle `v1` defines a start level of 0 and can therefore service
as many stops as it has capacity.
- The second vehicle `v2` defines a start level equal to its capacity and can
therefore service no stops at all.

0 comments on commit a245ac1

Please sign in to comment.