I have a dynamic set “iter” that defines the parameter blend(iter). I would like to take the last value from the blend(iter) when the iter might increase as the simulation goes along.
I know that if we have a deterministic set iter=15, its easy to call blend(‘15’). But since iter is changing, I am not sure what is the best way to do. I am looking forward to any good idea of doing that.
Thanks for the answer. Maybe I should put it more clear about “dynamic”.
The set “iter” is defined firstly with 15 different numbers /1*15/. So the card(iter) is always 15. But the parameter blend(iter) is dynamic and start to fill the space one by one, while the rest blend(iter) could be 0.
How can I pinpoint the last item that is not zero?
I think of one way:
alias (iter,iter2)
blend(iter)$(ord(iter) eq sum(iter2$blend(iter2),1))
Thanks for the answer. Maybe I should put it more clear about “dynamic”.
The set “iter” is defined firstly with 15 different numbers /1*15/. So the card(iter) is always 15. But the parameter blend(iter) is dynamic and start to fill the space one by one, while the rest blend(iter) could be 0.
How can I pinpoint the last item that is not zero?
I think of one way:
alias (iter,iter2)
blend(iter)$(ord(iter) eq sum(iter2$blend(iter2),1))
set iter / 1*15 /;
parameter blend(iter);
blend(iter)$(uniform(0,1)<0.1) = uniformInt(1,10);
* Find the last iter in blend<>0:
set sblend(iter) 'set of non-zeros in blend'; sblend(iter) = blend(iter);
singleton set lastIter(iter);
lastIter(sblend) = sblend.last
display lastIter;
I also used a singleton set for lastIter. This has the advantage that you can use it without controlling the index, like in “scalar lastBlendValue; lastBlendValue = blend(lastIter);” which might be in handy in your case.