question

Jiahao Y avatar image
0 Likes"
Jiahao Y asked Joseph Gillespie commented

How do I batch by aggregated label value?

Hi, I am new to FlexSim and am encountering a pretty complicated challenge.

I have two types of parcels - type 1 (5kg) and type 2 (10kg). I have created a label for the parcel weights at the source, and I want to batch the parcels together when the total weight reaches 50kg. This will include a mix of both type 1 and 2 parcels based on a first-come-first-serve basis in the queue.

I have created an "input" label at the processor to keep a running count of the total weight of the parcels processed. Once the "input" label reaches 50kg, I send it to the attached queue using a scripted code to control the outflow. However, the outflow code does not send the entire batch to the queue.

Would you have any suggestions how to resolve the issue?

project-v3.fsm

Choose One
labelsbatchingprocess flow tasksequence
project-v3.fsm (28.0 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

·
Aaron C avatar image
0 Likes"
Aaron C answered

Just based on the info you've provided, I would just use a Queue for batching instead of a Processor. Follow these simple steps to solve your problem:
1. Drag in a queue to perform your batching at.
2. Add a label "TotalWeight" to the Queue. Set it to 0 and check the "Automatically Reset" box.
3. Add the following code to the Queue's OnEntry trigger: (assume that the weight of the object is stored on item.Weight)
current.TotalWeight = current.TotalWeight + item.Weight; // Update TotalWeight
if (current.TotalWeight >= 50)
{
current.output.open(); // Opens the output port to release batch of items
}
4. Add the following code to the Queue's OnExit trigger:
if (current.subnodes.length == 1)
{
current.output.close();
current.TotalWeight = 0;
}
5. Add the following code to the Model's OnRunStart trigger:
Object queue = Model.find("QueueName"); // Change "QueueName" to whatever your queue is named
queue.output.close(); // Initially close the output port

That did it for me

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.