question

Oleksii avatar image
0 Likes"
Oleksii asked Oleksii commented

How to create a label in Flexsim using By Percentage

How to create a label in Flexsim using By Percentage but the total number of one label of two is not more than 100pcs. Thank you in advance for your help.

FlexSim 24.2.1
create labelscreate a label in flexsim
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

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Oleksii commented

You'll have to write some custom code for this. I would generate one value as normal, then generate another value until the sum of both doesn't exceed 100. One value is assigned to the current item, the other one is stored in a label on the source, so it can be assigned to the next item. If no stored value exists, a new value pair is generated.

In the example model I use an empirical distribution to generate the random values, so the code is less cluttered and hopefully easier to understand.

custom-percentage-label.fsm

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

// Make sure that source labels exist
current.labels.assert("StoredValues", []).value;
current.labels.assert("Index", 0).value;

if(current.StoredValues.length == 0)
{
    // No more stored values -> Create new ones and increment index
    double firstValue = Empirical("TestDistribution").get(getstream(current));
    double secondValue = Empirical("TestDistribution").get(getstream(current));
    while(firstValue + secondValue > 100)
    {
        // Keep rerolling until sum is not larger than 100
        secondValue = Empirical("TestDistribution").get(getstream(current));
    }
    // Update source labels
    current.StoredValues = [firstValue, secondValue];
    current.Index += 1;
}

// Assign labels to item
item.Value = current.StoredValues.shift();
item.PairID = current.Index;
item.color = Color.byNumber(item.PairID);

· 12
5 |100000

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

Oleksii avatar image Oleksii commented ·

Dear Felix,

thank you for your ideas in supporting me in my issue.

I think I did not put the question correctly.

Below is an example of a problem on the screen that needs to be solved.

Please take a look at it if you have a chance to help, I would be grateful.


Thank you in advance!

1728372022715.png

0 Likes 0 ·
1728372022715.png (48.9 KiB)
Felix Möhlmann avatar image Felix Möhlmann Oleksii commented ·

Sorry, but I don't see what the problem in your screenshot is. You have the pass/fail number, can thus calculate the failure rate and use it in the format you show.

It is possible to assign the label in a single expression using bernoulli(). Though that can only return numbers, not strings.

0 Likes 0 ·
Oleksii avatar image Oleksii Felix Möhlmann commented ·

Felix, the problem is as follows:

When randomly generating repair items, when creating an item using the By Percentage function, 1658,0 items (51,95%) are generated. These items go to the Queue after creation. After reaching Queue I need to create a batch of 6 items to be sent to the next workcenter.

When 1658 repair items are generated, the number of batches is not an even number 1658/6 = 276,3 and I still have items on Queue that cannot be formed into a batch.

So the goal is to randomly generate a number of repair items close to 51,95% but still even number of items in the batch. For example 1656 pieces. In this case the number of batches will be 1656/6 = 276, and it will give the opportunity to form batches of all items and pass to the next work center.


Can we use another solution instead of the By Percentage function?



1728377848072.png


0 Likes 0 ·
1728377848072.png (59.2 KiB)
Show more comments