I am trying to use the pulb libraries classes to solve a LP-Problem. I am having problems implementing the constraint into my code.
After importing the relevant classes and reading from my CSV file I wrote:
prob = pulp.LpProblem("Optimal Number of Bank Tellers", pulp.LpMinimize)
x = pulp.LpVariable("Number of Tellers", lowBound = 0, cat='Integer')
prob += x * (16*4 + 14*4)/8 , "Total Cost of Labor"
for i in [28, 35, 21, 46, 32, 14, 24, 32]:
prob += i / x <= 1/8, "Service Level Constraint for Time Slot {}".format(i)
prob.solve()
Unfortunately I don't quite understand why I get the error message, that 'int' and 'LpVariable' are an unsupported operand type.
How would I correctly model my constraint otherwise? What exactly did I do wrong here?
i / x <= 1/8
is obviously nonlinear. PuLP is only for linear models. Of course, you could write:
i <= x * (1/8)
which makes this linear.
Actually, there is no need to generate all these constraints. We can do with just one:
x >= 8*max([28, 35, 21, 46, 32, 14, 24, 32])
Finally, it is slightly better to specify this as a lower bound on x directly.