VROOM-Project / vroom

Vehicle Routing Open-source Optimization Machine

Home Page:http://vroom-project.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Divide jobs by equal time to vehicles

DejavuDaniel opened this issue · comments

Hi is it possible with vroom and osrm to lets say give 2 vehicles and 20 locations and get not the job locations divided by capacity 10 each.
but be divided by route time so that it would take around the same time to deliver to the locations ?
So the result could be one has 5 jobs other 15 and the route time would be around 2h each

Did you try using time windows?

On each job or driver ? Could you show an example please

this is the request i send :
`{
"vehicles": [
{
"id": 1,
"start": [
54.709692,
25.272143
],

        "speed_factor": 5,
        "time_window": [
            1708232400,
            1708318800
        ]
    },
    {
        "id": 2,
        "start": [
            54.709692,
            25.272143
        ],
        "speed_factor": 5,
        "time_window": [
            1708232400,
            1708318800
        ]
    }
],
"jobs": [
    {
        "id": 179,
        "location": [
            54.693050,
            25.269890
        ],
        "service": 300
    },
    {
        "id": 178,
        "location": [
            54.683740,
            25.289531
        ],
        "service": 300
    },
    {
        "id": 182,
        "location": [
            54.685166,
            25.293319
        ],
        "service": 300
    },
    {
        "id": 181,
        "location": [
            54.685856,
            25.281992
        ],
        "service": 300
    },
    {
        "id": 183,
        "location": [
            54.681682,
            25.292441
        ],
        "service": 300
    },
    {
        "id": 185,
        "location": [
            54.676300,
            25.292420
        ],
        "service": 300
    },
    {
        "id": 186,
        "location": [
            54.684549,
            25.277140
        ],
        "service": 300
    },
    {
        "id": 187,
        "location": [
            54.677009,
            25.285071
        ],
        "service": 300
    },
    {
        "id": 189,
        "location": [
            54.684012,
            25.288001
        ],
        "service": 300
    },
    {
        "id": 190,
        "location": [
            54.679161,
            25.287042
        ],
        "service": 300
    },
    {
        "id": 191,
        "location": [
            54.675749,
            25.288050
        ],
        "service": 300
    },
    {
        "id": 194,
        "location": [
            54.680044,
            25.280552
        ],
        "service": 300
    },
    {
        "id": 195,
        "location": [
            54.676440,
            25.286386
        ],
        "service": 300
    },
    {
        "id": 193,
        "location": [
            54.683943,
            25.279566
        ],
        "service": 300
    },
    {
        "id": 176,
        "location": [
            54.687952,
            25.276155
        ],
        "service": 300
    },
    {
        "id": 180,
        "location": [
            54.592051,
            25.057288
        ],
        "service": 300
    },
    {
        "id": 192,
        "location": [
            54.682603,
            25.281333
        ],
        "service": 300
    },
    {
        "id": 177,
        "location": [
            54.680198,
            25.282857
        ],
        "service": 300
    }
],
"options": {
    "g": true,
    "c": false,
    "t": 8,
    "x": 20
}

}`

and the response i get :

{ "code": 0, "summary": { "cost": 0, "routes": 1, "unassigned": 0, "setup": 0, "service": 5400, "duration": 0, "waiting_time": 0, "priority": 0, "distance": 0, "violations": [], "computing_times": { "loading": 5, "solving": 2, "routing": 3 } }, "unassigned": [], "routes": [ { "vehicle": 1, "cost": 0, "setup": 0, "service": 5400, "duration": 0, "waiting_time": 0, "priority": 0, "distance": 0, "steps": [ { "type": "start", "location": [ 54.709692, 25.272143 ], "setup": 0, "service": 0, "waiting_time": 0, "arrival": 1708232400, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.680198, 25.282857 ], "id": 177, "setup": 0, "service": 300, "waiting_time": 0, "job": 177, "arrival": 1708232400, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.682603, 25.281333 ], "id": 192, "setup": 0, "service": 300, "waiting_time": 0, "job": 192, "arrival": 1708232700, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.592051, 25.057288 ], "id": 180, "setup": 0, "service": 300, "waiting_time": 0, "job": 180, "arrival": 1708233000, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.687952, 25.276155 ], "id": 176, "setup": 0, "service": 300, "waiting_time": 0, "job": 176, "arrival": 1708233300, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.683943, 25.279566 ], "id": 193, "setup": 0, "service": 300, "waiting_time": 0, "job": 193, "arrival": 1708233600, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.67644, 25.286386 ], "id": 195, "setup": 0, "service": 300, "waiting_time": 0, "job": 195, "arrival": 1708233900, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.680044, 25.280552 ], "id": 194, "setup": 0, "service": 300, "waiting_time": 0, "job": 194, "arrival": 1708234200, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.675749, 25.28805 ], "id": 191, "setup": 0, "service": 300, "waiting_time": 0, "job": 191, "arrival": 1708234500, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.679161, 25.287042 ], "id": 190, "setup": 0, "service": 300, "waiting_time": 0, "job": 190, "arrival": 1708234800, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.684012, 25.288001 ], "id": 189, "setup": 0, "service": 300, "waiting_time": 0, "job": 189, "arrival": 1708235100, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.677009, 25.285071 ], "id": 187, "setup": 0, "service": 300, "waiting_time": 0, "job": 187, "arrival": 1708235400, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.684549, 25.27714 ], "id": 186, "setup": 0, "service": 300, "waiting_time": 0, "job": 186, "arrival": 1708235700, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.6763, 25.29242 ], "id": 185, "setup": 0, "service": 300, "waiting_time": 0, "job": 185, "arrival": 1708236000, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.681682, 25.292441 ], "id": 183, "setup": 0, "service": 300, "waiting_time": 0, "job": 183, "arrival": 1708236300, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.685856, 25.281992 ], "id": 181, "setup": 0, "service": 300, "waiting_time": 0, "job": 181, "arrival": 1708236600, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.685166, 25.293319 ], "id": 182, "setup": 0, "service": 300, "waiting_time": 0, "job": 182, "arrival": 1708236900, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.68374, 25.289531 ], "id": 178, "setup": 0, "service": 300, "waiting_time": 0, "job": 178, "arrival": 1708237200, "duration": 0, "violations": [], "distance": 0 }, { "type": "job", "location": [ 54.69305, 25.26989 ], "id": 179, "setup": 0, "service": 300, "waiting_time": 0, "job": 179, "arrival": 1708237500, "duration": 0, "violations": [], "distance": 0 }, { "type": "end", "location": [ 54.69305, 25.26989 ], "setup": 0, "service": 0, "waiting_time": 0, "arrival": 1708237800, "duration": 0, "violations": [], "distance": 0 } ], "violations": [], "geometry": "}|kiIsyf|C??????????????????????????????????????" } ] }

am i setting the time window wrong ?
sorry but i dont quit understand

In output, the duration, distance and cost values in summary are all 0 which is highly suspicious. My guess is you're switching lon,lat values in coordinates, resulting in points outside your OSM extract.

for some reason osrm would output not the best route so i changed to use ors . it works!

body i send:

{ "vehicles": [ { "id": 1, "profile": "driving-car", "start": [ 25.272143, 54.709692 ], "end": [ 25.272143, 54.709692 ], "time_window": [ 0, 6600 ] }, { "id": 2, "profile": "driving-car", "start": [ 25.272143, 54.709692 ], "end": [ 25.272143, 54.709692 ], "time_window": [ 0, 6600 ] } ], "jobs": [ { "id": 179, "service": 300, "location": [ 25.269890, 54.693050 ] }, { "id": 178, "service": 300, "location": [ 25.289531, 54.683740 ] }, { "id": 182, "service": 300, "location": [ 25.293319, 54.685166 ] }, { "id": 181, "service": 300, "location": [ 25.281992, 54.685856 ] }, { "id": 183, "service": 300, "location": [ 25.292441, 54.681682 ] }, { "id": 185, "service": 300, "location": [ 25.292420, 54.676300 ] }, { "id": 186, "service": 300, "location": [ 25.277140, 54.684549 ] }, { "id": 187, "service": 300, "location": [ 25.285071, 54.677009 ] }, { "id": 189, "service": 300, "location": [ 25.288001, 54.684012 ] }, { "id": 190, "service": 300, "location": [ 25.287042, 54.679161 ] }, { "id": 191, "service": 300, "location": [ 25.288050, 54.675749 ] }, { "id": 194, "service": 300, "location": [ 25.280552, 54.680044 ] }, { "id": 180, "service": 300, "location": [ 25.057288, 54.592051 ] }, { "id": 193, "service": 300, "location": [ 25.279566, 54.683943 ] }, { "id": 176, "service": 300, "location": [ 25.276155, 54.687952 ] }, { "id": 195, "service": 300, "location": [ 25.286386, 54.676440 ] }, { "id": 192, "service": 300, "location": [ 25.281333, 54.682603 ] }, { "id": 177, "service": 300, "location": [ 25.282857, 54.680198 ] } ] }

the response i get :

{ "code": 0, "summary": { "cost": 7568, "routes": 2, "unassigned": 0, "setup": 0, "service": 5400, "duration": 7568, "waiting_time": 0, "priority": 0, "violations": [], "computing_times": { "loading": 29, "solving": 13 } }, "unassigned": [], "routes": [ { "vehicle": 1, "cost": 5033, "setup": 0, "service": 1500, "duration": 5033, "waiting_time": 0, "priority": 0, "steps": [ { "type": "start", "location": [ 25.272143, 54.709692 ], "setup": 0, "service": 0, "waiting_time": 0, "arrival": 0, "duration": 0, "violations": [] }, { "type": "job", "location": [ 25.26989, 54.69305 ], "id": 179, "setup": 0, "service": 300, "waiting_time": 0, "job": 179, "arrival": 363, "duration": 363, "violations": [] }, { "type": "job", "location": [ 25.282857, 54.680198 ], "id": 177, "setup": 0, "service": 300, "waiting_time": 0, "job": 177, "arrival": 950, "duration": 650, "violations": [] }, { "type": "job", "location": [ 25.287042, 54.679161 ], "id": 190, "setup": 0, "service": 300, "waiting_time": 0, "job": 190, "arrival": 1619, "duration": 1019, "violations": [] }, { "type": "job", "location": [ 25.285071, 54.677009 ], "id": 187, "setup": 0, "service": 300, "waiting_time": 0, "job": 187, "arrival": 2053, "duration": 1153, "violations": [] }, { "type": "job", "location": [ 25.057288, 54.592051 ], "id": 180, "setup": 0, "service": 300, "waiting_time": 0, "job": 180, "arrival": 4234, "duration": 3034, "violations": [] }, { "type": "end", "location": [ 25.272143, 54.709692 ], "setup": 0, "service": 0, "waiting_time": 0, "arrival": 6533, "duration": 5033, "violations": [] } ], "violations": [] }, { "vehicle": 2, "cost": 2535, "setup": 0, "service": 3900, "duration": 2535, "waiting_time": 0, "priority": 0, "steps": [ { "type": "start", "location": [ 25.272143, 54.709692 ], "setup": 0, "service": 0, "waiting_time": 0, "arrival": 0, "duration": 0, "violations": [] }, { "type": "job", "location": [ 25.281992, 54.685856 ], "id": 181, "setup": 0, "service": 300, "waiting_time": 0, "job": 181, "arrival": 514, "duration": 514, "violations": [] }, { "type": "job", "location": [ 25.279566, 54.683943 ], "id": 193, "setup": 0, "service": 300, "waiting_time": 0, "job": 193, "arrival": 890, "duration": 590, "violations": [] }, { "type": "job", "location": [ 25.281333, 54.682603 ], "id": 192, "setup": 0, "service": 300, "waiting_time": 0, "job": 192, "arrival": 1289, "duration": 689, "violations": [] }, { "type": "job", "location": [ 25.288001, 54.684012 ], "id": 189, "setup": 0, "service": 300, "waiting_time": 0, "job": 189, "arrival": 1798, "duration": 898, "violations": [] }, { "type": "job", "location": [ 25.293319, 54.685166 ], "id": 182, "setup": 0, "service": 300, "waiting_time": 0, "job": 182, "arrival": 2209, "duration": 1009, "violations": [] }, { "type": "job", "location": [ 25.289531, 54.68374 ], "id": 178, "setup": 0, "service": 300, "waiting_time": 0, "job": 178, "arrival": 2580, "duration": 1080, "violations": [] }, { "type": "job", "location": [ 25.292441, 54.681682 ], "id": 183, "setup": 0, "service": 300, "waiting_time": 0, "job": 183, "arrival": 2959, "duration": 1159, "violations": [] }, { "type": "job", "location": [ 25.29242, 54.6763 ], "id": 185, "setup": 0, "service": 300, "waiting_time": 0, "job": 185, "arrival": 3441, "duration": 1341, "violations": [] }, { "type": "job", "location": [ 25.28805, 54.675749 ], "id": 191, "setup": 0, "service": 300, "waiting_time": 0, "job": 191, "arrival": 3824, "duration": 1424, "violations": [] }, { "type": "job", "location": [ 25.286386, 54.67644 ], "id": 195, "setup": 0, "service": 300, "waiting_time": 0, "job": 195, "arrival": 4325, "duration": 1625, "violations": [] }, { "type": "job", "location": [ 25.280552, 54.680044 ], "id": 194, "setup": 0, "service": 300, "waiting_time": 0, "job": 194, "arrival": 4846, "duration": 1846, "violations": [] }, { "type": "job", "location": [ 25.27714, 54.684549 ], "id": 186, "setup": 0, "service": 300, "waiting_time": 0, "job": 186, "arrival": 5296, "duration": 1996, "violations": [] }, { "type": "job", "location": [ 25.276155, 54.687952 ], "id": 176, "setup": 0, "service": 300, "waiting_time": 0, "job": 176, "arrival": 5664, "duration": 2064, "violations": [] }, { "type": "end", "location": [ 25.272143, 54.709692 ], "setup": 0, "service": 0, "waiting_time": 0, "arrival": 6435, "duration": 2535, "violations": [] } ], "violations": [] } ] }

for it to divide the parcels so that the drivers work around the same time i need to set same time window for both drivers,
maybe there is another way to make it divide by around same time without setting time window for drivers , because if i set the time window to big it will divide the parcels to only one driver if i set it to small it will leave some parcels unassigned . maybe there is a work around solution ?

maybe there is another way to make it divide by around same time

No, time windows are the best way to handle this kind of time-related need. You may try other constraints (e.g. max_tasks) for some kind of balancing but this may not result in time balancing.

Unless i would fetch the total time to deliver then divide on the number of drivers something like that ? 🤔

Well, you may probably find ways to come up with good estimates for some constraint values that work in your situation. This kind of stuff can be highly use-case dependent.