# Simulation with AnyLogic/Print version

The current, editable version of this book is available in Wikibooks, the open-content textbooks collection, at
https://en.wikibooks.org/wiki/Simulation_with_AnyLogic

# Agent-Based Modeling
## Bass Diffusion. Agent Based Model

AnyLogic supports different modeling techniques. This tutorial covers the agent-based modeling approach, successfully applied in a wide range of fields such as ecology, sociology, economics, traffic simulation, and many others. Agent-based modeling is used to model markets (agent is a potential customer), competition and supply chains (agent is a company), population (agent is a family, a citizen, or a voter), etc. Agent-based models allow getting an insight into the general behavior of the system assuming the behavior of its elements, without having any global knowledge about the system.
AnyLogic is the only simulation tool, which allows creating flexible models with agents, interacting with each other and their environment. AnyLogic supports all known ways of specifying the agent behavior – statecharts, synchronous and asynchronous event scheduling.
This tutorial will briefly take you through the process of constructing a simulation model using AnyLogic. It is intended to introduce you to AnyLogic interface and many of its main features. We will create a simple illustrative example—the product life cycle model, used for forecasting sales of new products. The first steps will take you through the process of construction of the classic Bass diffusion model. The model describes a product diffusion process. Potential adopters of a product are influenced into buying the product by advertising and by word of mouth from adopters – those who have already purchased the new product. Adoption of a new product driven by word of mouth is likewise an epidemic. Potential adopters come into contact with adopters through social interactions. A fraction of these contacts results in the purchase of the new product. The advertising causes a constant fraction of the potential adopter population to adopt each time period.
Then we will expand our model by considering some details and introducing you to some advanced features of AnyLogic useful in agent-based modeling.
Note that there are several reference files available for this model representing the milestones of the editing. You can use reference files if you experience any difficulties creating a model and you would like to compare your model with the reference file. You can use Welcome Page to open those examples. Welcome Page appears automatically when you open AnyLogic. It can be opened whenever you like from AnyLogic menu: Help|Welcome.
You can also run this model online.
* Step 1. Creating a new model
* Step 2. Creating agents
* Step 3. Adding Adoption from Advertisement
* Step 4. Counting the product adopters
* Step 5. Adding charts
* Step 6. Configuring simulation
* Step 7. Running the model
* Step 8. Adding adoption from word of mouth
* Step 9. Adding the Product Consumption Logic
* Step 10. Adding agent animations
* Step 11. Making people contacts distance-based

# System Dynamics
## Bass Diffusion Model

AnyLogic supports different modeling techniques. This document covers System Dynamics modeling approach. There are many spheres where system dynamics simulation can be successfully applied — the range of SD applications includes business, urban, social, ecological types of systems. AnyLogic allows you to create complex dynamic models using standard SD graphical notation.
This tutorial will briefly take you through the process of constructing a simulation model using AnyLogic. It is intended to introduce you to AnyLogic interface and many of its main features. We will create a simple illustrative example — the product life cycle model, used for forecasting sales of new products.
The first 10 steps will take you through the process of construction of the classic Bass diffusion model. The model describes a product diffusion process. Potential adopters of a product are influenced into buying the product by advertising and by word of mouth from adopters – those who have already purchased the new product. Adoption of a new product driven by word of mouth is likewise an epidemic. Potential adopters come into contact with adopters through social interactions. A fraction of these contacts results in the purchase of the new product. The advertising causes a constant fraction of the potential adopter population to adopt each time period.
Then we will expand our model by considering some details and introducing you to some advanced features of AnyLogic useful in creating system dynamics models. The expanded model may help you to better plan the entry strategy, target the right consumer and anticipate demand so as to have an efficient and effective promotion strategy.
Note that there are several reference files available for this model representing the milestones of the editing. You can use reference files if you experience any difficulties creating a model and you would like to compare your model with the reference file. You can use Welcome Page to open those examples. Welcome Page appears automatically when you open AnyLogic. It can be also opened whenever you like from AnyLogic menu: Help|Welcome.
You can also run this model online.
* Step 1. Analyzing the model
* Step 2. Creating a new model
* Step 3. Adding stocks
* Step 4. Adding adoption flow
* Step 5. Adding constants
* Step 6. Defining initial values of stocks
* Step 7. Adding auxiliaries
* Step 8. Configuring simulation
* Step 9. Running the model
* Step 10. Adding charts
* Step 11. Modeling replacement purchases

# Discrete Event Simulation
## Discrete-Event Simulation

AnyLogic provides Enterprise Library, a discrete-event simulation library containing objects you can use to rapidly simulate complex discrete-events systems like:
* Manufacturing processes with detailed shop floor layout
* Simple and complex service systems (e.g. banks, airports, hospitals etc.)
* Business processes with activity based costing
* Logistics and supply chain models
Enterprise Library allows you to create flexible models, collect basic and advanced statistics, and effectively visualize the process you are modeling to validate and present your model.
This tutorial shows you the basic steps of creating models of different natures – in the fields of manufacturing, service and business processes. Enterprise Library allows you to create models of different natures where discrete events happen – for example, parts processing during manufacturing or document processing during document circulation. There are many other spheres where discrete event simulation can be successfully applied. Moreover, in case you need to extend your model and go beyond pure discrete event simulation, you can seamlessly use any other AnyLogic modeling techniques in your model. For instance, you can use statecharts to describe complex, non-trivial behavior. For more information about the modeling techniques and ways AnyLogic supports, please refer to AnyLogic Help.
* Bank Model
* Ophthalmology Department Model

# Pedestrian Simulation
## Pedestrian Simulation

AnyLogic provides the Pedestrian Library, a higher-level library for simulating pedestrian flows in “physical” environment. It allows creating models of pedestrian buildings (like subway stations, security checks, etc.) or streets (big number of pedestrians). The Pedestrian Library allows you to create flexible models, collect basic and advanced statistics, and effectively visualize the process you are modeling to validate and present your model. You may collect statistics on pedestrian density in different areas, to assure acceptable performance of service points with hypothetic load, estimate lengths of stay in specific areas, detect potential problems with interior geometry – effect of adding obstacles and many other applications. In models created with Pedestrian Library, pedestrians move in continuous space, reacting on different kinds of obstacles (walls, different kinds of areas) and other pedestrians.
In this tutorial you will learn how to create models with Pedestrian Library. We will create a simple illustrative example of subway entrance . This model demonstrates how to simulate simple pedestrian flow and services using AnyLogic Pedestrian Library
Note that there is a reference model Subway Entrance available representing the milestones of the editing. You can use it if you experience any difficulties creating a model and you would like to compare your model with the reference file. Use Sample Models page of the Welcome page to open this example.
Please refer to Pedestrian Library Reference Guide for more information about Pedestrian Library blocks and their functions and parameters.
You can run this model online.

### Subway Entrance Model

* Step 1. Creating a new model
* Step 2. Creating a model animation
* Step 3. Adding a passenger flow
* Step 4. Configuring the simulation
* Step 5. Running the model
* Step 6. Adding ticket control gates
* Step 7. Changing passenger arrival rate interactively
* Step 8. Adding ticket windows