Paul Toone avatar image
Paul Toone posted

First Model   


In this model we will look at the process of manufacturing three types of products in a factory. In our simulation model, we will associate an itemtype value with each of the three product types. These three types all arrive intermittently from another part of the factory. There are also three machines in our model. Each machine can process a specific product type. Once products are finished at their respective machines, all three types of products must be tested at a single shared testing station for correctness. If they have been manufactured correctly, they are sent on to another part of the facility, leaving our simulation model. If they were manufactured incorrectly, they must return to the start of the simulation model to be re-processed by their respective machines. The goal of the simulation is to find where the bottleneck is. Is the testing machine causing the three other machines to back up, or is it being starved because the three machines can't keep up with it? Is the amount of buffer space before the tester important?

Applying the Model to Different Industries

While we are using the manufacturing industry for this example, the same simulation model can be applied to other industries. Take a copy shop for example. A copy shop has three main services: black and white copies, color copies, and binding. During business hours, there are three employees working. One employee handles black and white copy jobs, another handles color copy jobs, and the third handles binding jobs. There is also a cashier to ring up finished orders. Each customer that enters the copy shop gives a job to the employee that specializes in his type of job. As each job is finished, it is placed in a queue for the cashier to finalize the sale and give to the customer. However, sometimes the customer is not satisfied with the job that was done. In such cases, the job must be given back to the appropriate employee to be done again. This scenario represents the same simulation model as the one described above for the manufacturing industry. Here, though, you may be more concerned with the customer queue and the time they spend waiting, as slow service can be very costly to a copy shop's business.

Here's another example of the same simulation model applied to the transportation industry. Commercial shipping trucks traveling over a bridge from Canada into America must go through a customs facility before being allowed to enter the country. Each truck driver must first get the proper paperwork necessary, and then pass through a final inspection of the truck. There are three general categories of trucks. Each category has a different type of paperwork to fill out and must apply at a different department of the customs facility. Once paperwork is finished, all categories of trucks must go through the same inspection process. If they fail the inspection, then they must go through more paperwork, etc. Again, this situation contains the exact same simulation elements as the manufacturing example, only applied to the transportation industry. Here, you may be interested in how far the trucks back up across the bridge. If they back up for miles and thus block traffic into the neighboring Canadian city, then you may need to change how the facility operates.

Building the Model

If at any time you encounter difficulties while building this model, a fully functional tutorial model can be found at http:www.flexsim.comtutorials.


  • Step 1: Start FlexSim
  • Step 2: Select Units
  • Step 3: Create the Objects
  • Step 4: Connect the Objects
  • Step 5: Define the Inter-Arrival Time
  • Step 6: Assign an Itemtype and a Color
  • Step 7: Define the Queue's Maximum Content
  • Step 8: Define Queue1's Routing
  • Step 9: Define Process Times
  • Step 10: Define Queue2's Maximum Content
  • Step 11: Define Tester's Process Time
  • Step 12: Define Tester's Routing
  • Step 13: Reset and Run the Model
  • Creating a Dashboard
  • Randomness
  • Results
    • Step 1: Start FlexSim

      • Open FlexSim by double-clicking on the FlexSim icon on your desktop. The Start Page will appear. Select the "New Model" option in the upper left hand corner of the window.
        • Step 2: Select Units

          FlexSim allows the user to select appropriate units for a model. By default the Model Units window will appear for each new model. You can select units for time, length, fluids and a Model Start Time. The units you choose will be used throughout the model. The Model Start Time may be changed after the model is created, however, the Time, Length and Fluid units CANNOT be changed. For this model, use the following:

          • Time Units: Seconds.
          • Length Units: Meters.
          • Fluid Units: Liters.
          • Model Start Time: Leave as default.
            • Step 3: Create the Objects

              • Create a Source, two Queues, four Processors, and a Sink in the model. Name and place them as shown below (note that one of the Processor objects will be the "Tester").
              • To review the process for creating objects in FlexSim, refer to the Creating An Object section of the Interacting with FlexSim page. To review how to rename an object, refer to the Naming An Object section.

              Step 4: Connect the Objects

              To review how to connect objects, refer to the Connecting Objects section of the Interacting with FlexSim page.

              Notice the Tester object has an output connection to Queue1. This will allow rejected items to be sent back to the start of the process.

              • Connect Source to Queue1.
              • Connect Queue1 to Processor1, Processor2, and Processor3.
              • Connect Processor1, Processor2, and Processor3 to Queue2.
              • Connect Queue2 to Tester.
              • Connect Tester to Sink and Queue1.

              The next step is to change the properties of the different objects so they will behave as specified in the model description. We will start with the source and work our way to the sink.

              Each object has its own properties window through which data and logic are added to the model. Double-clicking on an object accesses the object's properties window.

              For this model, we want three different product types to enter the system. To do this, each flowitem's itemtype will be assigned an integer value between one and three using a uniform distribution (see FlexSim Concepts for more information about itemtypes). This will be accomplished using the source's exit trigger.

              Step 5: Define the Inter-Arrival Time

              Products arrive every 5 seconds, exponentially distributed. The Source, by default, uses an exponentially distributed inter-arrival time, but you will change the mean of that distribution. Statistical distributions like exponential distribution are used throughout simulation in order to model the variations that occur in real-life systems.

              You may edit the Source's Inter-Arrival Time from two different windows:

              • 1) Click on the Source to bring up its properties in the Quick Properties window.

              • 2) Double-click on the Source to bring up its Properties window.

              • On the Source tab, click on the button. A popup will appear.
              • Set Distribution to exponential.
              • Set Location to 0.
              • Set Scale to 5.
              • Set Stream to 0.

              Click anywhere outside the popup to save these settings.

              Remember that units were set at the beginning. Setting Scale to 5 sets the mean of the distribution to 5 seconds. If the units had been set to hours, the mean would have been 5 hours.

            • If you edited the Inter-Arrival time through the Quick Properties window, you'll need to open the Source's Properties window in order to perform Step 6. This can be done by clicking the More Properties button under the General Properties section of the Quick Properties.

            Step 6: Assign an Itemtype and a Color

            The next thing we need to do is assign an itemtype number to the flowitems as they enter the system. This value is uniformly distributed between 1 and 3, meaning the chance that the entering product is type 1 is just as likely as it is type 2, which is just as likely as it is type 3. The best way to do this would be to change the itemtype in the OnCreation trigger of the Source.

            • Click the Triggers tab. Add a function (press the button) to the OnCreation trigger. Select Set Item Type and Color from the list. A popup will appear.

            The duniform distribution is similar to a uniform distribution except that instead of returning a real number it will only return whole numbers. Click OK to apply the changes and close the window.

            Step 7: Define the Queue's Maximum Content

            The next step is to edit the Queue. There are two things we need to configure on Queue1. First we need to set the Maximum Content of the Queue. Second, we need to have the Queue send itemtype 1 to Processor1, itemtype 2 to Processor2, and itemtype 3 to Processor3.

            This step, along with step 8 can be done through the Quick Properties window as shown below, or by opening the Queue's Properties window as described.

            • Double-click on Queue1 to open its Properties window.
            • On the Queue tab, change the Maximum Content to 10000.
            • Click Apply, but do not close the Properties window.

            Step 8: Define Queue1's Routing

            • Click the Flow tab.
            • Under Output, select By Expression from the Send To Port drop-down list.

            • A popup with suggested expressions will appear. The default expression for By Expression is getitemtype(item) . This will send type 1 to port 1, type 2 to port 2, and so on. Click anywhere outside popup to close it, and then click OK to apply the changes and close the window.

            Step 9: Define Process Times

            The next step is to set the processing times for the three processors.

            As described for Step 7, the Process Time can be set through the Quick Properties window by clicking on the object once in the 3D view.

            • Double-click on Processor1 to open its Properties window.
            • On the Processor tab, select Statictical Distribution from the Process Time list.
            • In the Statictical Distribution popup, set Distribution to exponential. Use the default parameters given for this distribution.
            • Click OK to apply the changes and close the window.
          • Repeat this step for Processor2 and Processor3.

          Step 10: Define Queue2's Maximum Content

          Follow Step 7 to change Queue2's Maximum Content to 10000.

          Step 11: Define Tester's Process Time

          As described in Step 9, this can be set through the Quick Properties window as well.

          • Double-click on Tester to open its Properties window.
          • On the Processor tab, highlight all the text in the Process Time field.
          • Replace the text with 4. This sets the process time to a constant four seconds.
          • Click Apply, but do not close the Properties window.

          Step 12: Define Tester's Routing

          Now we need to configure the testing station to send bad products back to the beginning of the model, and to send good products to the sink. When you created this object's connections, you should have first connected it to the sink, then connected it back to the first queue. This ordering will have made the first output port of the testing station be connected to the sink and the second output port be connected to Queue1. You can verify that the ports are correct by clicking Output Ports in the Ports panel, which is at the bottom of the General tab. If the ports are out of order, you can use the "Rank ^" and "Rank v" buttons to reorder the ports. Now we want to route to the appropriate port number based on a certain percentage.

          • Click the Flow tab. Select By Percentage from the Send To Port list.

          • Use the to add another field.
          • Fill the fields to match the picture below.

          This means that 80 percent of the products (the correctly manufactured products) will be sent through output port 1 to the Sink, and 20 percent (the incorrectly manufactured products) will be sent through output port 2 back to the first queue.

          One more thing we might want to do is visually distinguish items that have already been through the testing station and have been sent back to the first queue.

          • Click the Triggers tab. Add a function (click the button) to the OnExit trigger and select the Set Color option. Select colorblack(item) from the list.

          • Press OK to close the Properties window.

          Step 13: Reset and Run the Model

          • Click on the button, located at the upper left-hand corner. Resetting the model sets all system variables to their starting values and clears any flowitems present in the model. Resetting is also necessary any time new connections are made between objects.
          • Click the button, located right next to the reset button.

          The model should now start to run. Flowitems should move from the first queue, into one of the three processors, then to the second queue, into the testing station, and from there to the sink, with some being re-routed back to the first queue. Re-routed items will be colored black.

          To stop the model, press the button at any time. Later you will learn how to run a model for a specified time, and for a specified number of iterations. Running a model more than once is important when statistical distributions have been used in the model definition.

          To speed the model up or slow it down, move the Simulation time slide bar at the top of the window to the right or left. Alternatively, you can press the Ctrl + Down Arrow and the Ctrl + Up Arrow to increase or decrease the run speed.

          Moving the slide bar changes how fast the simulation time proceeds relative to real time. It has no effect on model results.

          We have now completed building the model. Let's look at some of the statistics the model generates.

          Creating a Dashboard

          Finding the Bottleneck

          In the model description, we said that we wanted to know where the bottleneck was in the system. There are several ways to determine this. First, you can simply examine the visual size of each queue. If one queue in the model consistently has many products backed up in it, then that is a good indication that the processing station(s) that it feeds are causing a bottleneck in the system. In running this model, you'll notice that the second queue very often has a lot of products waiting to be processed, whereas the first queue's content is usually 20 or less, as shown below.

          Another way of finding the location of a bottleneck is by examining the state statistics of each of the processors. If the three upstream processors are always busy, while the testing station is often idle, then the bottleneck is likely to be at the three upstream processors. On the other hand, if the testing station is always busy, while the upstream processors are often idle, then the bottleneck is probably at the testing station.

          Evaluating the New Configuration

          Run the model for at least 50,000 seconds. Notice first that Queue2 is now almost always empty, whereas the Queue for the 3 processors backs up quite often. Let's use the dashboard to compare the two testers side by side.

          • From the FlexSim Toolbar click the Dashboards button then Add a dashboard. The Dashboard window will appear.

          • Drag the icon into the Dashboard window. This should bring up an object selection window.

          • On the Objects tab, click the . This will open a popup.
          • In the popup, click the , expand Processors, and select Tester and Tester2.

          • Click the Select button on the popup to finalize your selection. Then click OK. A blank chart should appear in the dashboard.
          • Reset and run the model again. The graph in the Dashboard will dynamically update.

          The reason that these two are different is because the tester queue sends to the first available tester. Whenever both testers are available, a product will always go to the original tester, since it is the first available. Products only go to the second tester if the original tester is already busy. Thus the original tester gets higher utilization than the second tester.

          Now add the other three processors to the State Bar graph.

          • Double-click on the graph in the dashboard and the same object selection dialog opens.
          • Select Processor1, Processor2, and Processor3 from the selection list. Whatever you select is added to the previous contents of the graph.
          • Reset and run the model again. Now all five processors can be compared side by side.

          We have effectively moved the system bottleneck from the tester to the three upstream processors. Also, by increasing throughput by 15% and consequently adding another tester, we have significantly decreased the utilization of each tester. Whether this is a good decision depends much on the cost it would take to add a second tester. Since the bottleneck is in the 3 processors, in order to further increase throughput, and thus increase the utilization of each tester, we would need to add more processors. Again, there is a cost/benefit analysis to this decision.

          Try changing any parameter (like a processor's process time) and watch its effect on the model. Even small changes can dramatically change the overall model.


          Let's do some more testing before we actually decide to add another tester. Since on average one product arrives from the source every 5 seconds, and on average one product goes to the sink every 5 seconds, why should the queue accumulate at all? Products are leaving just as fast as they arrive, so there shouldn't be any accumulation in the system.

          The reason the queue accumulates is because of randomness in the system. Yes, on average a product arrives every 5 seconds, but this arrival rate is according to an exponential distribution. For an exponential distribution with a mean of 5, most of the time products will actually arrive at a faster rate than every 5 seconds. But every once in a while there will be a long drought where no products arrive at all. In the end it evens out to an average of 5 seconds, but usually products arrive faster, and thus will accumulate in the tester's queue, since the tester is the bottleneck.

          What if, in our facility, products actually arrive at a more predictable rate, instead of by the somewhat unpredictable exponential distribution? Will the queue size generally stay at a lower level? Let's test it.

          • Edit the Source'sInter-Arrivaltime to match the following.

          • Once set, Reset and Run the model again.

          If you do not still have Queue2's properties window available, open it again by double-clicking on Queue2. Continue to run the model. You will notice here that the queue's maximum content doesn't go up as high. Usually they won't go much higher than 50 or 60 now, whereas before they would sometimes get up to 150 or 200. This is a significant difference caused by simply changing the type of randomness in the model.

          Higher Throughput

          Now suppose that the facility does indeed need to increase the throughput rate of this system by 15%. This equates to a change of the mean inter-arrival time of the source from 5 seconds to 4.25 seconds. Since the tester was already at 100% utilization, we will obviously need to add a second tester to the system. Let's make this change.

          • Edit the Source'sInter-Arrivaltime to be a normal distribution with a mean of 4.25.
          • Now we will create a second tester. Create another Processor object in the model, and place it below Tester. Name it Tester2.
          • Connect Queue2 to Tester2.
          • Connect Tester2 to Sink and to Queue1.
          • Set Tester2'sProcess Time to 4.

          • Change Tester2'sSent To Port to By Percentage Enter the same parameters as you did for Tester1.

          • Add an OnExit trigger to change the color to black, just like the other Tester.
          • Now that you have finished making the changes, Reset and Run the model again.


          By creating a model that simulates our system, we have clearly determined what effect certain decisions will have on the system. We can now use the information we have gathered from the simulation to make better informed decisions for the future of the facility.

          With this simple model, many of the same conclusions could have been made through mathematical models and formulas. However, real systems are often much more complex than the model we have just built, and are outside the scope of mathematical modelling. By using FlexSim simulation, we can model these real-life complexities, and examine the results just as we have done in this model.

          FlexSim also gives your simulations much more visual appeal. It is much easier to convince a management team of the wisdom in a decision if the management team can see the effects of that decision in a virtual 3D world. This world is created automatically as you build your FlexSim models.

          What Next?

          Now that you have become familiar with FlexSim and the use of simulation, we suggest that you go through the other tutorials included in FlexSim Help.

        flexsim users 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.



        paul.t contributed to this article


        FlexSim 2016.1