Get Label Total in Object

Sum the total for a label across all work items in an object.

* The simulation object. Can also be text that is the name of a Simul8 Group of simulation objects.

  • The label that contains the numerical value to be totaled
  • A data item to receive the returned total

A fast way to get the total inside an object (or all the objects in a Group) of one specific label across all work items. Much faster that writing a loop that selects each work item and then gets its label value, then gets the next work item, etc.

See Get Label Total Visual Logic in action

Below is a small example simulation in which we use this Visual Logic command.

Download example simulation

We see that Activity 1 collects all work items of Queue 1 whenever the sum of their label “lbl_ProductParts” is equal to or more than 21. If the sum is less, it does not collect and wait. This logic is common for example when we load products onto some means of transportation, let’s say a truck, and we need to ensure that a certain minimum number is collected. In addition, a single work item might represent a pallet and the minimum number to collect refers to the sum of parts across all pallets.

In that example, a label called “lbl_ProductParts” is set to a Rounded Uniform distribution (integer values between 1 and 7) on the Start Point. Visit Labels Tutorial for how to attach a label and see Distributions for the different distributions offered in Simul8.

Then, On Entry of Queue 1 the following Visual Logic command is called.

Example Visual Logic command

The “Get Label Total in Object” returns a global variable, in this case “gbl_PartsCount”, which is the sum of all work items’ labels “lbl_ProductParts” that are in Queue 1. The remainder implements the above logic using IF and ELSE (note that the latter sets the number to be collected to 999 as a dummy number, higher than we ever expect it to be, or as in this case impossible to be reached).

This Visual Logic command is similar to Batching In on a work item count with minimum and maximum, however might offer additional flexibility and control, e.g. when we don’t want to assemble work items. If you have any comments or questions, please get in touch with