OPTIMIZATION Challenge

Hi, reading the documentation Im not totally sure if I can solve this challenge…

  1. N vehicles with capacity size
  2. N addresses for pickups
  3. specific DELIVERY constraint (time)
  4. many packages going to same delivery address & time, and can share a route

SO, I need to build the most efficient routes backwards from delivery address/time and find based on capacity which packages could be picked up on same route/vehicle…

My understanding is that SHIPMENTS assumes that start all that deposit (same address) and not loaded during the route…

ANy suggestion?
thanks in advance

Yes, you can solve this with shipments: specify the pickup and delivery location accordingly as well as the time window for delivery.

But I’m unsure about your specific requirements as you say you have N vehicles and N addresses. Did you mean that you have one vehicle per address?

My understanding is that SHIPMENTS assumes that start all that deposit (same address) and not loaded during the route…

No. If you use shipments you can freely specify the start+end of each shipment. Only when you use services then you have a “depot” which must be used as (pickup) start or (delivery) destination.

Yes, but capacity & size are not working… With shipments size > 0, no shipments routed at all.

Did you set the capacity of the vehicle too? If yes, can you post a minimal example that does not work? (without real customer data)

Sure and thanks for your quick replies… see an example below… with shipments size > 0, I get an error… with size=0 error is skipped and but capacity not taken into consideration what its really needed…

{
“vehicle_types”: [
{
“type_id”: “van”,
“capacity”: [
12
],
“profile”: “car”,
“cost_per_activation”: 20,
“cost_per_meter”: 0.00015
},
{
“type_id”: “bus”,
“capacity”: [
35
],
“profile”: “car”,
“cost_per_activation”: 42,
“cost_per_meter”: 0.00025
}
],
“objectives”: [
{
“type”: “min”,
“value”: “completion_time”
}
],
“configuration”: {
“routing”: {
“calc_points”: true
}
},
“shipments”: [
{
“id”: “s1”,
“name”: “JWM”,
“pickup”: {
“address”: {
“location_id”: “21.0883820191863_-86.7701770422204”,
“lat”: 21.0883820191863,
“lon”: -86.7701770422204
},
“duration”: 300
},
“delivery”: {
“address”: {
“location_id”: “21.1416772435803_-86.774390895306”,
“lat”: 21.1416772435803,
“lon”: -86.774390895306
},
“time_windows”: [
{
“earliest”: 1693477800,
“latest”: 1693478700
}
],
“duration”: 600
},
“size”: [
3
]
},
{
“id”: “s2”,
“name”: “EC”,
“pickup”: {
“address”: {
“location_id”: “21.0741878568448_-86.7750067104034”,
“lat”: 21.0741878568448,
“lon”: -86.7750067104034
},
“duration”: 300
},
“delivery”: {
“address”: {
“location_id”: “21.1416772435803_-86.774390895306”,
“lat”: 21.1416772435803,
“lon”: -86.774390895306
},
“time_windows”: [
{
“earliest”: 1693477800,
“latest”: 1693478700
}
],
“duration”: 600
},
“size”: [
4
]
},
{
“id”: “s3”,
“name”: “WC”,
“pickup”: {
“address”: {
“location_id”: “21.1212212002566_-86.755264027018”,
“lat”: 21.1212212002566,
“lon”: -86.755264027018
},
“duration”: 300
},
“delivery”: {
“address”: {
“location_id”: “21.1416772435803_-86.774390895306”,
“lat”: 21.1416772435803,
“lon”: -86.774390895306
},
“time_windows”: [
{
“earliest”: 1693477800,
“latest”: 1693478700
}
],
“duration”: 600
},
“size”: [
2
]
},
{
“id”: “s4”,
“name”: “IP”,
“pickup”: {
“address”: {
“location_id”: “21.1374308015573_-86.7519431593183”,
“lat”: 21.1374308015573,
“lon”: -86.7519431593183
},
“duration”: 300
},
“delivery”: {
“address”: {
“location_id”: “21.1416772435803_-86.774390895306”,
“lat”: 21.1416772435803,
“lon”: -86.774390895306
},
“time_windows”: [
{
“earliest”: 1693477800,
“latest”: 1693478700
}
],
“duration”: 600
},
“size”: [
6
]
},
{
“id”: “s5”,
“name”: “CM”,
“pickup”: {
“address”: {
“location_id”: “21.1450391886116_-86.7777995334643”,
“lat”: 21.1450391886116,
“lon”: -86.7777995334643
},
“duration”: 300
},
“delivery”: {
“address”: {
“location_id”: “20.5831821798674_-87.1200553826557”,
“lat”: 20.5831821798674,
“lon”: -87.1200553826557
},
“time_windows”: [
{
“earliest”: 1693477800,
“latest”: 1693478700
}
],
“duration”: 600
},
“size”: [
3
]
},
{
“id”: “s6”,
“name”: “PR”,
“pickup”: {
“address”: {
“location_id”: “21.1113862821237_-86.7596254420538”,
“lat”: 21.1113862821237,
“lon”: -86.7596254420538
},
“duration”: 300
},
“delivery”: {
“address”: {
“location_id”: “21.1416772435803_-86.774390895306”,
“lat”: 21.1416772435803,
“lon”: -86.774390895306
},
“time_windows”: [
{
“earliest”: 1693477800,
“latest”: 1693478700
}
],
“duration”: 600
},
“size”: [
4
]
},
{
“id”: “s7”,
“name”: “HF”,
“pickup”: {
“address”: {
“location_id”: “21.1176807741337_-86.756279226784”,
“lat”: 21.1176807741337,
“lon”: -86.756279226784
},
“duration”: 300
},
“delivery”: {
“address”: {
“location_id”: “20.5831821798674_-87.1200553826557”,
“lat”: 20.5831821798674,
“lon”: -87.1200553826557
},
“time_windows”: [
{
“earliest”: 1693477800,
“latest”: 1693478700
}
],
“duration”: 600
},
“size”: [
2
]
}
],
“vehicles”: [
{
“vehicle_id”: “v1”,
“start_address”: {
“location_id”: “21.044737416717_-86.8743537162894”,
“lat”: 21.044737416717,
“lon”: -86.8743537162894
},
“max_jobs”: 50,
“return_to_depot”: false
},
{
“vehicle_id”: “v2”,
“start_address”: {
“location_id”: “21.184443843763_-86.8512284336537”,
“lat”: 21.184443843763,
“lon”: -86.8512284336537
},
“max_jobs”: 5,
“return_to_depot”: false
},
{
“vehicle_id”: “v3”,
“start_address”: {
“location_id”: “21.051638707812_-86.8495702751448”,
“lat”: 21.051638707812,
“lon”: -86.8495702751448
},
“max_jobs”: 10,
“return_to_depot”: false
}
]
}

You need to use your defined vehicle types (van or bus) in your vehicles list. So for example instead of

“vehicle_id”: “v1”,

you should use

“vehicle_id”: “bus”,

See the examples for the Route Optimization API at https://explorer.graphhopper.com/

Well, in fact I need to add type_id = “bus”… as vehicle_ID must be unique… many vehicles could be type “bus” bust their IDs must be unique… this was solved… now discovered something new…
image

early starting time defined as 5:AM to give room for optimization, with strict delivery-time at 10:40… but the route started 5AM (not needed at all)… and juste waited before delivering on the last step…

Unfortunately the start time is currently not part of the optimization and when you specify it as 5:00 it will stay at this time.