In a scheduling problem I want to assign the maximum number of tasks to one worker before assigning it to another. For example, if I have $10$ tasks and $2$ workers, the best assignment would be $(10, 0)$ and the worst $(5, 5)$.
I have tried the following ideas:
Iterative approach: assign tasks to each worker one by one with the objective of maximizing the number of assigned tasks. Didn't really work because there are constraints and objectives that take into account the other workers.
Maximize the sum of squares: $\sum(\text{number of tasks}^2)$, this way $(10, 0)$ has a score of $100$ and $(5, 5)$ a score of $50$.
I am going by the second approach but the solving speed drops quite a bit, not sure if it is because the problem is much more complex, or because it becomes quadratic.
Is there a better way to model this objective? Maybe something in terms of distance?
PS: The logic of my current OR-Tools code is something along the lines of this:
for w in workers:
worker_task_count[w] = model.NewIntVar(
0, number_tasks, f'{w}_task_count'
)
squared_count[w] = model.NewIntVar(
0, number_tasks**2, f'{w}_squared_task_count'
)
model.Add(
worker_task_count[w] == sum(
assigned_tasks[w, t]
for t in tasks
)
)
model.AddMultiplicationEquality(
squared_count[w],
[worker_task_count[w], worker_task_count[w]]
)
self.model.Add(objective == sum(squared_count.values()))