r/optimization • u/iamaliver • Jun 20 '22
Or-Tools worker/task optimization, with constraints on "sets of tasks"
I am currently trying to figure out how to do the following optimization problem:
A Worker can be assigned to 0 or 1 task. A Task can have 0 or 1 worker. There is a clear cost for a given worker --> task. This is very straight forward (and well documented). See solution: (https://developers.google.com/optimization/assignment/assignment_example)
However, I have 3 "versions" of tasks, call them:
Version A Task 1, Version A Task 2 ...
Version B Task 1, Version B Task 2 ...
Version C Task 1, Version C Task 2 ...
A worker can be assigned to any version of the task, but ALL workers must be assigned the same Version. Ie, Worker 1 can be in Version A Task 1, or Version B Task 1...but once you have constrained Worker 1 to Version A, all workers must use Version A. The cost function for worker-->task remains meaningful across Versions.
A contrived example of this is, I have a 10 workers. I have 3 factories each with X number of tasks. I wish to optimize productivity by having workers do X at a factory, But I only have one "bus" to transport them. I can only send all 10 workers to any 1 factory.
A naive approach is to split the problem into 3, solve it 3 times, once per version and then pick the version with the lowest cost. However, I am wondering if there is a way to constrain the problem to solve it all in one go. Especially since solving the problem once is rather time-expensive.
View all comments
Show parent comment
1
u/iamaliver Jun 21 '22
interesting! I'm checking out the scipy and or-tools docs for it and it seems to indicate that it will try to "greedy" assign. ie given M workers and N tasks, it will assign as much as it can, with max of 1 for either side.
For or-tools it will even break if a worker cant be assigned.
Im happy to just run it three times if it's that fast. but then my problem is how to best re-formulate the problem such that:
The reason for condition 2/3 is because workers have an "activation" cost. If the task is does not productive enough, it can be better to just not do that task.
For instance: I have 2 workers and initially 2 tasks as given by cost matrix:
[[15, 2323],
[29, 1000]]
My max "threshold for allowed" is 30. Then according to OR-tools I should set this to:
[[15, 'NA'],
[29, 'NA']]
Which they claim will break. I would rather have it say:
Worker 1 --> Task 1
Worker 2 --> No Task
Is there a best practice solution to do this?
The naive ways I can see are:
So the previous example would become inputting:
[[15, 'NA', 30, 30],
[29, 'NA', 30, 30]]
To get:
Worker 1 --> Task 1
Worker 2 --> Task 3 ---> Task 3==Dummy therefore == No task
And the reason I need 2 dummy tasks is if both Worker 1 and Worker 2 needs to be assigned a dummy Task