Maximize the spread of all nurses in Scheduling

Viewed 163
    model.Maximize(
        sum(shift_requests[n][d] * shifts[( n, d)] for n in all_nurses
            for d in all_days))

Curious how I could change the above (which is optimizing for shift requests) to the below, which would optimize for the spread. I'm trying to actually spread out the assignments as much as possible. Thoughts?

    model.Maximize(
        np.std(shifts[( n, d)] for n in all_nurses
            for d in all_days))
1 Answers

You can try the following

You have a list of Booleans: b(i) means mean span between 2 working days is greater or equal than i

  1. you need to ensure consistency between b(i) variables: b(i) => b(i-1)

  2. if nurse n is working on day d, and b(i) is true, then work[n, d + i - 1] is false. Encoded as model.AddBoolOr(work[n, d].Not(), b(i).Not(), work[n, d + i - 1].Not()] for all the relevant n, d, i.

  3. maximize i where b(i) is true. A crude solution would be just model.Maximize(sum(b(i))). Maybe this can be improved.

Related