I have a model that describes the optimal relocations of stock in a situation where the total inventory is sometimes larger than the in-house warehouse capacity. I defined the set 'products' and 'flows' with indices (respectively) i and j. The decision variable(Xij) is the (integer) amount of products to assign to each flow, minimizing the cost involved.
I am currently struggling with implementing one of the constraints: for each i in flow j=3, the value of Xi3 should be some integer (say 0 to 10) times the flowcapacity (=45). After some searching on this forum, I figured I should try adding a parameter Flowcapacity(j), make Flowcapacity(3)=45 and all other Flowcapacity(j=/=3)=0. Then, in the constraint, include an if statement: "if Flowcapacity(j)>0 then X(ij)=Flowcapacity(j)*{0,1,2,3,4,5,6,7,8,9,10}".
The program seems to accept the reference to the parameter, but not the subset of integers (which was a long shot). How should I formulate this constraint?
Page 1 / 1
Create another variable IV with range as integers {0..10}.
Now modify your original constraint as
if Flowcapacity(j) >0 then X(ij) = FlowCapacity(j) * IV endif
IV will take one of the integer values as you want.
Hi @StudentWouter just checking if this worked for you, or maybe you found another way? Please let us know how it worked out in case others have a similar problem. Thanks!
Reply
Sign up
Already have an account? Login
Please use your business or academic e-mail address to register
Login to the community
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.