Simulation with AnyLogic/Discrete Event Simulation/Bank Model/Step 2. Creating a simple model
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
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 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.
- 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.
- Add Queue object to model a queue of customers waiting for the moment they can be served.
- Add Delay object. The Delay object models the ATM that is spending some time serving the customer.
- Add Sink object. This object indicates the end of the flowchart.
- 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.
- Connect the output port of queue with the input port of delay.
- 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.
- Modify the properties of the source.
- Modify the properties of the queue.
- 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
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.
- In the Project view, click the Simulation:Main experiment item.
- On the Model Time tab of the Properties window, choose Never from the Stop at specified time drop-down list.
Running the model
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.
- 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.
- Having started the model, you will see the presentation window. It displays the presentation designed for your simulation experiment.
- 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.
- 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.