Commit 3c5f575c authored by Mohcine Chraibi's avatar Mohcine Chraibi

Merge branch 'develop' into '270-statistics'

# Conflicts:
#   Simulation.cpp
parents 249b8dfb 1db2aa23
Pipeline #9701 failed with stages
in 29 seconds
......@@ -48,6 +48,8 @@ make-linux:
- bin
stage: compile
tags:
- linux
script:
- cd build
- make -j$nproc
......
......@@ -8,6 +8,10 @@ All notable changes to this project will be documented in this file.
- New attributes for sources `agent_id` and `time` for scheduling agent's appearance. See #258 for discussion. !14
- Router tests
- Option for printing progressbar: `<progressbar/>` cfc65f22
- Universal Floorfield: recognition of inside and outside of rooms, gridpoints know corresponding Subroom
- Floorfield Router: fixes of "Cannot find route for pedestrian ..." bugs; b1345915
- vtk-files (ff_router) can be written with `<write_VTK_files>true</write_VTK_files>` (see wiki)
- Exit_Strategie / Direction_Strategie: fixed bug 269, where agents get stuck at doors. b1345915
## v0.8.2 [2016-10-11]
......
......@@ -6,6 +6,7 @@
# -DBUILD_CPPUNIT_TEST=ON (default OFF) for unit tests
# -DUSE_DUAL_ABI=ON (default OFF) https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
# -D Boost_NO_SYSTEM_PATHS=true (default false) -D BOOST_ROOT=PATH_where_to_find_boost
# -D AIROUTER (default true)
#--------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
......@@ -13,10 +14,16 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0)
project(JPScore)
if(NOT AIROUTER)
set(AIROUTER false)
else()
set(AIROUTER true)
endif()
set(CMAKE_COLOR_MAKEFILE ON)
set(JPSCORE_MAJOR_VERSION 0)
set(JPSCORE_MINOR_VERSION 8)
set(JPSCORE_PATCH_VERSION 2)
set(JPSCORE_PATCH_VERSION 3)
set(JPSCORE_VERSION
${JPSCORE_MAJOR_VERSION}.${JPSCORE_MINOR_VERSION}.${JPSCORE_PATCH_VERSION})
message(STATUS "JPSCORE_VERSION: " ${JPSCORE_VERSION})
......@@ -63,7 +70,6 @@ if (NOT DEFINED PROCESSOR_COUNT)
list(LENGTH procs PROCESSOR_COUNT)
endif (EXISTS "${cpuinfo_file}")
# Windows:
if (WIN32)
set(PROCESSOR_COUNT "$ENV{NUMBER_OF_PROCESSORS}")
......@@ -198,9 +204,10 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
#boost
find_package(Boost COMPONENTS timer chrono system filesystem unit_test_framework REQUIRED)
if(AIROUTER)
#CGAL
find_package(CGAL REQUIRED)
find_package(CGAL REQUIRED) # for AI router
endif()
# test all cpp-files in Utest
if (BUILD_TESTING OR BUILD_CPPUNIT_TEST)
......@@ -336,24 +343,6 @@ set(source_files
routing/smoke_router/cognitiveMap/internnavigationnetwork.cpp
visiLibity/source_code/visilibity.cpp
#AI router
routing/ai_router/AIRouter.cpp
routing/ai_router/BrainStorage.cpp
routing/ai_router/cognitiveMap/associations.cpp
routing/ai_router/cognitiveMap/connection.cpp
routing/ai_router/cognitiveMap/cognitivemap.cpp
routing/ai_router/cognitiveMap/landmark.cpp
routing/ai_router/cognitiveMap/region.cpp
routing/ai_router/cognitiveMap/landmarknetwork.cpp
routing/ai_router/cognitiveMap/internnavigationnetwork.cpp
routing/ai_router/perception/visualsystem.cpp
routing/ai_router/perception/visibleenvironment.cpp
routing/ai_router/perception/cgalgeometry.cpp
routing/ai_router/perception/sign.cpp
routing/ai_router/Cortex.cpp
poly2tri/common/shapes.cpp
poly2tri/sweep/sweep_context.cpp
poly2tri/sweep/advancing_front.cpp
......@@ -426,23 +415,6 @@ set(header_files
routing/smoke_router/cognitiveMap/internnavigationnetwork.h
visiLibity/source_code/visilibity.hpp
#AI router
routing/ai_router/AIRouter.h
routing/ai_router/BrainStorage.h
routing/ai_router/cognitiveMap/associations.h
routing/ai_router/cognitiveMap/connection.cpp
routing/ai_router/cognitiveMap/cognitivemap.h
routing/ai_router/cognitiveMap/landmark.h
routing/ai_router/cognitiveMap/region.h
routing/ai_router/cognitiveMap/landmarknetwork.h
routing/ai_router/cognitiveMap/internnavigationnetwork.h
routing/ai_router/perception/visualsystem.h
routing/ai_router/perception/visibleenvironment.h
routing/ai_router/perception/cgalgeometry.h
routing/ai_router/perception/sign.h
routing/ai_router/Cortex.h
pedestrian/Pedestrian.h
pedestrian/PedDistributor.h
pedestrian/Ellipse.h
......@@ -463,8 +435,9 @@ set(header_files
tinyxml/tinystr.h
general/ArgumentParser.h
general/Configuration.h
general/Macros.h
general/randomnumbergenerator.h
general/randomnumbergenerator.h
geometry/Crossing.h
geometry/NavLine.h
......@@ -515,12 +488,55 @@ set(header_files
JPSfire/C_toxicity_analysis/ToxicityOutputhandler.h
)
SET(AIROUTER_SRC
#AI router
routing/ai_router/AIRouter.cpp
routing/ai_router/BrainStorage.cpp
routing/ai_router/cognitiveMap/associations.cpp
routing/ai_router/cognitiveMap/connection.cpp
routing/ai_router/cognitiveMap/cognitivemap.cpp
routing/ai_router/cognitiveMap/landmark.cpp
routing/ai_router/cognitiveMap/region.cpp
routing/ai_router/cognitiveMap/landmarknetwork.cpp
routing/ai_router/cognitiveMap/internnavigationnetwork.cpp
routing/ai_router/perception/visualsystem.cpp
routing/ai_router/perception/visibleenvironment.cpp
routing/ai_router/perception/cgalgeometry.cpp
routing/ai_router/perception/sign.cpp
routing/ai_router/Cortex.cpp
)
SET(AIROUTER_HDR
#AI router
routing/ai_router/AIRouter.h
routing/ai_router/BrainStorage.h
routing/ai_router/cognitiveMap/associations.h
routing/ai_router/cognitiveMap/connection.cpp
routing/ai_router/cognitiveMap/cognitivemap.h
routing/ai_router/cognitiveMap/landmark.h
routing/ai_router/cognitiveMap/region.h
routing/ai_router/cognitiveMap/landmarknetwork.h
routing/ai_router/cognitiveMap/internnavigationnetwork.h
routing/ai_router/perception/visualsystem.h
routing/ai_router/perception/visibleenvironment.h
routing/ai_router/perception/cgalgeometry.h
routing/ai_router/perception/sign.h
routing/ai_router/Cortex.h
)
message(STATUS "AIROUTER: ${AIROUTER}")
if(CGAL_FOUND AND AIROUTER)
SET(source_files ${source_files} ${AIROUTER_SRC})
SET(header_files ${header_files} ${AIROUTER_HDR})
message(STATUS "USE AI ROUTER")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DAIROUTER")
endif()
add_library(core STATIC ${source_files})
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIRS})
add_library(cnpy SHARED "cnpy/cnpy.cpp")
add_library(cnpy STATIC "cnpy/cnpy.cpp")
target_link_libraries(cnpy ${ZLIB_LIBRARIES})
......@@ -670,6 +686,7 @@ if (NOT CMAKE_GENERATOR MATCHES "Xcode|Visual Studio")
endif ()
endif ()
if (MSVC)
message(STATUS "MSVC: " ${MSVC})
elseif (MSVC_IDE)
......
......@@ -132,8 +132,8 @@ bool GeoFileParser::LoadGeometry(Building* building)
SubRoom* subroom = nullptr;
if (type=="stair" || type=="escalator" || type=="idle_escalator") {
if (xSubRoom->FirstChildElement("up")==NULL) {
Log->Write("ERROR:\t the attribute <up> and <down> are missing for the "+type);
if (xSubRoom->FirstChildElement("up") == NULL) {
Log->Write("ERROR:\t the attribute <up> and <down> are missing for the " + type);
Log->Write("ERROR:\t check your geometry file");
return false;
}
......@@ -142,10 +142,39 @@ bool GeoFileParser::LoadGeometry(Building* building)
double down_x = xmltof(xSubRoom->FirstChildElement("down")->Attribute("py"), 0.0);
double down_y = xmltof(xSubRoom->FirstChildElement("down")->Attribute("py"), 0.0);
subroom = new Stair();
((Stair*) subroom)->SetUp(Point(up_x, up_y));
((Stair*) subroom)->SetDown(Point(down_x, down_y));
}
else {
((Stair *) subroom)->SetUp(Point(up_x, up_y));
((Stair *) subroom)->SetDown(Point(down_x, down_y));
} else if (type =="escalator_up") {
if (xSubRoom->FirstChildElement("up") == NULL) {
Log->Write("ERROR:\t the attribute <up> and <down> are missing for the " + type);
Log->Write("ERROR:\t check your geometry file");
return false;
}
double up_x = xmltof(xSubRoom->FirstChildElement("up")->Attribute("px"), 0.0);
double up_y = xmltof(xSubRoom->FirstChildElement("up")->Attribute("py"), 0.0);
double down_x = xmltof(xSubRoom->FirstChildElement("down")->Attribute("py"), 0.0);
double down_y = xmltof(xSubRoom->FirstChildElement("down")->Attribute("py"), 0.0);
subroom = new Escalator();
((Escalator *) subroom)->SetUp(Point(up_x, up_y));
((Escalator *) subroom)->SetDown(Point(down_x, down_y));
((Escalator*) subroom)->SetEscalatorUp();
_configuration->set_has_directional_escalators(true);
} else if (type == "escalator_down") {
if (xSubRoom->FirstChildElement("up") == NULL) {
Log->Write("ERROR:\t the attribute <up> and <down> are missing for the " + type);
Log->Write("ERROR:\t check your geometry file");
return false;
}
double up_x = xmltof(xSubRoom->FirstChildElement("up")->Attribute("px"), 0.0);
double up_y = xmltof(xSubRoom->FirstChildElement("up")->Attribute("py"), 0.0);
double down_x = xmltof(xSubRoom->FirstChildElement("down")->Attribute("py"), 0.0);
double down_y = xmltof(xSubRoom->FirstChildElement("down")->Attribute("py"), 0.0);
subroom = new Escalator();
((Escalator *) subroom)->SetUp(Point(up_x, up_y));
((Escalator *) subroom)->SetDown(Point(down_x, down_y));
((Escalator*) subroom)->SetEscalatorDown();
_configuration->set_has_directional_escalators(true);
} else {
//normal subroom or corridor
subroom = new NormalSubRoom();
}
......
......@@ -40,7 +40,7 @@ public:
virtual bool LoadTrafficInfo(Building* building) override;
private:
const Configuration* _configuration;
Configuration* _configuration;
bool LoadGeometry(Building* building);
......
......@@ -122,7 +122,7 @@ bool IniFileParser::Parse(std::string iniFile)
// Progressbar
if (xMainNode->FirstChild("progressbar")) {
_config->SetPRB(true);
Log->Write("INFO: \tUse Progressbar");
Log->Write("INFO: \tUse Progressbar");
}
// geometry file name
......@@ -143,8 +143,8 @@ bool IniFileParser::Parse(std::string iniFile)
if (numthreads) {
#ifdef _OPENMP
omp_set_num_threads(xmltoi(numthreads->Value()));
#endif
}
#endif
}
}
_config->SetMaxOpenMPThreads(omp_get_max_threads());
Log->Write("INFO:\tUsing num_threads <%d> threads (%d available)", _config->GetMaxOpenMPThreads(), max_threads);
......@@ -379,25 +379,25 @@ bool IniFileParser::ParseGCFMModel(TiXmlElement* xGCFM, TiXmlElement* xMainNode)
return false;
//force_ped
if (xModelPara->FirstChild("force_ped")) {
string nu = xModelPara->FirstChildElement("force_ped")->Attribute("nu");
string dist_max = xModelPara->FirstChildElement("force_ped")->Attribute(
"dist_max");
string disteff_max =
xModelPara->FirstChildElement("force_ped")->Attribute(
"disteff_max"); // @todo: rename disteff_max to force_max
string interpolation_width =
xModelPara->FirstChildElement("force_ped")->Attribute(
"interpolation_width");
_config->SetMaxFPed(atof(dist_max.c_str()));
_config->SetNuPed(atof(nu.c_str()));
_config->SetDistEffMaxPed(atof(disteff_max.c_str()));
_config->SetIntPWidthPed(atof(interpolation_width.c_str()));
Log->Write(
"INFO: \tfrep_ped nu=%.3f, dist_max=%.3f, disteff_max=%.3f, interpolation_width=%.3f",
atof(nu.c_str()), atof(dist_max.c_str()), atof(disteff_max.c_str()), atof(interpolation_width.c_str()));
}
if (xModelPara->FirstChild("force_ped")) {
string nu = xModelPara->FirstChildElement("force_ped")->Attribute("nu");
string dist_max = xModelPara->FirstChildElement("force_ped")->Attribute(
"dist_max");
string disteff_max =
xModelPara->FirstChildElement("force_ped")->Attribute(
"disteff_max"); // @todo: rename disteff_max to force_max
string interpolation_width =
xModelPara->FirstChildElement("force_ped")->Attribute(
"interpolation_width");
_config->SetMaxFPed(atof(dist_max.c_str()));
_config->SetNuPed(atof(nu.c_str()));
_config->SetDistEffMaxPed(atof(disteff_max.c_str()));
_config->SetIntPWidthPed(atof(interpolation_width.c_str()));
Log->Write(
"INFO: \tfrep_ped nu=%.3f, dist_max=%.3f, disteff_max=%.3f, interpolation_width=%.3f",
atof(nu.c_str()), atof(dist_max.c_str()), atof(disteff_max.c_str()), atof(interpolation_width.c_str()));
}
//force_wall
if (xModelPara->FirstChild("force_wall")) {
......@@ -416,7 +416,7 @@ bool IniFileParser::ParseGCFMModel(TiXmlElement* xGCFM, TiXmlElement* xMainNode)
_config->SetIntPWidthWall(atof(interpolation_width.c_str()));
Log->Write(
"INFO: \tfrep_wall mu=%.3f, dist_max=%.3f, disteff_max=%.3f, interpolation_width=%.3f",
atof(nu.c_str()), atof(dist_max.c_str()), atof(disteff_max.c_str()), atof(interpolation_width.c_str()));
atof(nu.c_str()), atof(dist_max.c_str()), atof(disteff_max.c_str()), atof(interpolation_width.c_str()));
}
//Parsing the agent parameters
......@@ -487,7 +487,7 @@ bool IniFileParser::ParseKrauszModel(TiXmlElement* xKrausz, TiXmlElement* xMainN
_config->SetIntPWidthPed(atof(interpolation_width.c_str()));
Log->Write(
"INFO: \tfrep_ped nu=%.3f, dist_max=%.3f, disteff_max=%.3f, interpolation_width=%.3f",
atof(nu.c_str()), atof(dist_max.c_str()), atof(disteff_max.c_str()), atof(interpolation_width.c_str()));
atof(nu.c_str()), atof(dist_max.c_str()), atof(disteff_max.c_str()), atof(interpolation_width.c_str()));
}
//force_wall
......@@ -507,7 +507,7 @@ bool IniFileParser::ParseKrauszModel(TiXmlElement* xKrausz, TiXmlElement* xMainN
_config->SetIntPWidthWall(atof(interpolation_width.c_str()));
Log->Write(
"INFO: \tfrep_wall mu=%.3f, dist_max=%.3f, disteff_max=%.3f, interpolation_width=%.3f",
atof(nu.c_str()), atof(dist_max.c_str()), atof(disteff_max.c_str()), atof(interpolation_width.c_str()));
atof(nu.c_str()), atof(dist_max.c_str()), atof(disteff_max.c_str()), atof(interpolation_width.c_str()));
}
//Parsing the agent parameters
......@@ -1045,7 +1045,6 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
Log->Write("ERROR: \t Agent Distribution section is missing");
return false;
}
//first get list of actually used router
std::vector<int> usedRouter;
usedRouter.clear();
......@@ -1104,6 +1103,7 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
}
else if ((strategy == "AI") &&
(std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
#ifdef AIROUTER
Router *r = new AIRouter(id, ROUTING_AI);
_config->GetRoutingEngine()->AddRouter(r);
......@@ -1111,6 +1111,7 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
///Parsing additional options
if (!ParseAIOpts(e))
return false;
#endif
}
else if ((strategy == "ff_global_shortest") &&
(std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
......@@ -1252,7 +1253,7 @@ bool IniFileParser::ParseCogMapOpts(TiXmlNode* routingNode)
return true;
}
#ifdef AIROUTER
bool IniFileParser::ParseAIOpts(TiXmlNode* routingNode) {
TiXmlNode *sensorNode = routingNode->FirstChild();
......@@ -1311,7 +1312,7 @@ bool IniFileParser::ParseAIOpts(TiXmlNode* routingNode) {
return true;
}
#endif
bool IniFileParser::ParseLinkedCells(const TiXmlNode& linkedCellNode)
......@@ -1414,7 +1415,8 @@ bool IniFileParser::ParseNodeToSolver(const TiXmlNode& solverNode)
bool IniFileParser::ParseStrategyNodeToObject(const TiXmlNode& strategyNode)
{
string query = "exit_crossing_strategy";
string query = "exit_crossing_strategy";
if (!strategyNode.FirstChild(query.c_str())) {
query = "exitCrossingStrategy";
Log->Write(
......@@ -1461,6 +1463,18 @@ bool IniFileParser::ParseStrategyNodeToObject(const TiXmlNode& strategyNode)
}
_exit_strat_number = pExitStrategy;
if (pExitStrategy == 8 || pExitStrategy ==9){
_config->set_write_VTK_files_direction(false);
if (strategyNode.FirstChild("write_VTK_files")) {
const char* tmp =
strategyNode.FirstChild("write_VTK_files")->FirstChild()->Value();
//remark: std::strcmp returns 0 if the strings are equal
bool tmp_write_VTK = !std::strcmp(tmp, "true");
_config->set_write_VTK_files_direction(tmp_write_VTK);
}
}
switch (pExitStrategy) {
case 1:
_exit_strategy = std::shared_ptr<DirectionStrategy>(new DirectionMiddlePoint());
......@@ -1485,19 +1499,26 @@ bool IniFileParser::ParseStrategyNodeToObject(const TiXmlNode& strategyNode)
Log->Write("ERROR: \tExit Strategy 7 is not supported any longer. Please refer to www.jupedsim.org");
Log->Write("WARNING: \tChanging Exit-Strategy to #9 (Floorfields with targets within subroom)");
pExitStrategy = 9;
_exit_strat_number = 9;
_exit_strategy = std::shared_ptr<DirectionStrategy>(new DirectionSubLocalFloorfield());
if(!ParseFfOpts(strategyNode)) {
return false;
};
_config->set_dirSubLocal(dynamic_cast<DirectionSubLocalFloorfield*>(_exit_strategy.get()));
break;
case 8:
_exit_strategy = std::shared_ptr<DirectionStrategy>(new DirectionLocalFloorfield());
if(!ParseFfOpts(strategyNode)) {
return false;
};
_config->set_dirLocal(dynamic_cast<DirectionLocalFloorfield*>(_exit_strategy.get()));
break;
case 9:
_exit_strategy = std::shared_ptr<DirectionStrategy>(new DirectionSubLocalFloorfield());
if(!ParseFfOpts(strategyNode)) {
return false;
};
_config->set_dirSubLocal(dynamic_cast<DirectionSubLocalFloorfield*>(_exit_strategy.get()));
break;
default:
_exit_strategy = std::shared_ptr<DirectionStrategy>(new DirectionMinSeperationShorterLine());
......@@ -1511,6 +1532,7 @@ bool IniFileParser::ParseStrategyNodeToObject(const TiXmlNode& strategyNode)
return false;
}
Log->Write("INFO: \texit_crossing_strategy < %d >", pExitStrategy);
_config->set_exit_strat(_exit_strat_number);
}
return true;
}
......
......@@ -61,9 +61,9 @@ private:
bool ParseFfRouterOps(TiXmlNode* routingNode, RoutingStrategy s);
bool ParseCogMapOpts(TiXmlNode* routingNode);
#ifdef AIROUTER
bool ParseAIOpts(TiXmlNode* routingNode);
#endif
bool ParseLinkedCells(const TiXmlNode& linkedCellNode);
bool ParseStepSize(TiXmlNode& stepNode);
......
......@@ -35,7 +35,7 @@
#include "math/GompertzModel.h"
#include "math/GradientModel.h"
#include "pedestrian/AgentsQueue.h"
#include "pedestrian/AgentsSourcesManager.h"
#ifdef _OPENMP
#else
......@@ -61,6 +61,7 @@ Simulation::Simulation(Configuration* args)
_fps = 1;
_em = nullptr;
_gotSources = false;
_maxSimTime = 100;
// _config = args;
}
......@@ -201,6 +202,7 @@ bool Simulation::InitArgs()
sprintf(tmp, "\tt_max: %f\n", _config->GetTmax());
s.append(tmp);
_deltaT = _config->Getdt();
_maxSimTime = _config->GetTmax();
sprintf(tmp, "\tdt: %f\n", _deltaT);
_periodic = _config->IsPeriodic();
sprintf(tmp, "\t periodic: %d\n", _periodic);
......@@ -214,10 +216,11 @@ bool Simulation::InitArgs()
_routingEngine = _config->GetRoutingEngine();
auto distributor = std::unique_ptr<PedDistributor>(new PedDistributor(_config));
// IMPORTANT: do not change the order in the following..
_building = std::unique_ptr<Building>(new Building(_config, *distributor));
_building = std::shared_ptr<Building>(new Building(_config, *distributor));
// Initialize the agents sources that have been collected in the pedestrians distributor
_agentSrcManager.SetBuilding(_building.get());
_agentSrcManager.SetMaxSimTime(GetMaxSimTime());
_gotSources = (bool) distributor->GetAgentsSources().size(); // did we have any sources? false if no sources
for (const auto& src: distributor->GetAgentsSources()) {
_agentSrcManager.AddSource(src);
......@@ -286,8 +289,8 @@ void Simulation::UpdateRoutesAndLocations()
{
//pedestrians to be deleted
//you should better create this in the constructor and allocate it once.
vector<Pedestrian*> pedsToRemove;
pedsToRemove.reserve(500); //just reserve some space
set<Pedestrian*> pedsToRemove;
// pedsToRemove.reserve(500); //just reserve some space
// collect all pedestrians in the simulation.
const vector<Pedestrian*>& allPeds = _building->GetAllPedestrians();
......@@ -305,12 +308,12 @@ void Simulation::UpdateRoutesAndLocations()
&& (room->GetCaption() == "outside")) {
#pragma omp critical(Simulation_Update_pedsToRemove)
pedsToRemove.push_back(ped);
pedsToRemove.insert(ped);
} else if ((ped->GetFinalDestination() != FINAL_DEST_OUT)
&& (goals.at(ped->GetFinalDestination())->Contains(
ped->GetPos()))) {
#pragma omp critical(Simulation_Update_pedsToRemove)
pedsToRemove.push_back(ped);
pedsToRemove.insert(ped);
}
// reposition in the case the pedestrians "accidently left the room" not via the intended exit.
......@@ -326,8 +329,7 @@ void Simulation::UpdateRoutesAndLocations()
if (!assigned) {
#pragma omp critical(Simulation_Update_pedsToRemove)
pedsToRemove.push_back(ped);
//the agent left the old room
pedsToRemove.insert(ped); //the agent left the old room
//actualize the eggress time for that room
#pragma omp critical(SetEgressTime)
allRooms.at(ped->GetRoomID())->SetEgressTime(ped->GetGlobalTime());
......@@ -359,10 +361,11 @@ void Simulation::UpdateRoutesAndLocations()
else
#endif
{
// remove the pedestrians that have left the building
for (unsigned int p = 0; p<pedsToRemove.size(); p++) {
UpdateFlowAtDoors(*pedsToRemove[p]);
_building->DeletePedestrian(pedsToRemove[p]);
for (auto p : pedsToRemove){
UpdateFlowAtDoors(*p);
_building->DeletePedestrian(p);
}
pedsToRemove.clear();
}
......@@ -532,12 +535,31 @@ void Simulation::RunFooter()
void Simulation::ProcessAgentsQueue()
{
/* std::cout << "Call Simulation::ProcessAgentsQueue() at: " << Pedestrian::GetGlobalTime() << std::endl; */
/* std::cout << KRED << " SIMULATION building " << _building << " size " << _building->GetAllPedestrians().size() << "\n" << RESET; */
/* for(auto pp: _building->GetAllPedestrians()) */
/* std::cout<< KBLU << "BUL: Simulation: " << pp->GetPos()._x << ", " << pp->GetPos()._y << RESET << std::endl; */
//incoming pedestrians
vector<Pedestrian*> peds;
// std::cout << ">>> peds " << peds.size() << RESET<< std::endl;
AgentsQueueIn::GetandClear(peds);
//std::cout << "SIMULATION BEFORE BOOL = " << _agentSrcManager.IsBuildingUpdated() << " peds size " << peds.size() << "\n" ;
//_agentSrcManager.SetBuildingUpdated(true);
/* std::cout << "SIMULATION AFTER BOOL = " << _agentSrcManager.IsBuildingUpdated() << "\n" ; */
for (auto&& ped: peds) {
/* std::cout << "Add to building : " << ped->GetPos()._x << ", " << ped->GetPos()._y << " t: "<< Pedestrian::GetGlobalTime() << std::endl; */
_building->AddPedestrian(ped);
}
// for(auto pp: _building->GetAllPedestrians())
// std::cout<< KBLU << "BUL: Simulation: " << pp->GetPos()._x << ", " << pp->GetPos()._y << " t: "<< Pedestrian::GetGlobalTime() <<RESET << std::endl;
/* std::cout << "LEAVE Simulation::ProcessAgentsQueue() with " << " size " << _building->GetAllPedestrians().size() << "\n" << RESET; */
}
void Simulation::UpdateDoorticks() const {
......@@ -622,3 +644,7 @@ Building* Simulation::GetBuilding()
{
return _building.get();
}
int Simulation::GetMaxSimTime() const{
return _maxSimTime;
}
......@@ -67,7 +67,7 @@ private:
///seed using for the random number generator
unsigned int _seed;
/// building object
std::unique_ptr<Building> _building;
std::shared_ptr<Building> _building;
/// Force model to use
std::shared_ptr<OperationalModel> _operationalModel;
/// Manage all route choices algorithms
......@@ -85,6 +85,8 @@ private:
/// hybrid simulation manager
//HybridSimulationManager
int _periodic;
int _maxSimTime;
bool _gotSources; // is true if we got some sources. Otherwise, false.
// bool _printPB; // print progressbar
public:
......@@ -182,6 +184,8 @@ public:
*
*/
void UpdateDoorticks() const;
int GetMaxSimTime() const;
};
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<geometry version="0.8" caption="Projectname" gridSizeX="20.000000"
gridSizeY="20.000000" unit="m"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_geoemtry.xsd ">
<rooms>
<room id="0" caption="botleneck" zpos="0.000000">
<subroom id="0" closed="0" class="subroom">
<polygon caption="oben">
<vertex px="65.000000" py="106.000000" />
<vertex px="62.000000" py="106.000000" />
<vertex px="62.000000" py="102.400" />
</polygon>
<polygon caption="unten">
<vertex px="62.000000" py="101.600" />
<vertex px="62.000000" py="98.000000" />
<vertex px="65.000000" py="98.000000" />
</polygon>
</subroom>
<subroom id="1" closed="0" class="subroom">
<polygon caption="wall">
<vertex px="62.000000" py="102.400" />
<vertex px="60.000000" py="102.400" />
</polygon>
<polygon caption="wall">
<vertex px="60.000000" py="101.600" />