forked from PedestrianDynamics/jupedsim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e0374f
commit 8a31a90
Showing
1 changed file
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#! /usr/bin/env python3 | ||
|
||
# Copyright © 2012-2024 Forschungszentrum Jülich GmbH | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
import pathlib | ||
import sys | ||
|
||
import shapely | ||
|
||
import jupedsim as jps | ||
|
||
|
||
def main(): | ||
geometry = shapely.GeometryCollection(shapely.box(0, -2.5, 50, 2.5)) | ||
exit_polygon = shapely.box(48, -2.5, 50, 2.5) | ||
|
||
trajectory_file = "example_6.sqlite" | ||
simulation = jps.Simulation( | ||
model=jps.CollisionFreeSpeedModelV2(), | ||
geometry=geometry, | ||
trajectory_writer=jps.SqliteTrajectoryWriter( | ||
output_file=pathlib.Path(trajectory_file) | ||
), | ||
) | ||
|
||
exit_id = simulation.add_exit_stage(exit_polygon) | ||
journey = jps.JourneyDescription([exit_id]) | ||
journey_id = simulation.add_journey(journey) | ||
|
||
motivated_start_positions = jps.distribute_by_number( | ||
polygon=shapely.box(0, -2.5, 5, 2.5), | ||
number_of_agents=30, | ||
distance_to_agents=0.3, | ||
distance_to_polygon=0.2, | ||
) | ||
|
||
for position in motivated_start_positions: | ||
simulation.add_agent( | ||
jps.CollisionFreeSpeedModelV2AgentParameters( | ||
journey_id=journey_id, | ||
stage_id=exit_id, | ||
position=position, | ||
radius=0.12, | ||
strength_neighbor_repulsion=8, | ||
range_neighbor_repulsion=0.1, | ||
strength_geometry_repulsion=5, | ||
range_geometry_repulsion=0.1, | ||
) | ||
) | ||
|
||
slow_start_positions = jps.distribute_by_number( | ||
polygon=shapely.box(15, -2.5, 20, 2.5), | ||
number_of_agents=30, | ||
distance_to_agents=0.3, | ||
distance_to_polygon=0.2, | ||
) | ||
|
||
for position in slow_start_positions: | ||
simulation.add_agent( | ||
jps.CollisionFreeSpeedModelV2AgentParameters( | ||
journey_id=journey_id, | ||
stage_id=exit_id, | ||
position=position, | ||
radius=0.12, | ||
strength_neighbor_repulsion=30, | ||
range_neighbor_repulsion=0.1, | ||
strength_geometry_repulsion=15, | ||
range_geometry_repulsion=0.1, | ||
v0=0.3, | ||
) | ||
) | ||
|
||
while simulation.agent_count() > 0: | ||
try: | ||
simulation.iterate() | ||
except KeyboardInterrupt: | ||
print("CTRL-C Recieved! Shuting down") | ||
sys.exit(1) | ||
print( | ||
f"Simulation completed after {simulation.iteration_count()} iterations" | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |