Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in input and output data #1157

Closed
AlirezaAzizi14 opened this issue Sep 16, 2024 · 3 comments
Closed

Problem in input and output data #1157

AlirezaAzizi14 opened this issue Sep 16, 2024 · 3 comments
Labels

Comments

@AlirezaAzizi14
Copy link

AlirezaAzizi14 commented Sep 16, 2024

Hi
I have an issue with the output using this input data. My problem is that I'm passing this data to the algorithm, but unfortunately, despite having 3 vehicles, all the jobs are being assigned to vehicle number 1. What do you think could be the cause of this problem?

input_data = {
"vehicles": [
{
"id":1,
"start_index":0,
"end_index":3,
"start":[2.35044, 48.71764],
"end":[2.35066, 48.71777]
},
{
"id":2,
"start_index":0,
"end_index":3,
"start":[3.35044, 49.71764],
"end":[3.35096, 49.71747]
},
{
"id":3,
"start_index":0,
"end_index":3,
"start":[1.35044, 47.71764],
"end":[1.35096, 47.71747]
}
],
"jobs": [
{
"id":1414,
"location_index":1,
"location": [1.98935, 47.701],
"priority":1
},
{
"id":1515,
"location_index":2,
"location": [2.03655, 48.61128],
"priority":2
},
{
"id":1616,
"location_index":3,
"location": [3.03655, 49.61128],
"priority":3
},
{
"id":1717,
"location_index":3,
"location": [4.03655, 50.61128],
"priority":0
},
{
"id":1818,
"location_index":3,
"location": [1.03655, 45.61128],
"priority":1
},{
"id":1919,
"location_index":3,
"location": [2.03655, 44.61128],
"priority":4
}
],
"matrices": {
"car": {
"durations": [
[0,2104,197,1299],
[2103,0,2255,3152],
[197,2256,0,1102],
[1299,3153,1102,0]
]
}
}
}

Output from Vroom :
{
"code": 0,
"summary": {
"cost": 5461,
"routes": 1,
"unassigned": 0,
"setup": 0,
"service": 0,
"duration": 5461,
"waiting_time": 0,
"priority": 11,
"distance": 2016365,
"violations": [],
"computing_times": {
"loading": 0,
"solving": 0,
"routing": 14
}
},
"unassigned": [],
"routes": [
{
"vehicle": 1,
"cost": 5461,
"setup": 0,
"service": 0,
"duration": 5461,
"waiting_time": 0,
"priority": 11,
"distance": 2016365,
"steps": [
{
"type": "start",
"location": [
2.35044,
48.71764
],
"location_index": 0,
"setup": 0,
"service": 0,
"waiting_time": 0,
"arrival": 0,
"duration": 0,
"violations": [],
"distance": 0
},
{
"type": "job",
"location": [
1.98935,
47.701
],
"location_index": 1,
"id": 1414,
"setup": 0,
"service": 0,
"waiting_time": 0,
"job": 1414,
"arrival": 2104,
"duration": 2104,
"violations": [],
"distance": 144015
},
{
"type": "job",
"location": [
2.03655,
48.61128
],
"location_index": 2,
"id": 1515,
"setup": 0,
"service": 0,
"waiting_time": 0,
"job": 1515,
"arrival": 4359,
"duration": 4359,
"violations": [],
"distance": 261059
},
{
"type": "job",
"location": [
2.03655,
44.61128
],
"location_index": 3,
"id": 1919,
"setup": 0,
"service": 0,
"waiting_time": 0,
"job": 1919,
"arrival": 5461,
"duration": 5461,
"violations": [],
"distance": 799000
},
{
"type": "job",
"location": [
1.03655,
45.61128
],
"location_index": 3,
"id": 1818,
"setup": 0,
"service": 0,
"waiting_time": 0,
"job": 1818,
"arrival": 5461,
"duration": 5461,
"violations": [],
"distance": 1006395
},
{
"type": "job",
"location": [
4.03655,
50.61128
],
"location_index": 3,
"id": 1717,
"setup": 0,
"service": 0,
"waiting_time": 0,
"job": 1717,
"arrival": 5461,
"duration": 5461,
"violations": [],
"distance": 1699383
},
{
"type": "job",
"location": [
3.03655,
49.61128
],
"location_index": 3,
"id": 1616,
"setup": 0,
"service": 0,
"waiting_time": 0,
"job": 1616,
"arrival": 5461,
"duration": 5461,
"violations": [],
"distance": 1884711
},
{
"type": "end",
"location": [
2.35066,
48.71777
],
"location_index": 3,
"setup": 0,
"service": 0,
"waiting_time": 0,
"arrival": 5461,
"duration": 5461,
"violations": [],
"distance": 2016365
}
],
"violations": [],

@jcoupey
Copy link
Collaborator

jcoupey commented Sep 16, 2024

The purpose of route optimization is to minimize the cost of serving all jobs. In your example, doing everything with a single vehicle is overall cheaper, so this is the expected solution.

In general, if not all jobs can be served by a single vehicle, then it means there are underlying business constraints: capacity, timing etc. You have to take those into account in order to improve the model and have the solutions match your workflow.

@AlirezaAzizi14
Copy link
Author

How should I apply a constraint?
I want the constraint to be such that no courier is assigned more than 5 orders.
How can I implement this?

@jcoupey
Copy link
Collaborator

jcoupey commented Sep 16, 2024

How should I apply a constraint?

First by looking up existing options in the docs: https://github.com/VROOM-Project/vroom/blob/master/docs/API.md#input.

no courier is assigned more than 5 orders.

That is supported, please refer to the vehicle object documentation.

@jcoupey jcoupey closed this as completed Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants