Loop

Hi,
I am working in power distribution side. In my GAMS code , I have multiply cost with PRESENT WORTH FACTOR [1/((1+r)**Y)] , where r=0.03 and “Y” is number of years. Now I want my GAMS code to print value for 5 years . It is like this…
COST(Y)*[1/((1+r)**Y)] . I can not get incremental value for every year and display it for every year.
Can anybody help me in this loop

Hi

It is not completely clear what you want (it is better to add some code you have already available).

Here some code to get every fifth element of a y as a subset by defining a subset y5(y). You define this dynamic set without assigning any values of y to it. This is done using the $-operator and the mod function:

set y years /2015*2050/
      y5(y)   every fifth year;
      
y5(y)$(mod(ord(y) - 1,5)=0) = YES;

display y5;

Cheers
Renger

Hi,

Thank you very much for your reply Sir,

My Code is like this
eq3… Netcost=e=(costAC+costDC);
eq4… PW=e=1/(1+r)**y;
eq5… CostY1=e=NetcostPW;
eq6… CostY2=e=CostY1
PW;
eq7… CostY3=e=CostY2*PW;

I want to make a loop that will increment year (y) value and calculate cost for the next year and then display it, A loop that give me Cost for each year from Y1 to Y5,

Thanks

Hi
If you want to loop over y, you should have indexed parameters, variables and equations. I think you should first sit down and derive mathematically what you want to do and then start from there: write down your model with model definition, solve statement, and have a good look at how to write indexed parameters, variables and equations.

CHeers
Renger