article

Paul Toone avatar image
0 Likes"
Paul Toone posted

List Connectionless Routing Example   

Here we will build a model that uses lists for basic many-to-many routing of items. The layout for this model is shown in the following image.

How It Will Work

In this model, items will be sent from three queues to one of four processors. We will use an item list. The queues will push the items onto the list, and the processors will pull them from the list and process them. Initially we will implement a simple pull, but later we will experiment with filtering and prioritizing.

Modeling Steps

  1. Build the Model Layout - Starting with a new model, create and connect objects in the model according to the following image, namely, a source that connects to three queues, and four processors that connect to a single sink. Do not connect the queues to the processors.

  2. Define Source Properties
    1. Open the Source properties window.
    2. Define the Inter-Arrivaltime as exponential(0, 2.5, 0).
    3. In the Flow tab under Send To Port choose Random Port from the pick list.
    4. Also, let's make three different item types, which we will use later. Add an OnCreation trigger to Set Itemtype and Color to duniform(1, 3).
  3. Add an Item List - From the Toolbox, press the Add button and select Global List > Item List. This will add an item list to the model. We don't need to define any custom properties right now, so close the list's properties window.
  4. Make Queues Push to the List - Define each queue's Send To Port by choosing Use List > Push to Item List from its pick list. Make sure the list corresponds the the item list's name that you added.

  5. Make Processors Pull from the List - For each processor's Input, check Pull and under Pull Strategy choose Use List > Pull from Item List from the pick list. Make sure the list name corresponds with the name of the item list that you added. You can leave the query blank.

  6. Run the Model - Now we're ready to run the model. Before we do that, though, let's open live views of what is on the list and who is waiting to pull from the list. In the Toolbox, double-click on the item list to open its properties. From the General tab, press both View Entries... and View Back Orders.... These buttons will open the entry viewer and back order viewer respectively.

    Now run the model.

When the model first starts, you'll notice that there are four rows in the back order viewer.

This means that the four processors have initiated a pull from the list, but since no items have been pushed to the list, they are waiting for their pull to be fulfilled.

As the model runs, items will enter the queues and be pushed onto the list, fulfilling the processor back orders, and then start to be processed. When an item is pushed onto the list and there are outstanding back orders, the item will be immediately pulled from the list. The back order will be fulfilled and subsequently removed from the back order list.

Eventually all outstanding back orders will be fulfilled, meaning all processors have found an item to process and are now processing it. When the back order list becomes empty, subsequent items that enter the queues are pushed onto the list, and, having no back orders to fulfill, they will remain on the list until a processor is finished processing its current item and pulls from the list again.

When items are pushed onto the list, they are added to the end of the list. If pull operations do not include prioritization as part of their query, the items will be pulled off in FIFO (first-in-first-out) order. Back orders will also be fulfilled in FIFO order if you do not define a Back Order Queue Strategy.

Model Experimentation

Now let's experiment with the different settings for the pull operations.

Scenario 1: Filter by Itemtype

Let's say that one of the processors can only process itemtype 2. We can accomplish this logic in our simulation by implementing a simple query on the processor.

  1. Open a processor's properties window.
  2. In the Flow tab, under Pull Strategy, open the pick list option properties.

  3. Under Query enter WHERE itemType = 2. You can use the Add button on the right for help in building this query, or just enter it in directly.

    This expression means that you only want to pull items from the list where the itemType column is equal to 2.

  4. Reset and run the model.

Now you should notice that the processor whose pull query we changed will only pull and process items with an itemtype of 2 (the green items).

For FlexScript Coders: The = operator

In this example we use the expression WHERE itemType = 2. The use of = as a comparison operator may be counter-intuitive for people who are familiar with FlexScript but new to SQL. In FlexScript (and in many other c-style languages), = is an assignment operator, whereas == is a comparison operator. In standard SQL, = is the comparison operator, and there is no assignment operator. To alleviate this confusion for our users, we have added a special SQL rule within FlexSim that makes both = and == a comparison operator, so that if you're used to using ==, you can do that in your list queries in FlexSim.

Scenario 2: LIFO Pulling

Let's say now that we want all the processors to pull in LIFO order (last-in-first-out) instead of the default FIFO, meaning that the items that were most recently added to the list should be the first to be pulled from the list. Again, we can accomplish this in the simulation by implementing a simple pull query.

For each of the processors, do the following:

  1. Open the processor's properties window.
  2. In the Flow tab, under Pull Strategy, open the pick list option properties.

  3. Under Query enter ORDER BY age ASC. Again, you can use the Add button on the right for help in building this query, or just enter it in directly.

    This expression tells the pull operation that you want to prioritize by the list's age column in ascending order, meaning items on the list with the lowest age will get the highest priority.

    If you want to keep the previous scenario's logic where one processor only pulls itemtype 2, then for that processor, you just append the ORDER BY clause at the end of the expression.

    WHERE itemType = 2 ORDER BY age ASC
  4. Reset and run the model.

You should notice now that items on the end of the list will be pulled first, and items at the front will be pulled last.

Using the Entry Viewer's Advanced Tools

The entry viewer has advanced tools that you can use if you want to test out various queries. For example, what if we wanted to test out our ORDER BY age ASC query to make sure it does what we want before actually implementing it in the simulation logic? We can use the entry viewer's advanced tools to do this.

  1. Run the model until there are several items on the list.
  2. In the entry viewer, press the Advanced Tools button to show the advanced tools.

  3. Test the pull query by entering ORDER BY age ASC in the Query field and pressing Enter.

    Notice that the items in the list are now reordered based on their age in ascending order. A pull operation that uses this query would pull from the top of this sorted list, namely /Queue8/Box with itemType of 2 and age of 0.36.

SQL Quick Start

If you're new to using SQL, the SQL Quick Start topic includes a lot more examples of the different pull queries that you might use in this model.

flexsim users manualusers manual
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Article

Contributors

paul.t contributed to this article

Navigation

FlexSim 2016.1