Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Dears,
I'm wondering if CP-SAT as any built-in function that allow me to balance the number of tasks assigned to the users.
Now I'm calculating the variance and I'm minimizing it in the objective function, so it would be great to have the possibility to calculate the variance with a built-in function, but I'm wondering if I have alternatives.

Thanks

question from:https://stackoverflow.com/questions/65951668/cp-sat-to-balance-task-assignment

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

There are no alternative.

If the number of tasks and of workers is fixed. You can compute the average, and using an epsilon, add the following constraints:

for all workers:
  model.Add(sum(assigned_tasks) <= average + epsilon)
  model.Add(sum(assigned_tasks) >= average - epsilon)

model.Minimize(epsilon)

This is less precise, but much faster.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...