Generating random numbers in 2-dimensional table

Hi, I’m new to GAMS and stumbled upon a problem that I couldnt fix by
searching google or this groups’ discussions…

I am trying to create a simple model with random numbers for demand of
different products in several periods. For example, for product 1,
GAMS should generate different random numbers based on a uniform
distribution with lower bound = 10, upper bound =50 for each period t.

I thought it might look similar to this:

Sets
i set of products /13/
t set of time periods /1
10/;

table d(i,t) demand of product i in period t
1*10
1 uniform(10,50)
2 uniform(3, 25)
3 normal(35, 10) ;

But I get an error message because GAMS expects real numbers in the
table. How can I resolve this error?

Any help would be very much appreciated.

Peter

\

Hi ,
I’m also a new GAMS user, but try this out:


Sets
i set of products /13/
t set of time periods /1
10/;

execseed = gmillisec(jnow);

parameter p(t)
q(t)
o(t);
p(t) = uniform (10,50);
q(t) = uniform (3, 25);
o(t) = normal (35,10);


parameter d(i,t) ;

d(“1”,t) = p(t);
d(“2”,t) = q(t);
d(“3”,t) = o(t);

display d;



Ah, also when you are working with random numbers, it’s advisable to use the ‘execseed’ command.
For more information check out the gams user guide ( look for the ‘seed’ command).

Have a nice day,
Gonzalo.

2011/7/7 Peter

Hi, I’m new to GAMS and stumbled upon a problem that I couldnt fix by
searching google or this groups’ discussions…

I am trying to create a simple model with random numbers for demand of
different products in several periods. For example, for product 1,
GAMS should generate different random numbers based on a uniform
distribution with lower bound = 10, upper bound =50 for each period t.

I thought it might look similar to this:

Sets
i set of products /13/
t set of time periods /1
10/;

table d(i,t) demand of product i in period t
1*10
1 uniform(10,50)
2 uniform(3, 25)
3 normal(35, 10) ;

But I get an error message because GAMS expects real numbers in the
table. How can I resolve this error?

Any help would be very much appreciated.

Peter


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Peter,

An example code with comments is below.

-Steve

Sets
i set of products /i1i3/
t set of time periods /t1
t10/;

  • set the random seed to control results
    execseed = 525;
  • or set it to make results different
    execseed = gmillisec(jnow);

parameter d1(i,t);
d1(i,‘t1’) = uniform(10,50);
d1(i,‘t2’) = uniform(3, 25);
d1(i,‘t3’) = normal(35, 10);

  • you can put some functions into data statements using the syntax,
  • but not random number generating functions

table d2(i,t)
t1*t10
i1 [exp(1)]
i2 [pi]
i3 [sqrt(2)] ;


On Thu, Jul 7, 2011 at 2:42 PM, Peter wrote:

Hi, I’m new to GAMS and stumbled upon a problem that I couldnt fix by
searching google or this groups’ discussions…

I am trying to create a simple model with random numbers for demand of
different products in several periods. For example, for product 1,
GAMS should generate different random numbers based on a uniform
distribution with lower bound = 10, upper bound =50 for each period t.

I thought it might look similar to this:

Sets
i set of products /13/
t set of time periods /1
10/;

table d(i,t) demand of product i in period t
1*10
1 uniform(10,50)
2 uniform(3, 25)
3 normal(35, 10) ;

But I get an error message because GAMS expects real numbers in the
table. How can I resolve this error?

Any help would be very much appreciated.

Peter


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.




– Steven Dirkse, Ph.D. GAMS Development Corp., Washington DC Voice: (202)342-0180 Fax: (202)342-0181 sdirkse@gams.com http://www.gams.com