question

Maryam H2 avatar image
0 Likes"
Maryam H2 asked Maryam H2 commented

counting subnodes with a specific label

How can I determine the number of subnodes on a processor that have a specific label? For instance, assume some subnodes are labeled "A" while others are labeled "B". How I can refer to the quantity of each in the pull from list?


1708472490784.png

FlexSim 24.0.1
list pullsubnodessubnode.length
1708472490784.png (33.2 KiB)
5 |100000

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

1 Answer

·
Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Maryam H2 commented

You'd usually test the value of the label not that it exists:

Table.query("SELECT count($2) FROM $1 WHERE $2.Type='A'",token.csb,$iter(1))[1][1]

Label names should reflect the name of a category not the value that needs to be written on it.


· 4
5 |100000

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

Maryam H2 avatar image Maryam H2 commented ·

@Jason Lightfoot that code does not work in the "Request/Require Number" section of a Pull from List activity (please see the picture above in previous post).

I know this one works: token.csb.subnodes.length (token.csb is the processor object) but I want to refer to specific item on the processor and the length of that item so referring to length of subnodes with specific label such color or name on them. How I can do that?

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Maryam H2 commented ·

Jason's expression directly returns the number of subnodes whose "Type" label has a value of "A" without the need for a list. So you could put it into the Value field of an "Assign Labels" activity for example.

And just so there is no misunderstanding: "length" is the number of entries in an array. If you want to query the size of objects you'd use "object.size.x/y/z".

                     
  1. Table.query("SELECT SUM($2.size.x) FROM $1 WHERE $2.Type='A'",token.csb,$iter(1))[1][1]

This would return the total size along the x-axis of all items with type A on the processor.

1 Like 1 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Maryam H2 commented ·

What makes you think it doesn't work? Here's a working example.

PullQtyMatchingItemLabels.fsm

0 Likes 0 ·
Maryam H2 avatar image Maryam H2 Jason Lightfoot ♦ commented ·

@Jason Lightfoot @Felix Möhlmann you're correct, I made a mistake in writing the query. Thanks!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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