I am trying to create a constraint in Pulp where we make use of a maximum timespan for the scheduled activities that a psychologist needs to perform. For this problem, I constructed 5 different variables for 5 different activities (activity A, B, C, D and E) with indexes p for psychologist and d for day:
A[(p,d)] for p in psychologists for d in days
B[(p,d)] for p in psychologists for d in days
C[(p,d)] for p in psychologists for d in days
D[(p,d)] for p in psychologists for d in days
E[(p,d)] for p in psychologists for d in days
I want the timespan for activity A + activity B to be completed within 2 days and the timespan for activity A + activity B + activity C + activity D + activity E should be completed within 14 days.
I tried to use precedence variables as follows:
Ad = lpSum(d*A[(m,d)] for p in psychologists for d in days)
Bd = lpSum(d*B[(m,d)] for p in psychologists for d in days)
Cd = lpSum(d*C[(m,d)] for p in psychologists for d in days)
Dd = lpSum(d*D[(m,d)] for p in psychologists for d in days)
Ed = lpSum(d*E[(m,d)] for p in psychologists for d in days)
schedule += Ad + Bd <= 2
schedule += Ad + Bd + Cd + Dd + Ed <= 14
However, this does not seem to work in Pulp.
Could anyone help me with my time-indexed problem?