Parameter of different length

Problems with modeling
Post Reply
Hussain_TUT
User
User
Posts: 6
Joined: 1 year ago

Parameter of different length

Post by Hussain_TUT » 4 weeks ago

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

User avatar
Renger
Posts: 150
Joined: 1 year ago

Re: Parameter of different length

Post by Renger » 3 weeks ago

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

Post Reply