Thank you very much Michael,
It solved my problem. I appreciate your help.
Majid
On Mon, Sep 29, 2014 at 10:11 AM, Michael Bussieck wrote:
For this you can use what Renger suggested to work with the seed for the random number generator:
set n / n1*n4 /;
parameter a(n), b(n);
execseed = 12345689;
a(n) = uniformInt(1,10);
execseed = 123456;
b(n) = uniformInt(1,10);
option a:0:0:1, b:0:0:1; display a, b;
Independent of n we start filling a and b always with the same sequence of random numbers. For the two dimensional parameters you need to combine this with my previous solutions. Here is the output for a and b for card(n)=3 and card(n)=4:
card(n)=3:
---- 8 PARAMETER a
n1 4, n2 1, n3 9
---- 8 PARAMETER b
n1 1, n2 7, n3 5
card(n)=4:
---- 8 PARAMETER a
n1 4, n2 1, n3 9, n4 9
---- 8 PARAMETER b
n1 1, n2 7, n3 5, n4 8
Hope this helps,
Michael Bussieck - GAMSWorld Coordinator
On Monday, September 29, 2014 10:01:40 AM UTC-4, Majid wrote:
Hi Michael,
Many thanks for your valuable response. It addressed my problem to some extend, but I still have the following issue.
My problem is designed on a network (i,j) and the whole network is designed on a scenario tree with index n. Therefore, I have some parameters on i, some on (i,j), some on (n,i), and some on (n,i,j). I want to solve the same network problem on different scenarios. So, my problem will grow only in dimension “n”.
The problem is that when I change n, lets say from 3 to 4, even those parameters that are independent from n will change. For example, I have a C(i) parameter, and when I change n, I get different values for that. Can I force GAMS to fix my C(i) in all runs, independent of the value of n?
I appreciate your help.
Majid
On Mon, Sep 29, 2014 at 4:48 AM, Michael Bussieck wrote:
Majid,
When you assign a parameter “a(i,j) = uniformInt(1,10);” it will fill the matrix row by row. The random number generator produces the same sequence of numbers but what you do with them (e.g. where you place) them is your business. In your example GAMS generates the sequence 1,3,1,2,4,6,2,1,7 also in the second examples this is the case (just follow the numbers row by row). If you would just add new columns all the time you could force GAMS to fill you matrix column by column:
set i /i1i3/, j /j1j4/;
- Fills row by row:
- a(i,j) = uniformInt(1,10);
- Fills column by column:
loop((j,i), a(i,j) = uniformInt(1,10));
If you want to “grow” your model in row and column dimension, things get a little more tricky. The following GAMS program shows you how to do that. You need to fill your new matrix based on your previous dimensions. Please experiment with the code by (un-)commenting the lines in the iSeq table:
set seq /13/, i / i1i5 /, j / j1j6 /, ij(i,j);
set iSeq(seq,i,j) /
1.(i1i3).(j1*j3)
- 2.(i1i3).(j1j4)
- 3.(i1i5).(j1j6)
/;
Set ijSeq(i,j); Parameter aRand(i,j);
ij(i,j) = no;
loop(seq,
ijSeq(i,j) = iSeq(seq,i,j) and not ij(i,j);
aRand(ijSeq) = uniformInt(1,10);
ij(ijSeq) = yes);
option aRand:0:1:1; display aRand;
Hope this helps,
Michael Bussieck - GAMSWorld Coordinator
On Friday, September 26, 2014 4:05:16 PM UTC-4, Majid wrote:
Hi,
Hope you are doing well.
I would appreciate if any of you can help me with the following issue:
I have a model and for its parameters, I randomly generate data. i do not update the seeds, so when i run it multiple times, I get the same numbers. Now, I have to increase the size of the problem, and for this new problem, I would like to keep the same parameters, and add some new data. For example, I have a 3X3 matrix:
1 3 1
2 4 6
2 1 7
Now, for the larger problem, I have a 3X4 matrix and I want the fist 3 column be the same as before, and the last column being generated randomly:
1 3 1 2
2 4 6 4
2 1 7 5
Do you know any way that I can force GAMS not to change the random data in different runs, even if there is a change in the model?
Thanks for your help.
Majid
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.