Pedestrian Density Map

AnyLogic enables collecting statistics on density of pedestrians in the simulated space and displaying this information on animation as a density map. 

Having added the Pedestrian Density Map element, you enable showing the pedestrian density map for your pedestrian simulation model. 

You will see that as pedestrians move in the simulated space, the layout is gradually painted in different colors. The color of every point of the space corresponds to the current density in this particular area. The density map is constantly repainted according to the actual values: when the density changes in some point, the color changes dynamically to reflect this change. In case of zero density the area is not painted at all.

The element itself acts as the color legend for the pedestrian density map. It displays the correspondence between density values and colors on the map (see the figure below. on the right side).


Red color indicates the critical density (by default it is equal to 1,5 pedestrians/m2). Blue color is used for low densities. When the density in some area is zero, the density map for this particular area is not drawn at all. 

The legend shown in the figure above tells us e.g. that yellow color on the map corresponds to the density 0,75 pedestrians/m2.  

You can change the logarithmic color scheme to linear, or some custom scheme, switch attenuation on/off, etc.

To add the density map

  1. Drag the element Pedestrian Density Map from the section Space Markup of  Pedestrian Library palette into the graphical editor. At the runtime it will show the density map legend. This density map legend helps to understand what colors on the density map mean what values. Legend displays the correspondence between density values and colors on the density map. 
  1. Now you can configure the properties of the density map as you need. Go to the properties of this element. Density map may either display maximum observed density values (if attenuation is turned off), or the actual density map for the recent period of time (if attenuation is turned on). With the attenuation being turned on, when the density goes down, the color for the corresponding zone on the density map changes correspondingly (but not immediately, with the specified delay). To turn the attenuation on, select the checkbox Enable attenuation.
  2. If you are not satisfied with the density map painted over the layout and making it hardly visible, you may increase the transparency level for the density map using the slider Transparency
  3. The density map is commonly used to detect the areas with critical densities. At the model runtime the areas with the density values equal or greater than the critical density threshold are painted with red color (if some other colors are not set using the Custom Color scheme). By default the critical density value is 1,5 pedestrians/m2. You can change this value in the parameter Critical density (shown in red), peds/m2.
  4. By default AnyLogic uses logarithmic color scheme. In this case the color changes logarithmically from the "minimum" (blue) color to the "maximum" (red) color. This color scheme is frequently used when you need to pay attention only to the density values close to the critical value threshold. You can change the logarithmic color scheme to the linear scheme by choosing Linear option of the parameter Color scheme. It is the simplest color scheme: color changes linearly from the "minimum" color to the "maximum" (red) color. You can even define your own color scheme by choosing the Custom Color scheme, see the properties description below.

Demo model: Pedestrian Density Map

Properties

General

Name – The name of the shape. The name is used to identify and access the shape from code.

Ignore – If selected, the shape is excluded from the model.

Visible on upper level – If selected, the shape is also visible on the upper level where this agent lives.

Lock – If selected, the shape is locked. Locked shapes do not react to mouse clicks - it is impossible to select them in the graphical editor until you unlock them. 

Visible – Here you specify whether the shape is visible on the animation at the model runtime, or not. Using the control, choose yes or no

Ground – Here you should specify the name of the ground where pedestrians move. This Pedestrian Density Map will display the density map for this particular ground.

Enable attenuation - If the checkbox is selected, the density map will be shown with attenuation. In this case the actual density map for the recent period of time will be shown, not the maximum observed densities. When the density goes down, the color for the corresponding zone on the density map changes correspondingly (but not immediately, with the specified delay).

Transparency - Here you can define the transparency level for the density map. Using the slider, choose the value from the range [0..100%]. 100% means fully transparent map (the density map is not visible), 0% means fully opaque density map (the animation underneath the density map is not visible at all).

Critical density - Here you specify the critical density value. All areas with the density values equal or greater than the critical density threshold will be painted on the animation with red (if some other colors are not set using the Custom Color scheme).

Color scheme - Here you can choose the color scheme for the density map. There are three alternative options available:
Logarithmic - The color will change logarithmically from the "minimum" (blue) color to the "maximum" (red) color. This color scheme is frequently used when you need to pay attention only to the density values close to the critical value threshold. 
Linear - The simplest color scheme: color will change linearly from the "minimum" (blue) color to the "maximum" (red) color. 
Custom - You can define your own color scheme and define the correspondence between colors and density values in the Custom color field below.

Custom color - [Visible if Color scheme is set to Custom] If you want to define some custom color scheme for the density map, here you should specify the expression that will return different colors depending on the density value (you can obtain the density value using the local variable density).
You can see the example of such an expression set up as the default value:
density > self.criticalDensity * 0.7 ? red: transparent

It defines that red color will be used for the densities that are higher than the specified threshold value (70% of the critical density value). For the lower densities, the density map will not be drawn at all.

Position and size

X – X-coordinate of the density map legend.

Y – Y-coordinate of the density map legend.

Width – Width of the density map legend (in pixels).

Height – Height of the density map legend (in pixels).

Advanced

Show in - Here you can choose whether you want the density map legend to be shown both In 2D and 3D animation, or in 2D only, or in 3D only.

Show name – If selected, the shape's name is displayed on a presentation diagram.

Functions

double currentDensity(double x, double y)-  Returns the current density value in the area neighboring the specified point, pedestrians/m². This value does not reflect exactly the current situation, it accumulates historic data. 
Parameters:  x - X-coordinate of the point
                    y - Y-coordinate of the point

double maximumDensity(double x, double y) -  Returns the maximum density value in the specified point, pedestrians/m².
Parameters:  x - X-coordinate of the point
                    y - Y-coordinate of the point

void show(boolean yes) - Shows/hides the density map. Shows the density map if true value was passed as the function argumnet; otherwise hides the map.