For a work shift optimization problem, I've defined a binary variable in PuLP as follows:
pulp.LpVariable.dicts('VAR', (range(D), range(N)), 0, 1, 'Binary')
where
- $D =$ # days in each schedule we create (= 28, or 4 weeks)
- $N =$ # of workers
and the variable $VAR$ represents whether worker $J$ works in Day $I$ or not.
I want to ensure that work is evenly distributed over the 28 days (a.k.a $VAR$ for worker $J$ should look more like [1,0,0,0,1,0,0,0,0,1,...,var[i=27][J]] rather than [1,1,1,0,0,0,0,0,...,var[i=27][J]] where work is clustered in the beginning). Since I can't add if statements/access the values of variables before they are defined, an approach where we minimize the range in days between work shifts doesn't seem feasible (since the work shifts themselves haven't been allocated yet). What could be a way to model this optimization problem?