From b066925794b041724d4fdc46adb5c2615e778ce6 Mon Sep 17 00:00:00 2001 From: Mohcine Chraibi Date: Sat, 12 Oct 2024 09:52:52 +0900 Subject: [PATCH] Change geometry and close two gates --- files/inifile.json | 8 ++++---- simulation.py | 13 ++++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/files/inifile.json b/files/inifile.json index 07e1c7f..2cb8b70 100644 --- a/files/inifile.json +++ b/files/inifile.json @@ -8,9 +8,9 @@ "a_ped": 0.1, "d_ped": 0.4, "a_ped_min": 0.1, - "a_ped_max": 1.0, - "d_ped_min": 0.1, - "d_ped_max": 1.0, + "a_ped_max": 0.5, + "d_ped_min": 0.4, + "d_ped_max": 0.6, "a_wall": 0.4, "d_wall": 0.2, "radius": 0.10 @@ -19,7 +19,7 @@ "fps": 60, "time_step": 0.001, "number_agents": 50, - "simulation_time": 300 + "simulation_time": 500 }, "measurement_line": { "vertices": [ diff --git a/simulation.py b/simulation.py index deb0270..67497a7 100644 --- a/simulation.py +++ b/simulation.py @@ -147,8 +147,12 @@ def init_simulation( accessible_areas = parse_accessible_areas(_data) if from_file: geometry = from_wkt( - "POLYGON ((-8.88 -7.63, 8.3 -7.63, 8.3 27.95, -8.88 27.95, -8.88 -7.63), (-3.54 -1.13, -3.57 19.57, -1.52 19.57, -1.37 19.71, -1.37 21.09, -1.52 21.23, -1.67 21.23, -1.67 21.18, -1.545 21.18, -1.4200000000000002 21.065, -1.4200000000000002 19.735, -1.545 19.62, -3.6199999999999997 19.62, -3.59 -1.13, -3.54 -1.13), (3.57 -0.89, 3.64 19.64, 1.47 19.57, 1.32 19.71, 1.32 21.09, 1.47 21.23, 1.62 21.23, 1.62 21.18, 1.4949999999999999 21.18, 1.37 21.065, 1.37 19.735, 1.4949999999999999 19.62, 3.69 19.69, 3.6199999999999997 -0.89, 3.57 -0.89), (0.67 19.57, 0.82 19.71, 0.82 21.09, 0.67 21.23, 0.38 21.23, 0.23 21.09, 0.23 19.71, 0.38 19.57, 0.67 19.57), (-0.42 19.57, -0.27 19.71, -0.27 21.09, -0.42 21.23, -0.72 21.23, -0.87 21.09, -0.87 19.71, -0.72 19.57, -0.42 19.57))" + "POLYGON ((-8.88 -7.63, 8.3 -7.63, 8.3 27.95, -8.88 27.95, -8.88 -7.63), (-3.54 -1.13, -3.57 19.57, -1.52 19.57, -1.37 19.71, -0.87 19.71, -0.72 19.57, -0.42 19.57, -0.27 19.71, -0.27 21.09, -0.42 21.23, -0.72 21.23, -0.87 21.09, -1.37 21.09, -1.52 21.23, -1.67 21.23, -1.67 21.18, -1.545 21.18, -1.4200000000000002 21.065, -1.4200000000000002 19.735, -1.545 19.62, -3.6199999999999997 19.62, -3.59 -1.13, -3.54 -1.13), (3.57 -0.89, 3.64 19.64, 1.47 19.57, 1.32 19.71, 0.82 19.71, 0.67 19.57, 0.38 19.57, 0.23 19.71, 0.23 21.09, 0.38 21.23, 0.67 21.23, 0.82 21.09, 1.32 21.09, 1.47 21.23, 1.62 21.23, 1.62 21.18, 1.4949999999999999 21.18, 1.37 21.065, 1.37 19.735, 1.4949999999999999 19.62, 3.69 19.69, 3.6199999999999997 -0.89, 3.57 -0.89))" ) + # geometry with two doors + # geometry = from_wkt( + # "POLYGON ((-8.88 -7.63, 8.3 -7.63, 8.3 27.95, -8.88 27.95, -8.88 -7.63), (-3.54 -1.13, -3.57 19.57, -1.52 19.57, -1.37 19.71, -1.37 21.09, -1.52 21.23, -1.67 21.23, -1.67 21.18, -1.545 21.18, -1.4200000000000002 21.065, -1.4200000000000002 19.735, -1.545 19.62, -3.6199999999999997 19.62, -3.59 -1.13, -3.54 -1.13), (3.57 -0.89, 3.64 19.64, 1.47 19.57, 1.32 19.71, 1.32 21.09, 1.47 21.23, 1.62 21.23, 1.62 21.18, 1.4949999999999999 21.18, 1.37 21.065, 1.37 19.735, 1.4949999999999999 19.62, 3.69 19.69, 3.6199999999999997 -0.89, 3.57 -0.89), (0.67 19.57, 0.82 19.71, 0.82 21.09, 0.67 21.23, 0.38 21.23, 0.23 21.09, 0.23 19.71, 0.38 19.57, 0.67 19.57), (-0.42 19.57, -0.27 19.71, -0.27 21.09, -0.42 21.23, -0.72 21.23, -0.87 21.09, -0.87 19.71, -0.72 19.57, -0.42 19.57))" + # ) else: geometry = build_geometry(accessible_areas) # areas = build_areas(destinations, labels) @@ -226,7 +230,10 @@ def run_simulation( # ) logging.info(f"{default_range=}") with open("values.txt", "w", encoding="utf-8") as file_handle: - while simulation.elapsed_time() < _simulation_time: + while ( + simulation.elapsed_time() < _simulation_time + and simulation.agent_count() > 0 + ): simulation.iterate() if simulation.iteration_count() % 100 == 0: number_agents_in_simulation = simulation.agent_count() @@ -244,7 +251,7 @@ def run_simulation( params ) if motivation_i > 1: - logging.info( + logging.error( f"{simulation.iteration_count()}: {agent.id}: {motivation_i = }" ) v_0, time_gap = motivation_model.calculate_motivation_state(