Inner Assignment of Parameter
Posted: Wed Jul 11, 2018 11:34 pm
Hi All,
I wonder if there is an efficient way to assign values for part of the parameter.
For instance, I have a parameter with 64 values controlled by m. Then I have another parameter with 12 values controlled by n. Now I want to put the latter parameter within the former one. Specifically, I want the part of the former parameter which starts from 13th value and ends with 24th value, to be exactly the latter one. I have an idea for that.
It can surely work, but it is weird that I created a non-index iterator "I". GAMS grammar for loop is a bit uncomfortable that I cannot use overall assignment like MATLAB: Former[13:24] = Latter. I wonder if there is more efficient way in GAMS to do this. By the way, to the best of my knowledge, GAMS has poor data manipulation functionality... I hope it can be improved in the future.
Best,
Gabriel
I wonder if there is an efficient way to assign values for part of the parameter.
For instance, I have a parameter with 64 values controlled by m. Then I have another parameter with 12 values controlled by n. Now I want to put the latter parameter within the former one. Specifically, I want the part of the former parameter which starts from 13th value and ends with 24th value, to be exactly the latter one. I have an idea for that.
Code: Select all
Set b /1*64/
m /1*12/
Parameter Former(b), Latter(m);
* Give Latter some values
loop(m,
Latter(m) = ord(m);
);
scalar i /1/;
Loop(b$(ord(b)>=13 and ord(b)<=24),
Former(b) = sum(m$(ord(m)=i), Latter(m));
i = i+1;
);
display Former;
Best,
Gabriel