Set limit as a predefined scalar

Problems with syntax of GAMS
Post Reply
Dewan
User
User
Posts: 2
Joined: 5 months ago

Set limit as a predefined scalar

Post by Dewan » 5 months ago

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: 150
Joined: 1 year ago

Re: Set limit as a predefined scalar

Post by Renger » 5 months ago

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

Post Reply