1

I have a constraint in my linear program for inventory that goes:

x[next period] = x[this period] + purchases[this period] - sold[this period]

Decision variables are purchases[this period] and sold[this period]. Solved for several periods with rolling horizon period.

When I put it in PuLP like this, all the x[t] other than the first (constant input, ex. 12345) end up to be 0.

T = range(0,7)
x = [0 for t in T]
x[0] = 12345

for t in T:
    prob += x[t] + p[t] - s[t] == x[t+1], "some label %s"(t)
    prob += x[t+1] >= 0

1 Answer 1

1

Solved it! For anyone who's interested in this...

I added it as a variable and added the following constraint prob += x[0] == 12345

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.