# Simulation, AI, Optimization and Complexity

## What Are Simulations and Why Are They Useful?

Simulation has been called the third scientific method, after empirical experiments and analytical theory. The advantage that computational simulation holds over the other two methods is in how it enables us to explore complexity and draw conclusions about the principles driving complex systems.

Computer simulations are “what-if machines” that can represent an array of many possible worlds; they help surface emergent phenomena arising from simple rules you devise, such as Conway’s Game of Life.

So simulations are tools for thought, and they are most useful when exploring complex and dynamic situations with many components that are in non-linear relationships to each other. Warren Weaver described them as “problems of organized complexity.” They can imitate, or recreate, a real-world process or situation.1

Many people are familiar with simulations that come in the form of games. We have driving simulations, flight simulations, farming simulations, and simulations that allow us to create whole cities, like SimCity or Cities: Skylines.

While most simulations include a visual rendering like the one above, which helps us more deeply grasp how they work, their essence is to show relations between variables, like an algebraic equation does; e.g. `profit = revenue – expenses`.

Simulating many different revenue and expense levels gives us an idea of how profit might behave under different conditions. In fact, the most common simulation tool is a simple spreadsheet such as Excel.

So businesses were early creators of simulations to imitate, or model, parts of their operations, which go beyond revenue to include supply chains, logistics, or manufacturing. Those simulations were the basis of predictions and planning; i.e. making optimal decisions. Simulations are not only tools for thought, but tools for action. They allow us to envision how we might shift the simulation’s response toward the outcome we desire.

## Optimization for Simulations

Changes to one part of the system can have an unforeseen impact on another. Sometimes those changes are deliberate improvements, other times they are external shocks that impact operations, such as the widespread supply and demand disruptions occurring during the COVID-19 lockdowns.

Simulation modelers often seek to explore changes in a system that will help them achieve better outputs to reach their goals; e.g. in business, it would greater profitability or efficiency, while in public health, it might be greater immunity and fewer deaths. Simulations help them surface causal relationships that they wouldn’t otherwise see.

So people use simulations to explore a space of possibilities; i.e. “What happens if I change the model like this, or that…?” And that exploration will often have the goal of improving operations. This goes beyond the analysis of historical data, which shows what was done in the past, to reveal what might happen if you took an action for the first time, which is only possible because you have modeled the logic of your system in the simulation in order to interact with it.

A business might seek the best way to, say, configure a supply chain. Let’s say it has a bunch of different factories with different capacities, a changing queue of items to produce, variable demand, and shifting conditions (like weather) that affect how goods are delivered. Adjusting several parameters in that complex system at once, to see what would happen over many time steps, is only possible with simulations. Finding the best path is only possible through optimization, which can automatically evaluate many possible configurations of the simulation, to arrive at the best one.

Optimization allows users to go beyond slow, manual exploration within a simulation. Various optimization tools exist, from solvers to search algorithms. But for truly complex systems, the only possible optimizer is deep reinforcement learning. DRL can crack previously unsolvable problems, and in using it, we can begin to steer emergent behavior within complex systems.

## Why Complexity Matters

Complexity matters because many small components can organize themselves to produce emergent behavior on a level more meaningful to us.

• Many molecules organize as a cell
• Many cells as a body
• Many bodies as a team

At each scale, the relevant entity is a superorganism composed of the entities one level below.

When we analyze teams, we see that they behave, and coalesce, in different ways that impact their performance. Many of the behaviors that maximize team performance are difficult to measure and track on the level of the individual; indeed, by incenting individuals to achieve certain personal metrics (in basketball, it might be rebounds), teams can undermine their own goals. Attempting to solve a problem at the wrong level of abstraction only makes it worse. Simulations allow us to observe agents as they organize themselves into a larger operative entity.

Business hire invididuals, but those individuals are part of larger efforts based on teamwork. The same is true of machines in factories and warehouses. Individual robots may be built, but the total output of the factory is a function of how their behavior is coordinated. Certain algorithms allow us to monitor and coordinate that collective action, and one of those is deep reinforcement learning. It is an algorithm that can optimize amid complexity. You might that deep RL is the answer to the complexity that plagues the coordination of collective action.

## Open-source Simulation Tools

NetLogo is a multi-agent programmable modeling environment.

### Simpy

Simpy is an open-source Python framework for modeling discrete events.

### PySCeS

PySCeS provides a variety of tools for the analysis of cellular systems.

### ManPy

Discrete event simulation in Python.

### Project Chrono

An Open Source Multi-physics Simulation Engine.

## Simulation Optimization Tools

### Pathmind

Deep reinforcement learning that works with AnyLogic and open-source Python. Performs significantly better than solver baselines on complex, multi-agent and multi-objective problems.

### Gurobi

A popular mathematical solver, built by the team that initially built IBM CPlex.

### IBM CPlex

A solver integrated with IBM’s many other enterprise technologies.

### OptQuest

A solver integrated with several popular simulation software packages.

## Games as Simulation tools

Games have a long history as simulation tools, starting with Sim City.

### Cities Skylines

Used with modifications to simulate many urban planning and disaster relief efforts.

### Unity

Used to simulate smaller scale vehicle movement scenarios, among others.

## Commercial Simulation Software Tools for Business Operations

The simulation software tools listed below can be used to model business processes.

### AnyLogic

AnyLogic is a popular simulation software tool for stock-and-flow models; e.g. simulations of supply chains, logistics, warehousing, and manufacturing, among other setttings. AnyLogic integrates with optimization tools such as the mathematical solvers OptQuest and Gurobi, as well as Pathmind’s AI optimization tool, which uses reinforcement learning for multi-agent scenarios.

## Footnotes

1) While our focus is on computational simulations, it is interesting to note that novels are a form of simulation built with words. Human imagination is often a simulation built with biological neurons. But we are interested in computer-based models that digitally capture some aspect of a world built with atoms.

## Other Resources on Simulations and Complexity

### Chris Nicholson

Chris Nicholson is the CEO of Pathmind. He previously led communications and recruiting at the Sequoia-backed robo-advisor, FutureAdvisor, which was acquired by BlackRock. In a prior life, Chris spent a decade reporting on tech and finance for The New York Times, Businessweek and Bloomberg, among others.