random arrays in a table

Problems with syntax of GAMS
Post Reply
Mo216
User
User
Posts: 2
Joined: 5 years ago

random arrays in a table

Post by Mo216 »

Hello everyone,
I know how to generate random data but I want to have a table which for each array I could have random values. and what what is the loop command to generate new values each iteration?
I really appreciate if you can help me with it.
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: random arrays in a table

Post by Renger »

Hi
Here is a small example with uniformly distributed random date

Code: Select all

set i /r1*r3/, j /c1*c3/, iter /1*3/;

parameter
    randval(i,j) Random values,
    randvalloop(iter, i,j) Store the random values;


* Set uniform random values between 1 and 10
* and set the seed so we can reproduce the results
$set seed 123456
loop(iter,
    randval(i, j) = uniform(1,10);
    randvalloop(Iter, i,j) = randval(i,j);
    );

* Check the results
display randvalloop;
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Mo216
User
User
Posts: 2
Joined: 5 years ago

Re: random arrays in a table

Post by Mo216 »

Thank you so much!
Post Reply