question

Juan Antononio M avatar image
0 Likes"
Juan Antononio M asked tannerp commented

Set label by percentage in Flexsim 19.0.0

Hello,

I´m working with Flexsim Version 19.0.0 and I´d like to know how is the method, set of intructions, or step by step to be able to run the instruction “Set label by percentage” in On Creation Trigger of Source because I know there is this option in Flexsim Version 2020 and it´s very useful.

In Flexsim Versión 19.0.0 don´t exist this option, unless I think, and I would need to create a mix-production whith differents types of flowitems (throw Arrival Schedule) with a particular label type and with particular percentage. I know in Flexsim Versión 19.0.0 exist this option “Set Item Type by Percentage” but it isn´t exactlyI need.

Could someone help me, please?

Thank you in advance.

Choose One
flexsim commands
· 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.

tannerp avatar image tannerp commented ·

Hi @Juan Antononio M, was Braydn T's answer helpful? If so, please click the red "Accept" button on their answer. If you'd still like help, feel free to comment back with more information so we can provide additional support. Thanks!

0 Likes 0 ·

1 Answer

Braydn T avatar image
1 Like"
Braydn T answered Braydn T commented

@Juan Antononio M

This is the code that flexsim uses to set label by percentage. You can just put this in a code snippet in the trigger:


/**Custom Code*/
Object current = ownerobject(c);
Object item = param(1);
int rownumber = param(2); //row number of the schedule/sequence table
{ // ************* PickOption Start ************* //


int stream = getstream(current);
double randomnum = uniform(0.0, 100.0, stream);
//this is the label name
string labelname = "myLabel";
Object involved = item;
Variant value;
double total = 0.0;
int foundmatch = 0;
//this is the percentage
total += 50; 
if (!foundmatch && randomnum <= total) {
    value = 1;
    foundmatch = 1;
}
involved.labels.assert(labelname).value = value;
} // ******* PickOption End ******* //
· 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.

Braydn T avatar image Braydn T commented ·

Also, I would recommend updating to the latest bug fix for 19.0, for the best performance. You can find it on the downloads page under your account on flexsim.com.


0 Likes 0 ·