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

Problems with syntax of GAMS
Post Reply
Parisa
User
User
Posts: 14
Joined: 5 years ago

How to define multi-dimensional sets with assigning values

Post by Parisa »

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 207 times
Attachments
re.JPG
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

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

Post by bussieck »

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: 14
Joined: 5 years ago

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

Post by Parisa »

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: 1033
Joined: 7 years ago

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

Post by bussieck »

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
Parisa
User
User
Posts: 14
Joined: 5 years ago

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

Post by Parisa »

Thank you.
Post Reply