Modeling starting and end inventory constraints Topic is solved

Problems with syntax of GAMS
Post Reply
San
User
User
Posts: 2
Joined: 3 years ago

Modeling starting and end inventory constraints

Post by San »

Hello,

In a product mix problem (with multiple products, over a period of time) that I am trying to solve there is a constraint w.r.t inventory where starting inventory is 0 for all the products, but at the end of n month period, the closing inventory should be equal to 200 for all the products. Also in each month (from 1 to n-1) the maximum inventory should be less than or equal to 100 w.r.t each product. I write the code in GAMS as below but ended up in an infeasible solution. Can you give me some suggestions on how to fix this or how these constraints can be written in a better/correct way. Thank you

Code: Select all

*I(i,j) - inventory of product i month j
*P(i,j) - qty of product i month j

*demand balancing from month 2-12 
d2(i,j)$((ord(j) > 1) and (ord(j) < 12)).. I(i,j-1) + P(i,j) - I(i,j) =e= D(i,j) ; 

*demand balancing for month one
d1(i,j)$(ord(j) < 2) .. P(i,j) -  I(i,j) =e= D(i,j) ; 

*demand balancing for month 12
d12(i,j)$(ord(j) > 11) .. I(i,j-1) + P(i,j) - I(i,j) =e= D(i,j);

*max inventory constraint 1-12
IN(i,j)$((ord(j) < 12)) .. I(i,j) =l= 100; 

*closing inventory
IC(i,j)$(ord(j) > 11) .. I(i,j) =e= 200; 

abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Modeling starting and end inventory constraints

Post by abhosekar »

I notice that constraints d2 and d12 are identical (apart from the $ condition) . Is this what you intended?

The constraint d2 might be getting violated in the final period if your model cannot make product inventory to 200. It depends on the values of D and P. Are D and P both variables/parameters?

I would try removing the constraint that fixed final inventory to 200 and see if I get a feasible solution.


Assuming it is correct, your constraints can be cleaned up significantly:
You can replace constraints d2, d1, d12 by just one constraint:

I(i,j-1)$(ord(j) ne 1) + P(i,j) - I(i,j) =e= D(i,j) ;

This way the first term will be added for all periods except the first period.

use .up and .lo for upper and lower bounds, .fx for fixing variables and get rid of constraints IN and IC

I.up(i, j) $(ord(j) ne 12) = 100;
I.fx(i, j) $(ord(j) eq 12) = 200;

- Atharv
San
User
User
Posts: 2
Joined: 3 years ago

Re: Modeling starting and end inventory constraints

Post by San »

Thank you very much! This was very helpful.
Post Reply