# Constraint equivalence in PuLP

I'm working on an optimization problem in PuLP and I have to enforce a daily minimum of shifts and a daily maximum of assigned shifts. I have the following constraints to ensure each day has a minimum and maximum of employees assigned on day shifts and night shifts ($$D_{i,j}$$ and $$N_{i,j}$$).

for j in days:
m += lpSum(D[(i, j)] for i in employees) >= b_d
m += lpSum(D[(i, j)] for i in employees) <= b_d_max
m += lpSum(N[(i, j)] for i in employees) >= b_n
m += lpSum(N[(i, j)] for i in employees) <= b_n_max


I tried to write both these constraints in a single line as follows:

for j in days:
m += b_d <= lpSum(D[(i, j)] for i in employees) <= b_d_max
m += b_n <= lpSum(N[(i, j)] for i in employees) <= b_n_max


However, the lower limit is not enforced now. Am I doing something wrong or is it just not possible to write the constraints like this in a single line?

• As far as I know its not possible, you need one line per symbol (<=,==,>=). May 6 '20 at 13:01