Simulation with AnyLogic/Discrete Event Simulation/Bank Model/Step 2. Creating a simple model

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Step 2. Creating a Simple Model

Now we will create the simpliest model consisting of the ATM only.
First, we will create a flowchart describing the system.

Creating the model flowchart[edit | edit source]

In AnyLogic you create flowcharts by adding the objects from the library stencil onto the class diagram, setting custom properties for the objects, and connecting objects together.

Add flowchart objects

  1. Add flowchart objects onto the diagram as shown below:

    To add a object of the library on the diagram, first open the library stencil in the Palette view, then drag the object from the library stencil into the graphical editor where you want to place the object.
    Enterprise Library stencil shows all the objects of the library.
  2. Add Source object. Source object generates entities with the specified interarrival time. In our example, it models customer arrival.

    Please refer to Enterprise Library Reference Guide for the description of all the Enterprise Library objects. You can find there all object functions and their parameters. To open Enterprise Library Reference Guide, choose the corresponding item from the AnyLogic Help. To invoke AnyLogic Help, choose Help|Help Contents from AnyLogic menu.
  3. Add Queue object to model a queue of customers waiting for the moment they can be served.
  4. Add Delay object. The Delay object models the ATM that is spending some time serving the customer.
  5. Add Sink object. This object indicates the end of the flowchart.

Connect the flowchart objects

  1. Connect the objects as shown in the figure:

    First, connect the port of source with the left port of queue (this port plays the role of the input port). Generally, input ports are placed on the left side of the object, while output ports - on the right.
    To connect ports of objects, double-click the first port and then click the second port. The connector linking two ports appears.

    Cyan points inside ports indicate the correct connection. In the case you do not see cyan circles, it probably means that you put connector's point close by a port and you need to move it onto it.
  2. Connect the output port of queue with the input port of delay.
  3. Connect the output port of delay with the port of sink.

Now we will define the data of our model, adjusting the properties of the flowchart blocks. To modify properties of some model element, first select it by clicking on it in the graphical editor or in the Project view. This opens the properties of this element in the Properties view.

Set up the properties of the flowchart objects

  1. Modify the properties of the source.
    • Specify how often customers arrive. Type 0.67 for Interarrival rate.
  2. Modify the properties of the queue.
    • Set queue capacity to 15 entities. At most 15 customers will wait in a queue.
    • Select the Enable statistics check box to turn statistics collecting for this object on.
  3. Modify the properties of the delay.
    • Name the object ATM.
    • Specify the processing time. Assume that processing time is triangularly distributed with mean value of 1, min of 0.8 and max value of 1.3 minutes.
    • The triangular() function is the standard AnyLogic random number generator. AnyLogic provides also other random number distributions, like normal, poisson, exponential etc. Please refer to AnyLogic Help for the description of all the random number generators (see AnyLogic Functions topic).
    • Select the Enable statistics check box.

Configuring the model[edit | edit source]

Model simulation has a set of specific settings. A group of model settings is called an experiment, and experiments are displayed at the bottom of the model branch in the workspace tree. You can create several experiments for the same model with alternative model settings. One experiment is created by default and named Simulation.

If we start the model, it will work for 100 time units and then will stop. We want to study the process over a long period of time, therefore configure the model to work infinitely.

Set the model to stop never

  1. In the Project view, click the Simulation:Main experiment item.
  2. On the Model Time tab of the Properties window, choose Never from the Stop at specified time drop-down list.

Running the model[edit | edit source]

We are ready to run the model. First, build your model by clicking the Build Model toolbar button. If there are some errors in your model, the building fails and the Problems view appears listing all the errors found in your model. Double-click an error in the list to open the location of the error and fix it.

After the model is successfully built, you can start it. Running the simulation, you automatically bring the current model up to date.

Start the model

  1. Click the Run toolbar button and choose the experiment you want to run from the drop-down list. Your simulation experiment is called Bank/Simulation.

    In the case this model is the only one opened in the workspace at the moment you will be prompted to run this particular experiment. Later on this button will start the previously run experiment. To run any other experiment, right-click the experiment in the Project view and choose Run from the context menu.
  2. Having started the model, you will see the presentation window. It displays the presentation designed for your simulation experiment.
  3. Click the button to Run the model and switch to Main view. and observe the process dynamics. You will see animated flowchart. Each model created with Enterprise Library instantly has animated flowchart where you can see detailed current object status, for example queue size, number of entities left and so on – completely in graphics!

    If needed, adjust the execution speed to your needs using Slow down and Speed up toolbar buttons.
  4. You can inspect flowchart objects to get the detailed information on their current state. Click on the object to open its inspect window. Inspect window show statistics on the object, e.g. Queue object's inspect shows the queue capacity, the number of entities passed through either port of the object and also whether the timeout option is enabled for this queue. Contains string displays the number of entities currently being in the object along with IDs of these entities.