def test_juelich_12_obstructed_visibility(tmp_path, env, operational_model_id): """ Four pedestrians being simulated in a bottleneck. Pedestrians 0 and 1 have zero desired speed i.e. they will not move during the simulation whereas pedestrians 2 and 3 are heading towards the exit. The visibility between pedestrians 2 resp. 3 and 0 resp. 2 is obstructed by a wall resp. an obstacle. Expected results: Pedestrians 2 and 3 should not deviate from the horizontal dashed line. :param tmp_path: working directory of test execution :param env: global environment object """ input_location = env.systemtest_path / "juelich_tests" / "test_12" template_path = input_location / "inifile.template" inifile_path = tmp_path / "inifile.xml" instanciate_tempalte( src=template_path, args={"operational_model_id": operational_model_id}, dest=inifile_path, ) copy_files( sources=[input_location / "geometry.xml"], dest=tmp_path, ) jpscore_driver = JpsCoreDriver(jpscore_path=env.jpscore_path, working_directory=tmp_path) jpscore_driver.run() trajectories = load_trajectory(jpscore_driver.traj_file) agent_path = trajectories.path(2) y = agent_path[:, 3] dy = numpy.sum(numpy.abs(numpy.diff(y))) tolerance = 0.005 assert dy < tolerance
def test_router_corridor_close(tmp_path, env, router_id): """ :param tmp_path: working directory of test execution :param env: global environment object """ input_location = (env.systemtest_path / "router_tests" / "test_corridor_close") template_path = input_location / "inifile.template" inifile_path = tmp_path / "inifile.xml" instanciate_tempalte( src=template_path, args={"router_id": router_id}, dest=inifile_path, ) copy_files( sources=[input_location / "geometry.xml"], dest=tmp_path, ) jpscore_driver = JpsCoreDriver(jpscore_path=env.jpscore_path, working_directory=tmp_path) jpscore_driver.run() trajectories = load_trajectory(jpscore_driver.traj_file) agent_path = trajectories.path(2) assert get_intersetions_path_segment( agent_path, Segment(Point(9.5, -5), Point(9.5, 5)))
def test_juelich_8_obstacle_avoidance(tmp_path, env, operational_model_id): """ Expected result: The pedestrian should avoid the obstacle and exit the room without overlapping with the obstacle. :param tmp_path: working directory of test execution :param env: global environment object """ input_location = env.systemtest_path / "juelich_tests" / "test_8" template_path = input_location / "inifile.template" inifile_path = tmp_path / "inifile.xml" instanciate_tempalte( src=template_path, args={"operational_model_id": operational_model_id}, dest=inifile_path, ) copy_files( sources=[input_location / "geometry.xml"], dest=tmp_path, ) jpscore_driver = JpsCoreDriver(jpscore_path=env.jpscore_path, working_directory=tmp_path) jpscore_driver.run() trajectories = load_trajectory(jpscore_driver.traj_file) assert trajectories.runtime() <= 45.0
def test_juelich_3_single_pedestrian_moving_in_a_corridor_with_a_desired_direction( tmp_path, env, seed, exit_crossing_strategy): """ A pedestrian is started from a random position in a holding area. This test should be repeated with different initial positions. Expected result: The pedestrians should be able to reach the marked goal in all repetitions of the test. :param tmp_path: working directory of test execution :param env: global environment object :param seed: value to use for the simulation :param exit_crossing_strategy: exit strategy id to use """ input_location = env.systemtest_path / "juelich_tests" / "test_3" template_path = input_location / "inifile.template" inifile_path = tmp_path / "inifile.xml" instanciate_tempalte( src=template_path, args={ "seed": seed, "exit_crossing_strategy": exit_crossing_strategy }, dest=inifile_path, ) copy_files(sources=[input_location / "geometry.xml"], dest=tmp_path) jpscore_driver = JpsCoreDriver(jpscore_path=env.jpscore_path, working_directory=tmp_path) jpscore_driver.run() trajectories = load_trajectory(jpscore_driver.traj_file) agent_path = trajectories.path(2) assert trajectories.runtime() < 10.0 assert numpy.any(agent_path[:, 2] > 8.5)
def test_juelich_2_single_pedestrian_moving_in_a_corridor( tmp_path, env, operational_model_id): """ Rotating the same geometry as in test 1 around the z−axis by an arbitrary angle e.g. 45deg should lead to the evacuation time of 10 s. :param tmp_path: working directory of test execution :param env: global environment object :param operational_model_id this test is parametrized for two models, the ids have to match the model ids in the template file """ input_location = env.systemtest_path / "juelich_tests" / "test_2" template_path = input_location / "inifile.template" inifile_path = tmp_path / "inifile.xml" instanciate_tempalte( src=template_path, args={"operational_model_id": operational_model_id}, dest=inifile_path, ) copy_files(sources=[input_location / "geometry.xml"], dest=tmp_path) jpscore_driver = JpsCoreDriver(jpscore_path=env.jpscore_path, working_directory=tmp_path) jpscore_driver.run() trajectories = load_trajectory(jpscore_driver.traj_file) agent_path = trajectories.path(2) d_x = max(agent_path[:, 2]) - min(agent_path[:, 2]) d_y = max(agent_path[:, 3]) - min(agent_path[:, 3]) beeline_distance = numpy.sqrt(d_x**2 + d_y**2) v_expected = 1.0 time_limit = (beeline_distance / v_expected) + 0.1 assert trajectories.runtime() <= time_limit
def test_juelich_11_geo_room_subroom_structure(tmp_path, env, operational_model_id): """ The same geometry is constructed differently The whole geometry is designed as a rooms (i.e. utility space) The geometry is designed by dividing the utility space in connected subrooms. Distribute randomly pedestrians in all sub-rooms of the geometry and repeat the simulation to get a certain statistical significance. Expected results: The mean value of the evacuation times calculated from both cases should not differ. :param tmp_path: working directory of test execution :param env: global environment object """ input_location = env.systemtest_path / "juelich_tests" / "test_11" template_path_a = input_location / "inifile_a.template" template_path_b = input_location / "inifile_b.template" tmp_path_a = tmp_path / "a" tmp_path_b = tmp_path / "b" tmp_path_a.mkdir() tmp_path_b.mkdir() inifile_path_a = tmp_path_a / "inifile.xml" instanciate_tempalte( src=template_path_a, args={"operational_model_id": operational_model_id}, dest=inifile_path_a, ) copy_files( sources=[input_location / "geometry_a.xml"], dest=tmp_path_a, ) inifile_path_b = tmp_path_b / "inifile.xml" instanciate_tempalte( src=template_path_b, args={"operational_model_id": operational_model_id}, dest=inifile_path_b, ) copy_files( sources=[input_location / "geometry_b.xml"], dest=tmp_path_b, ) jpscore_driver_a = JpsCoreDriver(jpscore_path=env.jpscore_path, working_directory=tmp_path_a) jpscore_driver_a.run() jpscore_driver_b = JpsCoreDriver(jpscore_path=env.jpscore_path, working_directory=tmp_path_b) jpscore_driver_b.run() trajectories_a = load_trajectory(jpscore_driver_a.traj_file) trajectories_b = load_trajectory(jpscore_driver_b.traj_file) assert numpy.allclose(trajectories_a.data, trajectories_b.data, 0.001)
def test_juelich_4_single_pedestrian_moving_in_a_corridor_with_obstacle( tmp_path, env, operational_model_id): """ Two pedestrians are aligned in the same room. The second pedestrian from left is standing and will not move during the test. Expected result: Pedestrian left should be able to overtake the standing pedestrian. :param tmp_path: working directory of test execution :param env: global environment object :param operational_model_id this test is parametrized for two models, the ids have to match the model ids in the template file """ input_location = env.systemtest_path / "juelich_tests" / "test_4" template_path = input_location / "inifile.template" inifile_path = tmp_path / "inifile.xml" instanciate_tempalte( src=template_path, args={"operational_model_id": operational_model_id}, dest=inifile_path, ) copy_files(sources=[input_location / "geometry.xml"], dest=tmp_path) jpscore_driver = JpsCoreDriver(jpscore_path=env.jpscore_path, working_directory=tmp_path) jpscore_driver.run() trajectories = load_trajectory(jpscore_driver.traj_file) agent_path3 = trajectories.path(3) agent_path4 = trajectories.path(4) x_1 = agent_path3[:, 2] y_1 = agent_path3[:, 3] x_2 = agent_path4[:, 2] y_2 = agent_path4[:, 3] eps = 0.3 # 10 cm x_min = x_2[0] - eps x_max = x_2[0] + eps y_min = y_2[0] - eps y_max = y_2[0] + eps lx = numpy.logical_and(x_1 > x_min, x_1 < x_max) ly = numpy.logical_and(y_1 > y_min, y_1 < y_max) overlap = (lx * ly).any() assert not overlap