if statement - If Function in GAMS -


i've been busy model, i'm uncomfortable result because think gams violates constraint. want tell gams is:

"check demand first -> check current stocks -> if there enough stocks sell current stocks -> if there not enough stocks first buy (produce) sell."

i think in model gams not obey demand (sell), minimum values , sells without buying any.

the model hereinbelow:

sets  items /s,p,b/ t  time in quarters /1,2,3/  parameters price(i)       selling price per unit per quarter in euros /s 6.34, p 6.46, b 5.93/ inistock(i)    initial stock in units /s 320000, p 296199, b 104208/ cap(i)         capacity limit each unit /s 400000, p 350000, b 150000/ c              cost of holding 1 unit of /s 10, p 15, b 12/  scalars tcap           total capacity of warehouse /650000/  variables stock(i,t)     stock stored @ time t sell(i,t)      stock sold @ time t buy(i,t)       stock bought @ time t cost           total cost  positive variables stock,sell,buy  equations cst            total cost occurs stck(i,t)      stock balance of unit @ time t;  cst..         cost=e=sum((i,t),price(i)*(buy(i,t)-sell(i,t))+c(i)*stock(i,t)); stck(i,t)..   stock(i,t)=e=inistock(i)+stock(i,t-1)+buy(i,t)-sell(i,t); stck.up(i,t)=tcap;  option lp=cplex ;  option optcr=0;  model twh warehouse problem / /;  solve twh minimizing cost using lp; 

thank in advance support!

you haven't set demand constraints, , minimum values 0 bounds defining variables being positive.

what other constraint did expect gams obey?

selling correct solution problem have defined.

i think part mistake:

stck.up(i,t)=tcap; 

you meant write 'stock' rather 'stck'. if lower bound (writing 'lo' instead of 'up'), have problem non-trivial solution, adding constraint warehouse should filled maximum capacity.


Comments