Example #1
0
def test_train_capacity_feature(tmp_path, env):
    """
    The first train has a capacity of 15, the second train of 20. At the end of
    the simulation only 15 agents should remain.

    BUG: Currently the capacity can be exceeded if pedestrians enter in the
    same frame, hence the remaining pedestrians are treated as an upper bound.

    :param tmp_path: working directory of test execution
    :param env: global environment object
    """
    input_location = (env.systemtest_path / "train_tests" /
                      "train_test_max_agents")
    copy_all_files(src=input_location, 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)

    # Check agent count after the first train left
    first_train_leaving_index = int(trajectories.framerate * 15)
    assert trajectories.agent_count_in_frame(first_train_leaving_index) <= 35

    # Check agent count after the second train left
    second_train_leaving_index = int(trajectories.framerate * 30)
    assert trajectories.agent_count_in_frame(second_train_leaving_index) <= 15

    # Check agent count at the end of the simulation
    last_frame_index = trajectories.frame_count() - 1
    assert trajectories.agent_count_in_frame(last_frame_index) <= 15
Example #2
0
def test_train_feature_basic_functionality(tmp_path, env):
    """
    Simple scenario with pedestrians heading for the train. It is expected that
    all agents have left the simulation within 50 seconds.

    :param tmp_path: working directory of test execution
    :param env: global environment object
    """
    input_location = env.systemtest_path / "train_tests" / "simple_train_test"
    copy_all_files(src=input_location, 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() <= 50.0
Example #3
0
def run_scenario(*, jpscore_path: Path, scenario_path: Path,
                 working_directory: Path):
    working_directory.mkdir(parents=True, exist_ok=True)
    copy_all_files(
        src=scenario_path,
        dest=working_directory,
    )

    jpscore_driver = JpsCoreDriver(jpscore_path=jpscore_path,
                                   working_directory=working_directory)
    logging.info(f"Running {scenario_path.name}")

    start_time = time.time()
    jpscore_driver.run()
    end_time = time.time()
    return end_time - start_time
Example #4
0
def test_juelich_1_free_flow_movement_in_corridor(tmp_path, env):
    """
    A pedestrian that starts in the middle of a corridor (i.e. is not
    influenced by the walls) should move with its free flow velocity towards
    the exit.

    :param tmp_path: working directory of test execution
    :param env: global environment object
    """
    input_location = env.systemtest_path / "juelich_tests" / "test_1"
    copy_all_files(src=input_location, 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)
    expected_evac_time = 10.0
    assert trajectories.runtime() <= expected_evac_time