utils

constants

Constants used in the application.

streamlit_app.utils.constants.FIRST_TAB_NAME: str = 'One agent'

Name fo the first tab within the Streamlit application

streamlit_app.utils.constants.SECOND_TAB_NAME: str = 'Crowd'

Name fo the second tab within the Streamlit application

streamlit_app.utils.constants.THIRD_TAB_NAME: str = 'Anthropometry'

Name fo the third tab within the Streamlit application

streamlit_app.utils.constants.FOURTH_TAB_NAME: str = 'About'

Name fo the fourth tab within the Streamlit application

streamlit_app.utils.constants.PROJECT_NAME: str = 'LEMONS'

Project name

streamlit_app.utils.constants.DEFAULT_HEIGHT_MIN: float = 100.0

Minimum pedestrian height (cm)

streamlit_app.utils.constants.DEFAULT_HEIGHT_MAX: float = 230.0

Maximum pedestrian height (cm)

streamlit_app.utils.constants.MAX_TRANSLATION_X: float = 200.0

Maximum translation along X axis allowed (cm)

streamlit_app.utils.constants.MAX_TRANSLATION_Y: float = 200.0

Maximum translation along Y axis allowed (cm)

streamlit_app.utils.constants.DEFAULT_SEX: Literal['male', 'female'] = 'male'

Default sex of the pedestrian

streamlit_app.utils.constants.DEFAULT_BOUNDARY_X: float = 200.0

Default boundary length along X axis (cm)

streamlit_app.utils.constants.DEFAULT_BOUNDARY_X_MIN: float = 50.0

Minimum boundary length along X axis (cm)

streamlit_app.utils.constants.DEFAULT_BOUNDARY_X_MAX: float = 2000.0

Maximum boundary length along X axis (cm)

streamlit_app.utils.constants.DEFAULT_BOUNDARY_Y: float = 200.0

Default boundary length along Y axis (cm)

streamlit_app.utils.constants.DEFAULT_BOUNDARY_Y_MIN: float = 50.0

Minimum boundary length along Y axis (cm)

streamlit_app.utils.constants.DEFAULT_BOUNDARY_Y_MAX: float = 2000.0

Maximum boundary length along Y axis (cm)

streamlit_app.utils.constants.DEFAULT_AGENT_NUMBER: int = 4

Default number of agents in the crowd

streamlit_app.utils.constants.DEFAULT_AGENT_NUMBER_MIN: int = 1

Minimum number of agents in the crowd

streamlit_app.utils.constants.DEFAULT_AGENT_NUMBER_MAX: int = 300

Maximum number of agents in the crowd

streamlit_app.utils.constants.DEFAULT_REPULSION_LENGTH_MIN: float = 1.0

Minimum repulsion strength between agents during crowd generation

streamlit_app.utils.constants.DEFAULT_REPULSION_LENGTH_MAX: float = 70.0

Maximum repulsion strength between agents during crowd generation

streamlit_app.utils.constants.DEFAULT_WALL_INTERACTION: bool = False

Presence or not of wall interactions during the simulation

streamlit_app.utils.constants.SHOW_DEV: bool = False

Show or not developer options in the application to help debugging

functions

Utility functions for plotting.

streamlit_app.utils.functions.extract_coordinates(multi_polygon)[source]

Extract x and y coordinates from a MultiPolygon object.

Parameters:

multi_polygon (MultiPolygon) -- A MultiPolygon object containing one or more polygons.

Returns:

A tuple of two numpy arrays:
  • The first array contains the x-coordinates.

  • The second array contains the y-coordinates.

Return type:

tuple[NDArray[np.float64], NDArray[np.float64]]

streamlit_app.utils.functions.filter_mesh_by_z_threshold(all_points, all_triangles, z_threshold=0.3)[source]

Filter a 3D mesh by removing vertices and triangles below a given z-coordinate threshold.

Parameters:
  • all_points (NDArray[np.float64]) -- An array representing the coordinates of the vertices in the mesh.

  • all_triangles (NDArray[np.float64]) -- An array representing the indices of the vertices forming the triangles in the mesh.

  • z_threshold (float) -- The z-coordinate threshold below which vertices and associated triangles are removed. Default is 0.3.

Return type:

tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]]

Returns:

  • filtered_points (NDArray[np.float64]) -- An array representing the coordinates of the filtered vertices.

  • filtered_triangles (NDArray[np.float64]) -- An array representing the indices of the vertices forming the filtered triangles.

Notes

  • N is the number of vertices in the original mesh.

  • M is the number of triangles in the original mesh.

  • P and Q are the numbers of vertices and triangles remaining after filtering, respectively.

streamlit_app.utils.functions.update_progress_bar(progress_bar, status_text, frac)[source]

Update a progress bar and status text based on the given completion fraction.

Parameters:
  • progress_bar (DeltaGenerator) -- The Streamlit progress bar object to be updated. Typically created using st.progress().

  • status_text (DeltaGenerator) -- The Streamlit text object to display the status message. Typically created using st.text().

  • frac (float) -- A value between 0 and 1 representing the completion fraction of the task. For example, frac=0.5 indicates 50% completion.

Raises:

ValueError -- If frac is not in [0,1].

Return type:

None

streamlit_app.utils.functions.compute_range(agent, axis)[source]

Compute the range (maximum - minimum) of coordinates along a given axis for an agent's 3D shapes.

Parameters:
  • agent (Agent) -- The agent object containing 3D shape information.

  • axis (Literal["x", "y"]) -- The axis along which to compute the range.

Returns:

The range (maximum - minimum) of coordinates along the specified axis.

Return type:

float

Raises:

ValueError -- If the axis is not 'x' or 'y', if agent.shapes3D or agent.shapes3D.shapes is None, or if any shape in agent.shapes3D.shapes is not a MultiPolygon.

logging

Logging setup for the Streamlit application.

streamlit_app.utils.logging.setup_logging()[source]

Set up logging configuration for the application.

Return type:

None

Examples

>>> import logging
>>> setup_logging()
>>> logging.info("This is an informational message.")
2025-05-05 13:42:00 - INFO - your_script.py:25 - This is an informational message.
>>> logging.warning("This is a warning message.")
2025-05-05 13:42:00 - WARNING - your_script.py:26 - This is a warning message.