Education Featured

Simulation Optimization with AnyLogic

Over the last years, I have worked on various research projects requiring the combination of simulation and optimization methods. It is a powerful tool to investigate complex setting with different input and influencing factors. I mostly use the simulation software package AnyLogic to accomplish this, which allows one to add optimization procedures coded in Java. This post provides an example of such a combination with AnyLogic.

Let’s refer to the following disaster relief setting. It assumes random and dynamic demand to be served by relief forces. Each shipment originates north of the river and has to be brought to a store south of the river, denoted in green. Transshipment of goods can only be performed at one of the blue dots, however, due to operational constraints, only a limited number of transshipment points can be operated simultaneously. Consequently, the solution procedures have to find the best set of points considering various uncertainties in the system. To accomplish this, the system runs a Tabu Search, which uses an agent-based simulation to evaluate solutions and model randomness. Furthermore, routing and GIS integration is facilitated.

The following video gives a short examples. It contains of three steps: (i) running the simulation with all transshipments (blue) points open; (ii) running an optimization procedure to find the most promising ones; (iii) presenting the solution.

The implementation of this simulation optimization framework in AnyLogic was done in the following way:

  1. Create the simulation

As a first step, a simulation is created. Agents are identified and processes are modeled.

  1. Create a ‘Custom experiment’ in AnyLogic

To integrate the optimization procedure, a custom experiment is created. Therefore, the optimization procedure can be coded directly within the custom experiment or called externally. In our case, we use a metaheuristic solution procedure based on Tabu Search. It uses multiple simulation runs to evaluate a single setting. The custom experiments changes input parameter, runs the simulation multiple times and returns the solution value of a setting. To enable such computations efficiently, make sure to increase memory and run simulation replications in parallel. See the AnyLogic API reference on class ExperimentCustom for additional implementation guidance.

  1. Return the results of the optimization procedure to AnyLogic

In the presented case, open hubs are indicated with a binary variable, set and updated by the optmization procedure. At the start of a run, the simulation checks which points are active. With more recent versions of AnyLogic (starting from AnyLogic 7.2), this changes can be further directly implemented in the built-in database.

  1. Re-run the simulation with the adjusted input

The next run of the simulation automatically presents the optimization results to the user. Furthermore, you can output results and present statistics in multiple ways. One other interesting option is to start multiple optimization experiments to analyze the impact of varying parameters (e.g., the number of transshipment points to select or demand volume).

As shown, simulation optimization enables the investigation of various scenarios under uncertain conditions. Nevertheless, run times and the resulting trade-off between improving and evaluating solutions are common obstacles, which have to be closely considered when developing such procedures.


–          Fikar, C, Gronalt, M, Hirsch, P (2016) A decision support system for coordinated disaster relief distribution. Expert Systems with Applications 57, 104-116. DOI:; Kudos:

–          AnyLogic – Multimethod Simulation Software:

3 comments on “Simulation Optimization with AnyLogic

  1. Pingback: Simulations to Improve Flood Response Skills – Christian Fikar

  2. Pingback: Combining Agent-Based Simulations with Optimization Procedures – Christian Fikar

  3. Pingback: Using GraphHopper within Simulations – Christian Fikar

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: