Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update getting started #1395

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Project setup
################################################################################
cmake_minimum_required(VERSION 3.22 FATAL_ERROR)
project(JuPedSim VERSION 1.2.0 LANGUAGES CXX)
project(JuPedSim VERSION 1.3.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down
1 change: 1 addition & 0 deletions libsimulator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ if (BUILD_TESTS)
test/TestNeighborhoodSearch.cpp
test/TestPoint.cpp
test/TestSimulationClock.cpp
test/TestStage.cpp
test/TestUniqueID.cpp
)

Expand Down
2 changes: 1 addition & 1 deletion libsimulator/src/Stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Point NotifiableWaitingSet::Target(const GenericAgent& agent)
return slots[0];
}

const auto next_slot_index = occupants.size() == 0 ? 0 : occupants.size() - 1;
const auto next_slot_index = std::min(occupants.size(), slots.size() - 1);

for(size_t index = 0; index < next_slot_index; ++index) {
if(agent.id == occupants[index]) {
Expand Down
62 changes: 62 additions & 0 deletions libsimulator/test/TestStage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright © 2012-2024 Forschungszentrum Jülich GmbH
// SPDX-License-Identifier: LGPL-3.0-or-later
#include "GenericAgent.hpp"
#include "GeometryBuilder.hpp"
#include "Journey.hpp"
#include "Stage.hpp"

#include "gtest/gtest.h"

class StagesTests : public ::testing::Test
{
public:
NeighborhoodSearch<GenericAgent> neighborhoodSearch{2};
std::unique_ptr<CollisionGeometry> collisionGeometry{};

void SetUp() override
{
GeometryBuilder b{};
b.AddAccessibleArea({{-10, -10}, {10, -10}, {10, 10}, {-10, 10}});
collisionGeometry = std::make_unique<CollisionGeometry>(b.Build());
}

void TearDown() override {}
};

TEST_F(StagesTests, NotifiableWaitingSetTargetIsCorrect)
{
std::vector<Point> waitingPoints = {{-9, -9}, {9, -9}, {9, 9}, {-9, 9}};
NotifiableWaitingSet waitingSet(waitingPoints);

// Each agent gets the next target of the provided waiting points until all positions are
// occupied
for(size_t i = 0; i < waitingPoints.size(); ++i) {
GenericAgent agent(
GenericAgent::ID::Invalid,
Journey::ID::Invalid,
waitingSet.Id(),
waitingPoints[i],
{},
CollisionFreeSpeedModelData{});
neighborhoodSearch.AddAgent(agent);

const auto& target = waitingSet.Target(agent);
ASSERT_EQ(target, waitingPoints[i]);

waitingSet.Update(neighborhoodSearch, *collisionGeometry);
}

// Each next agent gets the last slot
for(size_t i = 0; i < 2; ++i) {
GenericAgent agentToLastWaitingSetPos(
GenericAgent::ID::Invalid,
Journey::ID::Invalid,
waitingSet.Id(),
{},
{},
CollisionFreeSpeedModelData{});
neighborhoodSearch.AddAgent(agentToLastWaitingSetPos);
const auto& target = waitingSet.Target(agentToLastWaitingSetPos);
ASSERT_EQ(target, waitingPoints.back());
}
}
10 changes: 5 additions & 5 deletions notebooks/getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"\n",
"Now, you are ready to set up your first simulation with *JuPedSim*.\n",
"\n",
"If you want to follow this Jupyter Notebook on your own machine, you can download it \n",
"{download}`here <getting_started.ipynb>`."
"To access this Jupyter Notebook on your local machine, you can download it \n",
"{download}`here <getting_started.ipynb>` along with the accompanying data file {download}`here <demo-data/bottleneck/040_c_56_h-.txt>`."
]
},
{
Expand All @@ -47,9 +47,9 @@
" :align: center\n",
"```\n",
"\n",
"The data for this experiment is available {download}`here <demo-data/bottleneck/040_c_56_h-.txt>`, which belongs to this [experimental series](https://doi.org/10.34735/ped.2018.1) and is part of the publication [\"Crowds in front of bottlenecks at entrances from the perspective of physics and social psychology\"](https://doi.org/10.1098/rsif.2019.0871).\n",
"We aim to replicate the bottleneck scenario described in the experimental series linked to this [study](https://doi.org/10.34735/ped.2018.1) and detailed in the publication [\"Crowds in front of bottlenecks at entrances from the perspective of physics and social psychology\"](https://doi.org/10.1098/rsif.2019.0871). \n",
"\n",
"In this guide, we want to simulate the same bottleneck scenario with *JuPedSim*.\n",
"Our objective in this guide is to simulate this scenario using *JuPedSim*.\n",
"\n",
"If you use *JuPedSim* in your work, please cite it using the following information from Zenodo:\n",
"\n",
Expand Down Expand Up @@ -583,7 +583,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down
Loading