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

Favorize some vehicles over others for some jobs #393

Closed
romainrey opened this issue Sep 21, 2020 · 5 comments
Closed

Favorize some vehicles over others for some jobs #393

romainrey opened this issue Sep 21, 2020 · 5 comments

Comments

@romainrey
Copy link

Hi,

I am running into a case where some vehicles have some relations with some of the jobs.
Let's say that I have commercial sellers that are used to work with the clients of their zone.
I want to put an incentive for the commercial of the zone to go to his clients instead of the clients of the other commercial.
Skills does not work because it would be forcing him to go to his, while the idea here is more a penalization than a hard constrain. Indeed some time a commercial can go see the client of his colleague if his colleague has much more work than him.

What could work would be to allow priorities of jobs to be dependent of the vehicles. So for each job instead of having a unique priority it would have n priorities with n being the number of vehicles.
What do you think, is there any other workaround?

Ps:
I am already using priorities to incentive on urgency of the job. So my idea was to do priority -> priority + 2 if it is the commercial that knows the client.

Thanks!

@jcoupey
Copy link
Collaborator

jcoupey commented Sep 22, 2020

Adding this kind of soft constraint/penalization is something that usually is in conflict with the current solving approach and the way we set the optimization objective(s). See #263 for some background and discussions.

In this specific case, the whole notion of priority is currently handled as a "forefront" optimization objective, overall travel time being a secondary objective. In this prospect, I think the approach you describe would work for your special use-case.

On the other hand, I'm a bit circumspect at first on setting vehicle-dependant job priorities. First it would require to input much more data with a probably less intuitive API, then I'm not sure how we'd mix this with other ideas such as #359.

@romainrey if you want to go ahead and experiment with this idea, getting a minimal implementation to work would be quite straightforward because there are not that many places in the codebase where we deal with priorities. I can provide pointers if needed.

@romainrey
Copy link
Author

Hi Julien, Thanks for your quick answer, as usual!

Also another use case in addition to the one I was describing is if you are planning a full week at the same time and the urgency of some job is different if they are done the Monday or the Friday. You could represent day and vehicle as a couple vehicle-day and then the priority would be specific for this pair, which would help solve the problem of the urgency of a job that changes.

On the input data, yes but you could say that now for a job priority has to be a dict (vehicle1:priority1, ...) or an array if you assume knowing the order of the vehicles. But you could still let the possibility to only put an integer, and inside the function if it is only an integer then you just create the array yourself by replicating the integer. So that would not complexify the usage for those who don't want to use that option. For the others, I think that it is a very small cost for them for something that solve their problem.
Or another more efficient option could be to add an option that takes a matrix as input. With rows = jobs, columns = vehicles and values = priorities. So same thing that would not change the input for those who want to use the normal version but allow it for those you want.

Also I could see 359 and this one merged as the priority of a vehicle could be handle by changing his priorities in all job.
So just to illustrate if I have job1 and job2, and vehicle1 and 2 with vehicle being higher priority then the priorities would look like:
job1.priority = {'vehicle1' : 2, 'vehicle2':1}
job2.priority = {'vehicle1' : 2, 'vehicle2':1}
And that should work

Anyways I also understand that as you mentioned in 263, there is tons of possible ways you could go for the development, and you have to pick the ideas that are coherent with the direction your are going to and which are popular, and that's perfectly fine especially given that you are maintaining that alone which is already very impressive.
I would be happy to give it a try if you can point me to some of the logic I might need to have a look!

@jcoupey
Copy link
Collaborator

jcoupey commented Sep 22, 2020

Running grep -rn priority from the src folder should provide a comprehensive list of places you may have to change stuff.

The outline of a POC work would be:

  1. Adjust the job object model to store vehicle-dependent priorities (happens in structures/vroom/job.{h,cpp})
  2. Adapt the parsing steps to get the new data in input (happens in utils/input_parser.cpp)
  3. Replace all priority member values access by a vehicle-dependent version based on context (happens in utils/helpers.h and algorithms/local_search/local_search.cpp)

Happy to have any feedback if you give it a go.

@romainrey
Copy link
Author

Hey I have been working on the feature this week, it looks to work for me, probably still needs some validation from you to see if the modifications made make sense!

@jcoupey
Copy link
Collaborator

jcoupey commented Oct 22, 2021

Closing, see #396 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants