question

Patrick Zweekhorst avatar image
0 Likes"
Patrick Zweekhorst asked tannerp commented

Find token rank in batch

Hi,

What is the best way to assign a label to all tokens going out of a batch activity with as value their rank in the batch. So if 3 tokens go in the batch I want to have a new label on all 3 tokens with value 1, 2 and 3. I know I can make an array of all tokens going in the batch and get the index of the token in that array, but that feels a bit strange to just get the rank in the batch.

Are there any other options?
Thanks,

Patrick

FlexSim 20.0.0
batchrank
· 6
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

tannerp avatar image tannerp commented ·

Hi @Patrick Zweekhorst,

I'm not sure there's a better way than what you're already doing. Could you post an example of what you mentioned as your current method? The array of tokens going into the batch, etc. Where are you using the rank in the batch?

0 Likes 0 ·
Patrick Zweekhorst avatar image Patrick Zweekhorst tannerp commented ·

Hi @Tanner,

Attached is an example model. In the actual model I also need to assign some extra labels based on the rank/index in the batch. As example I made a label called SomeLabelBasedOnIndex. This method also works in my actual model. If there is no better option to do this it might be nice if an extra option could be added to the label aggregation option in the batch.

examplerankbatch.fsm

0 Likes 0 ·
tannerp avatar image tannerp Patrick Zweekhorst commented ·

I agree that this is a valuable tool as you've presented it. Perhaps it would be worth suggesting an idea that could be worked into future versions. For now, I think Jörg's method is the most concise.

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel commented ·

I have thought, that source code header of the function fields would contain a useful variable. It doesn’t. There is only another set of activities that does this. You batch 3 items into one. You add a label to the token that count the tokens. The next activity calls a subflow. This activity can easily assign the creation rank on the child tokens.
You can decide to write source code or add several activities.

0 Likes 0 ·
Patrick Zweekhorst avatar image Patrick Zweekhorst Joerg Vogel commented ·

Hi @Jörg Vogel,

Thank you for the reply but it is not really an option, I do want to keep the tokens that go in the batch. They have multiple labels that I also need in the rest of the flow. Only releasing 1 token out the batch is therefor no option

0 Likes 0 ·
Braydn T avatar image Braydn T Patrick Zweekhorst commented ·

@Patrick Zweekhorst

I played around with custom code and iterators for awhile, but I can't come up with a solution that is a simple as yours. If this is something you think would be very useful, maybe you could post an idea about it.

0 Likes 0 ·

1 Answer

Joerg Vogel avatar image
1 Like"
Joerg Vogel answered Patrick Zweekhorst commented

You don't need more activities, instead you add some source code to

# Tokens to Release

int index = batchQuantity;
while (index){
   batchedTokens[index].labels.assert("BatchRank",index);
   index--;
   }
return batchQuantity;

get-rank-batch-activity-tokens-by-code-index.fsm


· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Patrick Zweekhorst avatar image Patrick Zweekhorst commented ·

Hi @Jörg Vogel,

This is indeed also al nice option.
Thank you for your time

1 Like 1 ·