How to define multi-dimensional sets with assigning values Topic is solved

Problems with syntax of GAMS
Post Reply
Parisa
User
User
Posts: 12
Joined: 1 year ago

How to define multi-dimensional sets with assigning values

Post by Parisa » 3 weeks ago

Hello everybody,
I have the following CSV file, it is like an array with four entries "(i, s, t, f)", in which "i" is the indicator and "s, t, f" are its assigned values.
for this, I have written the next code.

Code: Select all

Sets
         i       /1*300/
         s       /0*23/
         t       /1*24/;
Sets
         x(i,s,t)
/
$ondelim
$include Pairs.csv
$offdelim
/;
But the code gives the result like this;
Image

This is not what I want since values are not accessible.
Thank you for your helps. :)
Pairs.csv
(4.26 KiB) Downloaded 7 times
Attachments
re.JPG

User avatar
bussieck
Moderator
Moderator
Posts: 465
Joined: 3 years ago

Re: How to define multi-dimensional sets with assigning values

Post by bussieck » 3 weeks ago

f is a numeric field, correct? You you need to store this in a parameter not a set:

Code: Select all

Parameter x(i,s,t)
/
$ondelim
$include Pairs.csv
$offdelim
/;
-Michael

Parisa
User
User
Posts: 12
Joined: 1 year ago

Re: How to define multi-dimensional sets with assigning values

Post by Parisa » 3 weeks ago

Thank you for your reply.
But if I define it as a parameter, then I cannot use syntaxes such as, "for" or "loop".
Moreover, Would you please give me some hints on How I can define a subset for multi-dimensional sets?

User avatar
bussieck
Moderator
Moderator
Posts: 465
Joined: 3 years ago

Re: How to define multi-dimensional sets with assigning values

Post by bussieck » 2 weeks ago

Why not? loop((i,s,t)$x(i,s,t), ...) iterates through the non-zero tuples of x. You can also create a dynamic set from x: set xset(i,s,t); xset(i,s,t) = x(i,s,t); You should invest more in understanding the principles of the language and study the documentation. Then things will be clearer.

-Michael


Post Reply