Set limit as a predefined scalar

Problems with syntax of GAMS
Post Reply
Dewan
User
User
Posts: 2
Joined: 6 years ago

Set limit as a predefined scalar

Post by Dewan »

Hi,
I was trying to use a predefined scalar as the set's upper limit. I wrote the following code:

Code: Select all

SCALAR   N       number of vertices      /5/;
SET
         i       vertex index    /1*N/
I am getting following error:

Code: Select all

Error 764 in C:\[dir]
Could not extract number in <element> * <element> list
Can anyone please help me to fix this issue.
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Set limit as a predefined scalar

Post by Renger »

Hi

For this you can use the $setlocal or $setglobal command which allows you to run your code with different values:
$setlocal n 5

SET
i vertex index /1*%n%/;

display i;
Now you can easily change this value by setting this parameter as an option:
gams mymodel --n=19

This will override n and use 19 instead of 5.

This can also be done in the Gamside
Image

Cheers

Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Post Reply