Michael
Michael

Reputation: 575

Use a macro instead of a loop for faster execution in GAMS?

Consider the following code:

set t               / 1 * 300000 /;
parameter pop(t)    / 1 3456 /
          growth(t) ;

growth(t) = 25;

loop(t,

   pop(t+1) = pop(t) + growth(t);
   
);

This takes pretty much time for GAMS to run. Instead of using loop, is it possible to use macro instead to make the execution faster?

I have tried with:

$macro mymacro(t)  \
& pop(&t+1) = pop(&t) + growth(&t);

mymacro(t);

The problem is that, it does not use the loop. I have also tried with:

mymacro("1");
mymacro("2");
...
mymacro("300000");

But it gives an error.

Upvotes: 0

Views: 28

Answers (0)

Related Questions