We use Labels to attach a value or attribute to a work item.
At the moment, all the work items traveling through our simulation are the same, i.e. they have no distinguishing attributes.
We want to distinguish between different types of work item, for example by marking each one as either Green or a Blue Car type.
We are going to use the structure below in order to create a simple example using labels.
We will assign a value to each work item, telling us whether it is Blue or Green. We can then use this information to send the Blue work items to the ‘Blue’ queue, and the Green work items to the ‘Green’ queue.
Step One: Create a Label
First of all we need to create a new label.
Clicking on the Labels button on the Data and Rules tab takes you to the Central Label Editor which is a list of all the labels in your simulation. This will be blank if you have not previously created any labels.
Select ‘Add Label’ to create a new label.
First, you need to enter a name for the Label Call your Label lbl_color. Please note that only one Label is needed for distinguishing Work Items based on color, rather than one for Blue and Green Cars each. We now need to choose whether to create a number or text type Label. Number type Label are more versatile because they can be used for mathematical functions later on, so it's generally a good idea to pick a number style Label as a default.
*Quick Tip: When naming Labels and other variables in Simul8, it is useful to assign a prefix to the name, so their type can be easily recognizable! In the case of Labels, the prefix “lbl” is usually used.
At this point you can also add a memo to your label. A memo won’t alter your label in any way. It is used just to remind you of what the different label values represent. We are going to give our lbl_color two different values depending on whether a work item is Blue or Green. Adding something like this to your memo box should remind you of what your values represent.
At this point we have created our label, but not attached it anywhere in our simulation. This will be the next step.
Step Two: Attach your Label
Labels can be attached in Start Points, Activities, and in Start Up in Queues. As a general rule, you should attach a label as soon as you know the relevant information. In our Car example, we could attach the label in either the Start or Activity, and the outcome would be the same. In larger simulations, however, it is important to think about where you might need to reference particular information. If you attach a label as soon as you know the information it contains, it will be there wherever you need it in your simulation.
We will attach lbl_color in the Start Point in this example. To do this, click the “Add Object” button in the Central Label Editor and choose Start Point 1.
When this is done, you need to choose what action you would like your label to take; this can be done by clicking the “Add Action” button. Choose one of the Action options on the right hand side of this dialog so that you can tell your simulation what to do with the label. Your Actions dialog should currently look like this.
The option Add a label to change allows you to pick the label you want to add actions to or remove from here. To remove click the label, and then choose Remove Selected.
You can also attach a label to an object by selecting the object in your simulation, and then choose Actions on the ribbon under the Properties tab.
Step Three: Set the value of your label
In this example we are going to say that each work item is equally likely to be a Blue or Green. We can set up our simulation to reflect this, so that the label value is equally likely to be 1 or 2.
The mathematical equivalent of this likelihood is a Rounded Uniform Distribution with a Lower Bound of 1 and an Upper Bound of 2. This means that any value is equally likely to occur between the lower and upper bound, and only whole numbers can occur.
Effectively, we are saying that 1 and 2 are the only possible values, and each of these values are equally likely.
Step Four: Testing
Now that we have attached our label and set its value, we can test whether the label values are being correctly assigned to our work items.
In your structure, delete the routing arrow after the 1st queue so that it looks like this.
We can now run the simulation so that all work items remain in the first Queue. It is now possible to inspect all the label values of work items in this queue to check that we have a mix of male and females (values 1 and 2).
To check the contents of a Queue, first of all select the Queue, then go to its Properties tab, and choose Current Contents. You can now scroll through each work item and see its value for lbl_color. You should have a mixture of values 1 and 2.
You can now replace the routing arrow to link your simulation back together.
Step Five: Routing Out
The final stage is to control sending the right work items to the right Queues. We can do this using Routing Out in the Activity.
Select your Activity, then Routing Out on the ribbon. We are going to Route Out using the Label discipline because it is the label value which determines where the work items should go.
When you choose Label as your Routing out discipline, a dialog will open with a list of all the labels in your simulation.
Whichever Queue you have first in the list order will take Label value 1 by default, and whichever Queue you have second in the list order will take label value 2, and so on. If these are the wrong way round, the pointer arrows can be used to change the ordering.
Make sure that label value 1 is being routed to the Blue Queue and value 2 is being routed to the Green Queue, by checking the contents of each Queue in turn, the way we did above.
Using Labels in Simul8 can be useful not only for Routing Out but also for many other actions in Simul8.