jupedsim.simulation#

Module Contents#

class Simulation(*, model: jupedsim.models.CollisionFreeSpeedModel | jupedsim.models.GeneralizedCentrifugalForceModel, geometry: str | shapely.GeometryCollection | shapely.Polygon | shapely.MultiPolygon | shapely.MultiPoint | list[tuple[float, float]], dt: float = 0.01, trajectory_writer: jupedsim.serialization.TrajectoryWriter | None = None, **kwargs: Any)[source]#

Defines a simulation of pedestrian movement over a continuous walkable area.

Movement of agents is described with Journeys, Stages and Transitions. Agents can be added and removed at will. The simulation processes one step at a time. No automatic stop condition exists. You can simulate multiple disconnected walkable areas by instantiating multiple instances of simulation.

Creates a Simulation.

Parameters:
Keyword Arguments:

excluded_areas – describes exclusions from the walkable area. Only use this argument if geometry was provided as list[tuple[float, float]].

add_waypoint_stage(position: tuple[float, float], distance) int[source]#

Add a new waypoint stage to this simulation.

Parameters:
  • position (tuple[float, float]) – Position of the waypoint

  • distance – Minimum distance required to reach this waypoint

Returns:

Id of the new stage.

Return type:

int

add_queue_stage(positions: list[tuple[float, float]]) int[source]#

Add a new queue state to this simulation.

Parameters:

positions (list[tuple[float, float]]) – Ordered list of the waiting points of this queue. The first one in the list is the head of the queue while the last one is the back of the queue.

Returns:

Id of the new stage.

Return type:

int

add_waiting_set_stage(positions: list[tuple[float, float]]) int[source]#
Parameters:

positions (list[tuple[float, float]]) –

Return type:

int

add_exit_stage(polygon: str | shapely.GeometryCollection | shapely.Polygon | shapely.MultiPolygon | shapely.MultiPoint | list[tuple[float, float]]) int[source]#

Add an exit stage to the simulation.

Parameters:

polygon (str | shapely.GeometryCollection | shapely.Polygon | shapely.MultiPolygon | shapely.MultiPoint | list[tuple[float, float]]) –

Polygon without holes representing the exit stage. Polygon can be passed as:

  • list of 2d points describing the outer boundary

  • GeometryCollection consisting only out of Polygons, MultiPolygons and MultiPoints

  • MultiPolygon

  • Polygon

  • MultiPoint forming a “simple” polygon when points are interpreted as linear ring without repetition of the start/end point.

  • str with a valid Well Known Text. In this format the same WKT types as mentioned for the shapely types are supported: GEOMETRYCOLLETION, MULTIPOLYGON, POLYGON, MULTIPOINT. The same restrictions as mentioned for the shapely types apply.

Returns:

Id of the added exit stage.

Return type:

int

add_journey(journey: jupedsim.journey.JourneyDescription) int[source]#
Parameters:

journey (jupedsim.journey.JourneyDescription) –

Return type:

int

add_agent(parameters: jupedsim.models.GeneralizedCentrifugalForceModelAgentParameters | jupedsim.models.CollisionFreeSpeedModelAgentParameters) int[source]#
Parameters:

parameters (jupedsim.models.GeneralizedCentrifugalForceModelAgentParameters | jupedsim.models.CollisionFreeSpeedModelAgentParameters) –

Return type:

int

mark_agent_for_removal(agent_id: int) bool[source]#

Marks an agent for removal.

Marks the given agent for removal in the simulation. The agent will be removed from the simulation in the start of the next iterate() call. The removal will take place before any interaction between agents will be computed.

Parameters:

agent_id (int) – Id of the agent marked for removal

Returns:

marking for removal was successful

Return type:

bool

removed_agents() list[int][source]#
Return type:

list[int]

iterate(count: int = 1) None[source]#
Parameters:

count (int) –

Return type:

None

switch_agent_journey(agent_id: int, journey_id: int, stage_id: int) None[source]#
Parameters:
  • agent_id (int) –

  • journey_id (int) –

  • stage_id (int) –

Return type:

None

agent_count() int[source]#
Return type:

int

elapsed_time() float[source]#
Return type:

float

delta_time() float[source]#
Return type:

float

iteration_count() int[source]#
Return type:

int

agents() Iterable[jupedsim.agent.Agent][source]#
Return type:

Iterable[jupedsim.agent.Agent]

agent(agent_id) jupedsim.agent.Agent[source]#
Return type:

jupedsim.agent.Agent

agents_in_range(pos: tuple[float, float], distance: float) list[jupedsim.agent.Agent][source]#
Parameters:
Return type:

list[jupedsim.agent.Agent]

agents_in_polygon(poly: str | shapely.GeometryCollection | shapely.Polygon | shapely.MultiPolygon | shapely.MultiPoint | list[tuple[float, float]]) list[jupedsim.agent.Agent][source]#

Return all agents inside the given polygon.

Parameters:

poly (str | shapely.GeometryCollection | shapely.Polygon | shapely.MultiPolygon | shapely.MultiPoint | list[tuple[float, float]]) –

Polygon without holes in which to check for pedestrians. Polygon can be passed as:

  • list of 2d points describing the outer boundary

  • GeometryCollection consisting only out of Polygons, MultiPolygons and MultiPoints

  • MultiPolygon

  • Polygon

  • MultiPoint forming a “simple” polygon when points are interpreted as linear ring without repetition of the start/end point.

  • str with a valid Well Known Text. In this format the same WKT types as mentioned for the shapely types are supported: GEOMETRYCOLLETION, MULTIPOLYGON, POLYGON, MULTIPOINT. The same restrictions as mentioned for the shapely types apply.

Returns:

All agents inside given polygon.

Return type:

list[jupedsim.agent.Agent]

get_stage(stage_id: int)[source]#
Parameters:

stage_id (int) –

set_tracing(status: bool) None[source]#
Parameters:

status (bool) –

Return type:

None

get_last_trace() jupedsim.tracing.Trace[source]#
Return type:

jupedsim.tracing.Trace

get_geometry() jupedsim.geometry.Geometry[source]#
Return type:

jupedsim.geometry.Geometry