Commit e99ef625 authored by f.mack's avatar f.mack

merged reroute

parents d6a408b2 50085212
......@@ -190,9 +190,10 @@ endif (OPENMP_FOUND)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
# test all cpp-files in Utest
if (BUILD_TESTING OR BUILD_CPPUNIT_TEST)
find_package(Boost COMPONENTS system filesystem unit_test_framework REQUIRED)
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
IF (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
IF (USE_DUAL_ABI)
......@@ -314,11 +315,7 @@ set(source_files
routing/cognitive_map/sensor/DiscoverDoorsSensor.cpp
routing/cognitive_map/sensor/JamSensor.cpp
routing/cognitive_map/sensor/LastDestinationsSensor.cpp
routing/cognitive_map/sensor/SmokeSensor.cpp
routing/cognitive_map/sensor/locater.cpp
routing/cognitive_map/fire_mesh/FireMesh.cpp
routing/cognitive_map/fire_mesh/Knot.cpp
routing/cognitive_map/fire_mesh/FireMeshStorage.cpp
routing/cognitive_map/cognitiveMap/associations.cpp
routing/cognitive_map/cognitiveMap/cognitivemap.cpp
routing/cognitive_map/cognitiveMap/waypoints.cpp
......@@ -336,6 +333,15 @@ set(source_files
poly2tri/sweep/cdt.cpp
events/EventManager.cpp
events/Event.cpp
JPSfire/generic/FDSMesh.cpp
JPSfire/generic/Knot.cpp
JPSfire/generic/FDSMeshStorage.cpp
JPSfire/A_smoke_sensor/SmokeSensor.cpp
JPSfire/B_walking_speed/WalkingSpeed.cpp
JPSfire/C_toxicity_analysis/ToxicityAnalysis.cpp
JPSfire/C_toxicity_analysis/ToxicityOutputhandler.cpp
math/KrauszModel.cpp)
set(header_files
......@@ -376,11 +382,7 @@ set(header_files
routing/cognitive_map/sensor/DiscoverDoorsSensor.h
routing/cognitive_map/sensor/JamSensor.h
routing/cognitive_map/sensor/LastDestinationsSensor.h
routing/cognitive_map/sensor/SmokeSensor.h
routing/cognitive_map/sensor/locater.h
routing/cognitive_map/fire_mesh/FireMesh.h
routing/cognitive_map/fire_mesh/Knot.h
routing/cognitive_map/fire_mesh/FireMeshStorage.h
routing/cognitive_map/cognitiveMap/associations.h
routing/cognitive_map/cognitiveMap/cognitivemap.h
routing/cognitive_map/cognitiveMap/waypoints.h
......@@ -450,10 +452,20 @@ set(header_files
poly2tri/sweep/sweep.h
events/EventManager.h
events/Event.h
)
JPSfire/generic/FDSMesh.h
JPSfire/generic/Knot.h
JPSfire/generic/FDSMeshStorage.h
JPSfire/A_smoke_sensor/SmokeSensor.h
JPSfire/B_walking_speed/WalkingSpeed.h
JPSfire/C_toxicity_analysis/ToxicityAnalysis.h
JPSfire/C_toxicity_analysis/ToxicityOutputhandler.h
)
add_library(core STATIC ${source_files})
add_library(core STATIC ${source_files})
if(Boost_FOUND)
target_link_libraries(core ${Boost_LIBRARIES})
endif()
#add_library ( core SHARED ${source_files} )
......@@ -461,6 +473,7 @@ add_library(core STATIC ${source_files})
#add_executable(
# jpscore Utest/Fastmarchtest.h
#)
add_executable(jpscore main.cpp)
if (Boost_FOUND)
......@@ -475,12 +488,13 @@ if (Boost_FOUND)
target_link_libraries(jpscore ${Boost_LIBRARIES})
endif ()
target_link_libraries(jpscore core)
target_link_libraries(jpscore core )
if (WIN32)
target_link_libraries(jpscore core wsock32)
endif (WIN32)
# if(CGAL_FOUND)
# target_link_libraries (jpscore ${CGAL_CORE_LIBRARY})
# endif(CGAL_FOUND)
......
......@@ -54,6 +54,9 @@ bool GeoFileParser::LoadGeometry(Building* building)
std::string geoFilenameWithPath = _configuration->GetProjectRootDir()+_configuration->GetGeometryFile();
TiXmlDocument docGeo(geoFilenameWithPath);
if (!docGeo.LoadFile()) {
Log->Write(_configuration->GetProjectRootDir());
Log->Write(_configuration->GetGeometryFile());
Log->Write(geoFilenameWithPath);
Log->Write("ERROR: \t%s", docGeo.ErrorDesc());
Log->Write("\t could not parse the geometry file");
return false;
......
This diff is collapsed.
......@@ -39,6 +39,7 @@ class IniFileParser {
public:
IniFileParser(Configuration* config);
~IniFileParser(){};
bool Parse(std::string iniFile);
......@@ -57,7 +58,7 @@ private:
bool ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* agentDistri);
bool ParseFfRouterOps(TiXmlNode* routingNode);
bool ParseFfRouterOps(TiXmlNode* routingNode, RoutingStrategy s);
bool ParseCogMapOpts(TiXmlNode* routingNode);
......
......@@ -60,6 +60,8 @@ bool PedDistributionParser::LoadPedDistribution(vector<std::shared_ptr<StartDist
int group_id = xmltoi(e->Attribute("group_id"));
int subroom_id = xmltoi(e->Attribute("subroom_id"), -1);
int number = xmltoi(e->Attribute("number"), 0);
double density = xmltof(e->Attribute("density"), 0);
string social_group = xmltoa(e->Attribute("social_group"), "false");
int agent_para_id = xmltoi(e->Attribute("agent_parameter_id"), -1);
int goal_id = xmltoi(e->Attribute("goal_id"), FINAL_DEST_OUT);
......@@ -71,8 +73,10 @@ bool PedDistributionParser::LoadPedDistribution(vector<std::shared_ptr<StartDist
double patience = xmltof(e->Attribute("patience"), 5);
double premovement_mean = xmltof(e->Attribute("pre_movement_mean"), 0);
double premovement_sigma = xmltof(e->Attribute("pre_movement_sigma"), 0);
//double risk_tolerance_mean = xmltof(e->Attribute("risk_tolerance_mean"), 0);
//double risk_tolerance_sigma = xmltof(e->Attribute("risk_tolerance_sigma"), 0);
double premovement_min = xmltof(e->Attribute("pre_movement_min"), 0);
double premovement_max = xmltof(e->Attribute("pre_movement_max"), 0);
double risk_tolerance_mean = xmltof(e->Attribute("risk_tolerance_mean"), 0);
double risk_tolerance_sigma = xmltof(e->Attribute("risk_tolerance_sigma"), 0);
double x_min = xmltof(e->Attribute("x_min"), -FLT_MAX);
double x_max = xmltof(e->Attribute("x_max"), FLT_MAX);
......@@ -94,37 +98,51 @@ bool PedDistributionParser::LoadPedDistribution(vector<std::shared_ptr<StartDist
dis->SetGroupId(group_id);
dis->Setbounds(bounds);
dis->SetAgentsNumber(number);
dis->SetAgentsDensity(density);
dis->SetAge(age);
dis->SetGender(gender);
dis->SetSocialGroup(social_group);
dis->SetGoalId(goal_id);
dis->SetRouteId(route_id);
dis->SetRouterId(router_id);
dis->SetHeight(height);
dis->SetPatience(patience);
dis->InitPremovementTime(premovement_mean, premovement_sigma);
if (e->Attribute("pre_movement_mean") && e->Attribute("pre_movement_sigma")) {
std::string distribution_type = "normal";
dis->InitPremovementTime(distribution_type, premovement_mean, premovement_sigma);
}
if (e->Attribute("pre_movement_min") && e->Attribute("pre_movement_max")) {
std::string distribution_type = "uniform";
if(premovement_min > premovement_max){
Log->Write("ERROR:\tpremovement_min > premovement_max!");
return false;
}
dis->InitPremovementTime(distribution_type, premovement_min, premovement_max);
}
if (e->Attribute("risk_tolerance_mean") && e->Attribute("risk_tolerance_sigma")) {
std::string distribution_type = "normal";
double risk_tolerance_mean = xmltof(e->Attribute("risk_tolerance_mean"), NAN);
double risk_tolerance_sigma = xmltof(e->Attribute("risk_tolerance_sigma"), NAN);
Log->Write("INFO:\trisk tolerance mu = %f, risk tolerance sigma = %f\n", risk_tolerance_mean,
risk_tolerance_sigma);
//Log->Write("INFO:\trisk tolerance mu = %f, risk tolerance sigma = %f\n", risk_tolerance_mean,
// risk_tolerance_sigma);
dis->InitRiskTolerance(distribution_type, risk_tolerance_mean, risk_tolerance_sigma);
}
else if (e->Attribute("risk_tolerance_alpha") && e->Attribute("risk_tolerance_beta")) {
std::string distribution_type = "beta";
double risk_tolerance_alpha = xmltof(e->Attribute("risk_tolerance_alpha"), NAN);
double risk_tolerance_beta = xmltof(e->Attribute("risk_tolerance_beta"), NAN);
Log->Write("INFO:\trisk tolerance alpha = %f, risk tolerance beta = %f\n", risk_tolerance_alpha,
risk_tolerance_beta);
//Log->Write("INFO:\trisk tolerance alpha = %f, risk tolerance beta = %f\n", risk_tolerance_alpha,
// risk_tolerance_beta);
dis->InitRiskTolerance(distribution_type, risk_tolerance_alpha, risk_tolerance_beta);
}
else {
std::string distribution_type = "normal";
double risk_tolerance_mean = 0.;
double risk_tolerance_sigma = 1.;
Log->Write("INFO:\trisk tolerance mu = %f, risk tolerance sigma = %f\n", risk_tolerance_mean,
risk_tolerance_sigma);
//Log->Write("INFO:\trisk tolerance mu = %f, risk tolerance sigma = %f\n", risk_tolerance_mean,
// risk_tolerance_sigma);
dis->InitRiskTolerance(distribution_type, risk_tolerance_mean, risk_tolerance_sigma);
}
......
......@@ -27,22 +27,20 @@
**/
#include "SmokeSensor.h"
#include "../NavigationGraph.h"
#include "../../../geometry/Building.h"
#include "../cognitiveMap/cognitivemap.h"
#include "../../../pedestrian/Pedestrian.h"
#include "../../../geometry/SubRoom.h"
#include "../fire_mesh/FireMesh.h"
#include "../fire_mesh/FireMeshStorage.h"
#include "../../routing/cognitive_map/NavigationGraph.h"
#include "../../geometry/Building.h"
#include "../../routing/cognitive_map/cognitiveMap/cognitivemap.h"
#include "../../pedestrian/Pedestrian.h"
#include "../../geometry/SubRoom.h"
#include "../generic/FDSMesh.h"
#include "../generic/FDSMeshStorage.h"
#include <set>
#include "../../tinyxml/tinyxml.h"
SmokeSensor::SmokeSensor(const Building *b, const std::string &filepath, const double &updateintervall, const double &finalTime) : AbstractSensor(b)
SmokeSensor::SmokeSensor(const Building *b) : AbstractSensor(b)
{
_FMStorage = std::make_shared<FireMeshStorage>(b,filepath,updateintervall,finalTime);
//Log.Write(FMS->get_FireMesh())
Log->Write("INFO:\tInitialized FireMeshStorage (Smoke Sensor)");
_building = b;
LoadJPSfireInfo(_building->GetProjectFilename());
}
......@@ -50,6 +48,37 @@ SmokeSensor::~SmokeSensor()
{
}
bool SmokeSensor::LoadJPSfireInfo(const std::string projectFilename)
{
TiXmlDocument doc(projectFilename);
if (!doc.LoadFile()) {
Log->Write("ERROR: \t%s", doc.ErrorDesc());
Log->Write("ERROR: \t could not parse the project file");
return false;
}
TiXmlNode* JPSfireNode = doc.RootElement()->FirstChild("JPSfire");
if( ! JPSfireNode ) {
Log->Write("INFO:\tcould not find any JPSfire information");
return true;
}
TiXmlElement* JPSfireCompElem = JPSfireNode->FirstChildElement("A_smoke_sensor");
if(JPSfireCompElem) {
if(JPSfireCompElem->FirstAttribute()){
//std::string filepath = xmltoa(JPSfireCompElem->Attribute("smoke_factor_grids"), "");
std::string filepath = _building->GetProjectRootDir() + xmltoa(JPSfireCompElem->Attribute("smoke_factor_grids"), "");
double updateIntervall = xmltof(JPSfireCompElem->Attribute("update_time"), 0.);
double finalTime = xmltof(JPSfireCompElem->Attribute("final_time"), 0.);
Log->Write("INFO:\tJPSfire Module A_smoke_sensor: \n\tdata: %s \n\tupdate time: %.1f s | final time: %.1f s",
filepath.c_str(), updateIntervall, finalTime);
_FMStorage = std::make_shared<FDSMeshStorage>(filepath, finalTime, updateIntervall);
return true;
}
}
return false;
}
std::string SmokeSensor::GetName() const
{
return "SmokeSensor";
......@@ -70,56 +99,30 @@ void SmokeSensor::execute(const Pedestrian * pedestrian, CognitiveMap * cognitiv
double RiskTolerance = pedestrian->GetRiskTolerance();
double smokeFactor = 1 + (1-RiskTolerance)*_FMStorage->get_FireMesh(item->GetCrossing()->GetCentre(),
pedestrian->GetGlobalTime()).GetKnotValue(pedestrian->GetPos()._x,
pedestrian->GetPos()._y);
double smokeFactor = 1 + (1-RiskTolerance)*
_FMStorage->GetFDSMesh(pedestrian->GetElevation(),
item->GetCrossing()->GetCentre(),
pedestrian->GetGlobalTime()).GetKnotValue(pedestrian->GetPos()._x,
pedestrian->GetPos()._y);
/// Set Smoke factor
item->SetFactor(smokeFactor,GetName());
}
// const GraphVertex * smoked_room = NULL;
// for(GraphVertex::EdgesContainer::const_iterator it = edges->begi bn(); it != edges->end(); ++it) {
// if(
// (*it)->GetDest() != NULL
// && (
// (*it)->GetDest()->GetSubRoom()->GetRoomID() == 14 //insert room id here
// && (*it)->GetDest()->GetSubRoom()->GetSubRoomID() == 7 //insert sub room id here
// )
// ) {
// smoked_room =(*it)->GetDest();
// }
// }
// if(smoked_room != nullptr) {
// NavigationGraph::VerticesContainer * vertices = cognitive_map->GetAllVertices();
// //iterating over all Vertices
// for(NavigationGraph::VerticesContainer::iterator it_vertices = vertices->begin(); it_vertices != vertices->end(); ++it_vertices) {
// GraphVertex::EdgesContainer * edges = (it_vertices->second)->GetAllEdges();
// //iterating over all edges
// for(GraphVertex::EdgesContainer::iterator it_edges = edges->begin(); it_edges != edges->end(); ++it_edges) {
// if((*it_edges)->GetDest() == smoked_room) {
// (*it_edges)->SetFactor(10000.0, GetName());
// }
// }
// }
// }
}
void SmokeSensor::set_FMStorage(const std::shared_ptr<FireMeshStorage> fmStorage)
void SmokeSensor::set_FMStorage(const std::shared_ptr<FDSMeshStorage> fmStorage)
{
_FMStorage=fmStorage;
}
const std::shared_ptr<FireMeshStorage> SmokeSensor::get_FMStorage()
const std::shared_ptr<FDSMeshStorage> SmokeSensor::get_FMStorage()
{
return _FMStorage;
}
......@@ -29,31 +29,35 @@
#ifndef SMOKESENSOR_H
#define SMOKESENSOR_H 1
#include "AbstractSensor.h"
#include "../../routing/cognitive_map/sensor/AbstractSensor.h"
#include <memory>
class Point;
class FireMeshStorage;
class FDSMeshStorage;
class SmokeSensor : public AbstractSensor
{
public:
SmokeSensor(const Building * b, const std::string &filepath, const double &updateintervall, const double &finalTime);
SmokeSensor(const Building * b);
virtual ~SmokeSensor();
bool LoadJPSfireInfo(const std::string projectFilename);
std::string GetName() const;
void execute(const Pedestrian *, CognitiveMap *) const;
void set_FMStorage(const std::shared_ptr<FireMeshStorage> fmStorage);
const std::shared_ptr<FireMeshStorage> get_FMStorage();
void set_FMStorage(const std::shared_ptr<FDSMeshStorage> fmStorage);
const std::shared_ptr<FDSMeshStorage> get_FMStorage();
private:
std::shared_ptr<FireMeshStorage> _FMStorage;
private:
const Building* _building;
std::shared_ptr<FDSMeshStorage> _FMStorage;
};
#endif // SMOKESENSOR_H
/**
* \file WalkingSpeed.cpp
* \date Jan 1, 2014
* \version v0.7
* \copyright <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
*
* \section License
* This file is part of JuPedSim.
*
* JuPedSim is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* JuPedSim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* \section Description
* detects smoke in the next rooms
*
*
**/
#include "WalkingSpeed.h"
#include "../../geometry/Building.h"
#include "../../pedestrian/Pedestrian.h"
#include "../generic/FDSMesh.h"
#include "../generic/FDSMeshStorage.h"
#include "../../pedestrian/PedDistributor.h"
#include "../../tinyxml/tinyxml.h"
#include <set>
#include <algorithm>
#include <math.h>
#include <string>
WalkingSpeed::WalkingSpeed(const Building * b)
{
_FMStorage = nullptr;
_building = b;
LoadJPSfireInfo(_building->GetProjectFilename());
}
WalkingSpeed::~WalkingSpeed()
{
}
bool WalkingSpeed::LoadJPSfireInfo(const std::string projectFilename )
{
TiXmlDocument doc(projectFilename);
if (!doc.LoadFile()) {
Log->Write("ERROR: \t%s", doc.ErrorDesc());
Log->Write("ERROR: \t could not parse the project file");
return false;
}
TiXmlNode* JPSfireNode = doc.RootElement()->FirstChild("JPSfire");
if( ! JPSfireNode ) {
Log->Write("INFO:\tcould not find any JPSfire information");
return true;
}
TiXmlElement* JPSfireCompElem = JPSfireNode->FirstChildElement("B_walking_speed");
if(JPSfireCompElem) {
if(JPSfireCompElem->FirstAttribute()){
std::string study = xmltoa(JPSfireCompElem->Attribute("study"), "");
std::string irritant = xmltoa(JPSfireCompElem->Attribute("irritant"), "");
//std::string filepath = xmltoa(JPSfireCompElem->Attribute("extinction_grids"), "");
std::string filepath = _building->GetProjectRootDir() + xmltoa(JPSfireCompElem->Attribute("extinction_grids"), "");
double updateIntervall = xmltof(JPSfireCompElem->Attribute("update_time"), 0.);
double finalTime = xmltof(JPSfireCompElem->Attribute("final_time"), 0.);
Log->Write("INFO:\tJPSfire Module B_walking_speed: \n \tstudy: %s \n\tdata: %s \n\tupdate time: %.1f s | final time: %.1f s | irritant: %s",
study.c_str(), filepath.c_str(), updateIntervall, finalTime, irritant.c_str());
_FMStorage = std::make_shared<FDSMeshStorage>(filepath, finalTime, updateIntervall, study, irritant);
return true;
}
}
return false;
}
double WalkingSpeed::GetExtinction(const Pedestrian * pedestrian)
{
std::string quantity = "SOOT_EXTINCTION_COEFFICIENT";
double ExtinctionCoefficient = _FMStorage->GetFDSMesh(pedestrian->GetGlobalTime(), pedestrian->GetElevation(), quantity).GetKnotValue(pedestrian->GetPos()._x , pedestrian->GetPos()._y);
return ExtinctionCoefficient;
}
void WalkingSpeed::set_FMStorage(const std::shared_ptr<FDSMeshStorage> fmStorage)
{
_FMStorage=fmStorage;
}
const std::shared_ptr<FDSMeshStorage> WalkingSpeed::get_FMStorage()
{
return _FMStorage;
}
double WalkingSpeed::FrantzichNilsson2003(double &walking_speed, double ExtinctionCoefficient)
{
//According to Frantzich+Nilsson2003
walking_speed = std::fmax(0.3, walking_speed * (1 + (-0.057 / 0.706) * ExtinctionCoefficient) );
return walking_speed;
}
double WalkingSpeed::Jin1978(double &walking_speed, double ExtinctionCoefficient)
{
//According to Jin1978
std::string irritant = _FMStorage->IrritantOrNot();
if(irritant=="false") {
walking_speed = std::fmax(0.3, walking_speed * ( -0.54991616 * std::pow(ExtinctionCoefficient, 3) +
-0.05957671 * std::pow(ExtinctionCoefficient, 2)
-0.06606845 * ExtinctionCoefficient + 1.0025715) );
}
else if(irritant=="true") {
walking_speed = std::fmax(0.3, walking_speed *
(- std::pow( 112236.0553, (ExtinctionCoefficient-0.532027513) ) + 0.988158598 ));
}
else {
Log->Write("ERROR:\tSpecify if irritant or non-irritant smoke shall be cosidered");
exit(EXIT_FAILURE);
}
return walking_speed;
}
double WalkingSpeed::WalkingInSmoke(const Pedestrian* p, double walking_speed)
{
double ExtinctionCoefficient = GetExtinction(p);
//std::cout << ExtinctionCoefficient << std::endl;
//fprintf(stderr, "%f\n", ExtinctionCoefficient);
std::string study = _FMStorage->GetStudy();
if((ExtinctionCoefficient < 10E-6) || (std::isnan(ExtinctionCoefficient))) //no obstruction by smoke or NaN check
{
//fprintf(stderr, "%f \t%f\n", ExtinctionCoefficient, p->GetEllipse().GetV0());
return walking_speed; // walking_speed is returned as V0 for plane or stairs
}
else {
if (study=="Frantzich+Nilsson2003"){
walking_speed = FrantzichNilsson2003(walking_speed, ExtinctionCoefficient);
}
else if (study=="Jin1978"){
walking_speed = Jin1978(walking_speed, ExtinctionCoefficient);
}
else {
Log->Write("ERROR:\tNo study specified");
exit(EXIT_FAILURE);
}
}
//fprintf(stderr, "%f \t%f \t%f \t%f \n", p->GetGlobalTime(), ExtinctionCoefficient, walking_speed, p->GetV().Norm() );
return walking_speed;
}
bool WalkingSpeed::ReduceWalkingSpeed()
{
return _FMStorage!=nullptr;
}
/**
* \file firemesh.h
* \date Jan 1, 2015
* \file WalkingSpeed.h
* \date Jan 1, 2014
* \version v0.7
* \copyright <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
*
......@@ -21,51 +21,48 @@
* along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.