Find the Shortest Line, Randomize If All Equal

When you are in a situation where you would like an entity to go-to the shortest queue available out of multiple routes/queues, and in case all queues are equal randomize what route the entity takes.

Find the Shortest Line, Randomize If All Equal model image

Where to Find the Model Object

The following model object can be found in the model objects directory:

  • Routings \ Find the Shortest Line, Randomize If All Equal

Difficulty Level

  • Ease of Use: Moderate
  • Ease of Modification: Moderate

How to Use the Model Object

  1. Open Your Model: Open your model or create a new blank model.
  2. Insert the Model Object into Your Model
    1. Locate the model object Find the Shortest Line, Randomize If All Equal and select the insert button.
    2. Move the cursor to the point of insertion and left mouse-click. The upper left corner of the model object will be inserted at the location of the mouse-click.
  3. Connect to Your Model
    1. Connect an arrival route or a percentage route from the part of your model where you would like the entities to take the shortest route to Select Line.from your model to Find the Shortest Line
    2. Connect the routes exiting from ProcessProcess2Process3, and Process4 to the rest of your model.from Find the Shortest Line to the rest of your modelThis gives you an example on how you can route entities to anywhere you like after they have  been through the shortest line.
  4. Update Objects
    1. Change all the processing times for routesProcessProcess2Process3, and Process4.change times in Find the Shortest Line
    2. Change the names of all the activities to match your organization.
  5. Completion: The model object is now integrated into your model, you should now be able to save and then simulate the model.

Controls Usage


  1. a_Dir: Do not change. This attribute tells each entity which route to take.


  1. v_Line_Count1-4: Do not change. This variable is used to know the amount of entities in queue for Process/2/3/4.

Advance Topics

How Do I Build This Model Object from Start?

  1.  Declare Attributes & Variables as suggested above, you will need to declare the variable v_Line_Countx multiple times, where x is the number of available routes an entity can take (as in this model object we have four available routes).
  2. Make the exit routes of the process that will decide where the entities are routed conditional and use the conditions so that every route represents a different Attribute number (ex: a_Dir = 1, a_Dir = 2 and so on).
  3. Increment the line counter on all routes, so that its known how many entities are pending at a process (ex: Inc v_Line_Count1).
  4. At the exit point from the alternate processes decrement the line counter so that the its known how many entities are pending in a process (ex: Dec v_Line_Count1).
  5. At the point in your model where you require an entity to route the shortest queue or randomize if all queues are equal you will need to write Action Logic, start with declaring an Attribute that will be used for direction as 0 (ex: a_Dir = 0), then use if and then statements as has been done in the model object’s Select Line and extent from it.
Was this article helpful?

Related Articles