Page 1 of 1

Parameter of different length

Posted: Mon Jun 18, 2018 4:21 pm
by Hussain_TUT
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

Re: Parameter of different length

Posted: Wed Jun 20, 2018 7:10 am
by Renger
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.

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;
I hope this gives you enough information, to find a solution for your specific problem.
Cheers
Renger