Hi,
I have the following code (not exact one)
set sh /1*50/
t /1*10/
;
Parameter
large (sh)
small(t);
I have two parameters of different length (large(sh) and small (t)). During simulation, large(sh) is assigned with some random values and i want to copy (for example) the middle 10 values from it and store it in small(t). Is it possible in GAMS if they have different dimensions?
Thanks
Parameter of different length
Re: Parameter of different length
Hi Hussain
This might be done in a while condition and a loop using as well as a condition on which values to assign to the small parameter.
I hope this gives you enough information, to find a solution for your specific problem.
Cheers
Renger
This might be done in a while condition and a loop using as well as a condition on which values to assign to the small parameter.
Code: Select all
set t /1*10/, sh /1*50/;
parameter
large(sh)
small(t);
large(sh) = uniform(0,1);
parameter
count /1/;
* Inititalize small, so if there are not enough values that fulfill the
* if-condition, we can spot this easily.
small(t) = EPS;
while(count <10,
loop(sh,
* Condition to single out the values from large(sh):
if(large(sh) < 0.3,
loop(t$(ord(t) eq count), small(t) = large(sh);
);
count = count + 1;
);
);
);
display small, large;
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Enjoy modeling even more: Read my blog on modeling at The lazy economist