Add a waypoint before a job

Can an optimisation request model a situation where the vehicle has to travel to a specific location before a job?

We have a requirement for some jobs to be preceded by a travelling to a specific waypoint immediately before the job, without other jobs being scheduled between the two locations. for example, to pick up an engineer to assist on a job (we don’t want to drag the assisting engineer round with us all day on other jobs)

Have tried modelling this as a Shipment with a pickup and delivery where the pickup is the location that must precede the job and the delivery is the actual job - this does make sure the pickup is scheduled earlier than the delivery but will allow other jobs to be done between the pickup and delivery.

If I have jobs at compass points:

    N
W   C   E
    S

but must make sure the West job must precede the East job with no jobs between, order of the other jobs can be optimised but West and East must be together eg: N > (W > E) > C > S.

{
    "jobs": [
        {
            "id": 1,
            "location": [
                -1.47055127219153,
                53.4164125891698
            ],
            "description": "north"
        },
        {
            "id": 2,
            "location": [
                -1.470085,
                53.3811290000678
            ],
            "description": "central"
        },
        {
            "id": 5,
            "location": [
                -1.46842328186653,
                53.3498244399211
            ],
            "description": "south"
        }
    ],
    "shipments": [
        {
            "amount": [
                1
            ],
            "pickup": {
                "id": 3,
                "location": [
                    -1.54223767395638,
                    53.3836259420499
                ],
                "description": "west"
            },
            "delivery": {
                "id": 4,
                "location": [
                    -1.4114317047181,
                    53.3852641211438
                ],
                "description": "east"
            }
        }
    ],
    "vehicles": [
        {
            "id": 1,
            "profile": "driving-car",
            "start": [
                -1.470551,
                53.416413
            ],
            "end": [
                -1.470551,
                53.416413
            ],
            "time_window": [
                1695024000,
                1695060000
            ],
            "capacity": [
                1
            ]
        }
    ]
}

then the Central and South jobs are always scheduled between the West and East jobs.

Hey,

I can’t think of a way to model this with VROOM, but there might be a workaround for your problem:

You could model your East job as the starting point and the West job as the end point of your vehicle, and the start/end point of your vehicle as a job location.

This will yield the most optimal route from East via your Starting Point to West, and inserting the best West->East connection, an optimal round trip that includes this connection.

Best regards

Thanks for the prompt reply.

Setting vehicle start and end locations wouldn’t reflect the real world locations of the vehicle but it’s an interesting idea.

I’ve tried playing with the capacity restrictions, using the Delivery, Pickup and Amount values but I’m tripping up over the default behaviour :

It is assumed that all delivery-related amounts for jobs are loaded at vehicle start, while all pickup-related amounts for jobs are brought back at vehicle end.

Do you know if there is any way to change the default capacity behavior?

hi @jschnell - Frustrated with how close to modelling waypoints the API gets I had a mess with constructing the request as all shipments

If the vehicle has a capacity of 1, when we create jobs its assuming the amount, if set, is loaded onto the vehicle before it sets off or collected when the job is done.

For a shipment the amount is added to the vehicle capacity when the pickup is done and decremented when the delivery is complete - therefore if we start with an empty vehicle and theres a pickup in its schedule the vehicle cant do any more jobs until the delivery decrements the vehicle capacity amount - forcing the delivery to happen immediately after the pickup

Great - we can force them to happen in the right sequence with no jobs between!

However - what about the rest of the jobs with no waypoints? - if we need to ensure the vehicle capacity is zero at the start of the route we cant add an amount to the job, this would allow a zero amount job to be scheduled between the pickup and delivery as it wouldnt break capacity restrictions, but if we model all jobs as a shipment with a capacity of 1 we can create a pickup AND a delivery at the same location and the scheduler will force them to be together (being at the same location, and the capacity restriction, makes the optimal solution put them together without a journey between)

Will need to add fake pickups for all jobs and turn them into shipments, and remove the fake pickup when I parse the results but get all the jobs in the right order.

{
    "shipments": [
        {
            "amount": [
                1
            ],
            "pickup": {
                "id": 3,
                "location": [
                    -1.54223767395638,
                    53.3836259420499
                ],
                "description": "west",
                "priority": 100
            },
            "delivery": {
                "id": 4,
                "location": [
                    -1.4114317047181,
                    53.3852641211438
                ],
                "description": "east",
                "priority": 100
            }
        },
        {
            "amount": [
                1
            ],
            "pickup": {
                "id": 1,
                "location": [
                    -1.47055127219153,
                    53.4164125891698
                ],
                "description": "north-fake-pickup"
            },
            "delivery": {
                "id": 100,
                "location": [
                    -1.47055127219153,
                    53.4164125891698
                ],
                "description": "north"
            }
        },
        {
            "amount": [
                1
            ],
            "pickup": {
                "id": 2,
                "location": [
                    -1.470085,
                    53.3811290000678
                ],
                "description": "central-fake-pickup"
            },
            "delivery": {
                "id": 222,
                "location": [
                    -1.470085,
                    53.3811290000678
                ],
                "description": "central"
            }
        },
        {
            "amount": [
                1
            ],
            "pickup": {
                "id": 5,
                "location": [
                    -1.46842328186653,
                    53.3498244399211
                ],
                "description": "south-fake-pickup"
            },
            "delivery": {
                "id": 555,
                "location": [
                    -1.46842328186653,
                    53.3498244399211
                ],
                "description": "south"
            }
        }
    ],
    "vehicles": [
        {
            "id": 1,
            "profile": "driving-car",
            "start": [
                -1.470551,
                53.416413
            ],
            "end": [
                -1.470551,
                53.416413
            ],
            "time_window": [
                1695024000,
                1695060000
            ],
            "capacity": [
                1
            ]
        }
    ]
}
1 Like

Hi @mgashworth,

maybe also take this over to vroom if you want them to support that use case:

Best regards