Warehouse Problem with minimizing the net present value of the cost Topic is solved

Problems with modeling
Post Reply
Asadujjaman
User
User
Posts: 16
Joined: 4 years ago

Warehouse Problem with minimizing the net present value of the cost

Post by Asadujjaman »

I try to minimize the total net present value of the cost of a simple ware house problem.
But when I run the prblem with NLP, it shows an error "Dimension different - The symbol is referenced with more/less indices as declared".
Why this error and how can I solve the problem?

Set
t time /1*4/;
scalar i /0.01/;

parameter
SP(t) selling price
/
1 10
2 12
3 8
4 9
/;

parameter
IS(t) initial stock /1 50/ ;

Scalar
SC storing cost /1/
SCap store capacity /100/;

variable
buy(t)
sell(t)
stock(t)
TC;
positive variable buy, sell, stock;

equation
cost
inventory(t);

cost.. TC =e= sum[t, [{SP(t)*(buy(t)-sell(t))+SC*stock(t)}/((1+i)**t)]];
inventory(t)..stock(t) =e= stock(t-1)+buy(t)-sell(t)+IS(t);
stock.up(t) = Scap;

Model swp 'simple warehouse problem' / all /;
solve swp maximizing TC using nlp;
Fred
Posts: 373
Joined: 7 years ago

Re: Warehouse Problem with minimizing the net present value of the cost

Post by Fred »

Hi,

Problem is how you use set t at the end of equation

Code: Select all

cost.. TC =e= sum[t, [{SP(t)*(buy(t)-sell(t))+SC*stock(t)}/((1+i)**t)]];
While you use set elements 1,2,3,4, set elements can in general be strings (e.g. apple, orange, cherry, ...) which is why you cannot make calculations with set elements like this. There t is a set attribute (https://www.gams.com/latest/docs/UG_Set ... Attributes) .val though which allows you to use set elements that are numbers in calculations. The following should do the trick:

Code: Select all

cost.. TC =e= sum[t, [{SP(t)*(buy(t)-sell(t))+SC*stock(t)}/((1+i)**t.val)]];
I hope this helps!

Fred
Asadujjaman
User
User
Posts: 16
Joined: 4 years ago

Re: Warehouse Problem with minimizing the net present value of the cost

Post by Asadujjaman »

Hi Fred,

Thank you. The problem is solved now.

Regards
Asadujjaman
Post Reply