question

Alejandro M16 avatar image
0 Likes"
Alejandro M16 asked Ben Wilson commented

How to label by percentages?

Hello. I need help with labels. 

The source sends matching boxes, this is fine. 

The problem is that I have to tag in a queue. 

I must label 10%. 

10% are scrap and the other 90% are good boxes. 

Then I must separate good pieces and scrap.

V18.05.14.2021.fsm

Thanks for the help!
FlexSim 21.1.1
flexsim 21.1.1any other version
captura.png (146.2 KiB)
v1805142021.fsm (27.6 KiB)
· 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.

Ben Wilson avatar image Ben Wilson ♦♦ commented ·

Hi @Alejandro M16, was Jörg Vogel's or Eric M's or Julio R's answer helpful? If so, please click the red "Accept" button at the bottom of one of their answers. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·
Eric M avatar image
0 Likes"
Eric M answered

He @Alejandro M16, you can set labels on flow items using triggers. So either on the source or the queue (either way would work), choose a trigger for when to set the label (on creation, on entry, on exit, etc.) and then select "set label by percentage" as seen in this image:

Then you can set up your label name and percentage distribution. In this case, the item will get a label called Type. 90% will have a value of 1 and 10% will have a value of 2:

Now that the items have a label, you can click on the queue and choose "port by case" for the output. This will send items of Type = 1 to Port 1 of the Queue and the same for Port 2 (where the ports have to do with the A-connections you drew connecting the ports):


1621022539541.png (22.7 KiB)
1621022643924.png (12.2 KiB)
1621022750481.png (10.5 KiB)
1621022812755.png (13.6 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.

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Joerg Vogel edited

I think the attributes “scrap” and “good” are not perfectly good for your purpose. It is your aim to separate a flow of items. As previously suggested you can divert 10% directly to an output port and 90% to another port. Or you can assert a label tag, previously called as Type and set 10% to a number value of 1 and 90% to value 2. Both variants do what you want indirectly. You’d like to assert something as “good” and “scrap”. This is possible, but totally ineffective. You would have to test for the existence of “good” and “scrap” each time you want to divert your items. Both suggested variants translate ”good” and “scrap” to number values, because a number is easier to get evaluated than an array of characters like “good” and “scrap”. And there is another problem, if you say at the start of your model that something is currently “good” and it is becoming later “scrap”, how would you do this if have already set a tag called as “good”. Would you delete the tag and then add another tag as “scrap”? Because this takes much more coding, both advanced users suggested an indirectly approach. I would do the same as both suggested. But I would tell you to think about a different name for your label, that indicates the attribute of ”good” and “scrap”. What about “HowAmI”? Then you can still set a value for “HowAmI” as “good” and “scrap”. Yes, you can set a label value as an array of characters called as string. And you can test, if the value of “HowAmI” is “good”. But this test doesn’t automatically involve, that any other value is always “scrap”. It can be anything else. It can be “GOOD”, “bad”, “bADd” and even empty. That is why users suggest to set discrete number values to 1,2,3,4. And programmers are a lazy kind of people, they think how can I make my live more comfortable. The values of a range like 1,2,3,4 is suiting better in FlexSim than 0,1,2,3. That is because the ports, which are responsible for the diverting of flow items are numbered as 1,2,3,4,.. Programmers think of easy and lazy methods. They have already translated “good” and “scrap” indirectly into number values. For once it is ok, twice that’s getting complicate, more often it would be complex. Now programmers do it in their language directly. They think “good” will mostly go to port 1 and “scrap“ will go to port 2. Then it is a good idea to set the value of label “HowAmI” to 1 for good parts and 2 for scrap parts. Then it is not necessary to test anymore. Now anyone need only read the value of “HowAmI” and divert an item directly to port 1 or 2. There are occasions you have to divert items to other numbered states. That is not really a problem, then you translate the number differently by a structure called “switch by case”. If you aren’t convinced of this lazy idea to make life comfortable then you can still assert a label called “good” and for other items called “scrap”. The condition for a test is then

objectexists(item.as(Object).attrs.labels.subnodes[“good”])
· 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.

Joerg Vogel avatar image Joerg Vogel commented ·

Source code designer would translate lazy into well organized. That is not true, because they often forget to comment their well organized work to document their thoughts.

0 Likes 0 ·
Julio R avatar image
0 Likes"
Julio R answered

Hello Alejandro,

I would suggest the other way arround, I would send by percentage using the "by percentage" option in the first queue and then I would change the label on entry in each Queue.


1621022240150.png (58.9 KiB)
1621022318397.png (14.4 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.

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.