Table of Contents
=================
* [Evacuation Demo](#evacuation-demo)
* [A Self-adaption Cellular Automaton Model](#a-self-adaption-cellular-automaton-model)
* [Acknowledgement](#acknowledgement)
* [Problem Review](#problem-review)
* [Glossary](#glossary)
* [Basic Assumptions](#basic-assumptions)
* [Function Implementations](#function-implementations)
* [Canvas Drawing](#canvas-drawing)
* [Movement](#movement)
* [Canvas Refresh](#canvas-refresh)
* [Additional Direction](#additional-direction)
# Evacuation Demo
<p align="center"><img src ="images/passage.gif"></p>
# A Self-adaption Cellular Automaton Model
[![LICENSE](https://img.shields.io/cocoapods/l/AFNetworking.svg)](https://github.com/Hephaest/2019ICM-D/blob/master/LICENSE)
[![Matlab](https://img.shields.io/badge/MATLAB-R2018b-orange.svg)](https://www.oracle.com/technetwork/java/javase/8u202-relnotes-5209339.html)
English | [中文](README_CN.md)
Last updated on `2019/07/18`
This project is just one part of the solutions of 2019 ICM Problem D - a self-adaption cellular automaton model to monitor visitor’s behavior in case of a stampede.
# Acknowledgement
Thanks to Dr.Zhou! He inspired me by his cellular automaton model.
I rewrote his code to fulfill the requirements of 2019 ICM Problem D.
You can find the original code at: https://github.com/MCMICM/2005MCM-B.
My code focus on the interactions between the visitors, the rules to guide the visitors to evacuation.
# Problem Review
The increasing number of terror attacks in France requires a review of the emergency evacuation plans at many popular destinations. Your ICM team is helping to design evacuation plans at the Louvre in Paris, France. In general, the goal of evacuation is to have all occupants leave the building as quickly and safely as possible. Upon notification of a required evacuation, individuals egress to and through an optimal exit in order to empty the building as quickly as possible.
The Louvre is one of the world’s largest and most visited art museum, receiving more than 8.1 million visitors in 2017. The number of guests in the museum varies throughout the day and year, which provides challenges in planning for regular movement within the museum. The diversity of visitors -- speaking a variety of languages, groups traveling together, and disabled visitors -- makes evacuation in an emergency even more challenging.
The Louvre has five floors, two of which are underground.
<p align="center"><img src ="images/2019_ICM_Problem_D.jpg"></p>
The 380,000 exhibits located on these five floors cover approximately 72,735 square meters, with building wings as long as 480 meters or 5 city blocks. The pyramid entrance is the main and most used public entrance to the museum. However, there are also three other entrances usually reserved for groups and individuals with museum memberships: the Passage Richelieu entrance, the Carrousel du Louvre entrance, and the Portes Des Lions entrance.
Only *emergency personnel* and museum officials know the actual number of total available exit points (service doors, employee entrances, VIP entrances, emergency exits, and old secret entrances built by the monarchy, etc.). While public awareness of these exit points could provide additional strength to an evacuation plan, their use would simultaneously cause security concerns due to the lower or limited security postures at these exits compared with level of security at the four main entrances. Thus, when creating your model, your team should consider carefully when and how any additional exits might be utilized.
Your supervisor wants your ICM team to develop an emergency evacuation model that allows the museum leaders to explore a range of options to evacuate visitors from the museum, while also allowing emergency personnel to enter the building as quickly as possible. It is important to identify potential *bottlenecks* that may limit movement towards the exits. The museum emergency planners are especially interested in an adaptable model that can be designed to address a broad set of considerations and various types of potential threats. Each threat has the potential to alter or remove segments of possible routes to safety that may be essential in a single optimized route. Once developed, validate your model(s) and discuss how the Louvre would implement it.
Based on the results of your work, propose policy and procedural recommendations for emergency management of the Louvre. Include any applicable crowd management and control procedures that your team believes are necessary for the safety of the visitors. Additionally, discuss how you could adapt and implement your model(s) for other large, crowded structures.
## Glossary
- **Bottlenecks** – places where movement is dramatically slowed or even stopped.
- **Emergency personnel** – people who help in an emergency, such as guards, fire fighters, medics, ambulance crews, doctors, and police.
# Basic Assumptions
- **Queue is organized by the first-in-first-out (FIFO) queue discipline**. This queue discipline represents that the first visitor who is in a waiting queue will be the first visitor to leave the entrance.
- **The queue length is relatively invariant**. Any individual follows the general principles to go forward and does not attempt to go beyond the individual in front if visitor and the person in front of the visitor have the same running speed.
- **Each visitor runs in a single direction**. Visitors run from the inside out and no longer returns to the interior of the building.
- **The probabilities of different ages on each floor are the same**. According to the Louvre Attendance and Frequentation reports from previous 4 years, assume that the proportion of normal adults is 79%, the proportion of young children is 12%, and the proportion of inconvenient walking people (the old, the blind, some people who are visually impaired, some people
who suffer from leg disability, etc) account for 9%.
- According to the statistics, assume that the walking speed of a normal adult is 0.75 m=s, and the running speed is no more than 3 m/s, the children’s movement speed is only 70% of normal adults, and movement speed of inconvenient people is only 70% of normal adults.
- According to the statistics, assume that the flux of the Portes Des Lions entrance is 6 person per second, the flux of the Passage Richelieu entrance is 6 person per second, the flux of the Carrousel du Louvre entrance is 6 person per second, and flux of the pyramid entrance is 14 person per second.
# Function Implementations
According to the tasks, the model should follow the additional assumptions:
- The number of visitors arriving at each exit (B1) in unit time approximately obeys the Normal distribution.
- Visitors run toward the nearest exit. The visitor will try to turn left or right to avoid the collision if the visitor's current speed is large than the speed of the front visitor or the obstacle in front of him or her. In addition, the visitor also has the ability to accelerate (but cannot exceed the maximum speed rate) or decelerate the running speed and stop for some reasons.
- Obstacles appear randomly, including flames, broken exhibits, stuffs left behind by visitors. However, over a period of time, these obstacles will be removed but new obstacles appear.
- According to congregational psychology, when visitors leave the exits, they will follow the path which is selected by more than half of the people.
The whole function implementations have been divided into 3 parts: `Canvas Drawing`, `Movement`, `Canvas Refresh`.
## Canvas Drawing
There are 4 basic object in a canvas, including `walls`, `passages`, `obstacles` and `visitors`. Each object has its own color, the appearances have been achieved by the following code:
```MATLAB
function h = showPassage(passage, h, n)
%
% showPassage To show the passage matrix as an image.
%
% Author: Hephaest
% July 18, 2019
%