question

Kyle S avatar image
0 Likes"
Kyle S asked Kyle S commented

How do I get all Items in a batch to go to the same random port?

I am building a model and have a few things I am unable to get the model to execute how I would like it to.

1. A few days ago someone assisted with the coding for the batching by SKU custom code in the source triggers. However after the items go to the first queue I would like them to be sent to one of the remaining queues randomly in the full batch quantity. When I use the random queue entry it sends each batch to different queues. After this step items are individually moved throughout the process so a combiner would not be ideal.

2. I have included the setup for a process flow I have that generates orders. I had to remove the current model and so the process flow does not function in the attached model. I am just looking for help with the "Assign Labels: SKU & QTY" step. I have the SKU and QTY setup by quantities from historical data but when the system gets the number of SKUs in the order from the "Get Order Data" label it pulls from all those historical quantities creating orders larger than we produce. Ideally I would like to set a max quantity on this so there is only a max of 52 items per order but am not sure if this is possible.


Any help is appreciated.

FlexSim Model.fsm

process flowbatchingqueues
flexsim-model.fsm (35.9 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.

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Kyle S, was Joerg Vogel's answer helpful? If so, please click the "Accept" button at the bottom of their answer. 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 comment back to reopen your question.

0 Likes 0 ·

1 Answer

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Kyle S commented

A queue has got an On Finishing Collection trigger. You set a random value in a label at your queue. In Send to port you read this label value.

Restriction: If another batch finishes before all previous batched items left, this gets messed up. If this can happen, you have to step through all items in a loop to assign an output port label, which is read in send to port OR you explicitly release each item by command releaseitem through a port number.

· 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.

Felix Möhlmann avatar image Felix Möhlmann commented ·

1) Using On Finish Collection might not work if the sizes of the batches coming from the queue are random to begin with. What can work instead is to keep track of the time when the last item exited the queue. All items that exit at the same time are send to the same port. If the time since the last exit is larger than 0 a new port is randomly determined.

flexsim-model_1.fsm

2) The real-life order composition probably follows much more complex 'rules' which will be hard to shape into something functional for the simulation (if there are multiple SKUs in the order the individual quantities will be lower compared to an order with fewer or only one SKU).

If you have a sufficient number of historical orders and you don't assume that order composition will change in the future then feeding the model with the exact historical orders might be the best choice.

If you want to keep the orders (semi-) random, then the quantities of different SKUs should better not be independent. One possible approach might be the following:

- Determine how many SKUs are present in the order
- Determine the total quantity of items in the order (different distributions for different SKU amounts)
- Choose which SKUs are part of the order
- Pick a SKU for each item in the order based on a percentage distribution

This would all happen on the 'main' token so that the second layer of your Process Flow logic would be skipped. The main token would directly use a subflow to pull the individual items.

1 Like 1 ·
flexsim-model-1.fsm (36.6 KiB)
Kyle S avatar image Kyle S commented ·

@Felix Möhlmann In regards to question 2. Our process is currently newer so out historical data is not in depth enough to confidently use. Based on that, could you explain further your process for building the semi random orders. I am not sure I understand the steps to get that functioning correctly. Thanks.

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Kyle S commented ·

I added an example of what I had in mind to the model. It would require changing the current Process Flow a bit, since it outputs a single array with all types in the order. But you could of course also adjust the code to get a data structure that fits your current model better.

flexsim-model-2.fsm (The distributions to determine the number of items are placeholders)

0 Likes 0 ·
flexsim-model-2.fsm (37.4 KiB)
Kyle S avatar image Kyle S Felix Möhlmann commented ·

Thank you for providing the example. I believe I have it incorporated into my model but I am unfamiliar with some of the coding used to determine which SKUs are used. Does this code take the empirical distribution "Type" into account?

0 Likes 0 ·
Show more comments