Commit 138e6066 authored by tobias schroedter's avatar tobias schroedter

WIP Commit, needs to clean up CMakeLists.txt

parent 5b35dc65
This diff is collapsed.
...@@ -482,34 +482,36 @@ bool GeoFileParser::LoadRoutingInfo(Building* building) ...@@ -482,34 +482,36 @@ bool GeoFileParser::LoadRoutingInfo(Building* building)
std::cout << waitingArea->toString() << std::endl; std::cout << waitingArea->toString() << std::endl;
} }
// building->AddTrip(trips);
_configuration->GetRoutingEngine()->AddTrip(trips);
std::cout << trips;
} }
//load routes //load routes
TiXmlNode* xTripsNode = xRootNode->FirstChild("routing")->FirstChild("routes"); // TiXmlNode* xTripsNode = xRootNode->FirstChild("routing")->FirstChild("routes");
//
if (xTripsNode) // if (xTripsNode)
for (TiXmlElement* trip = xTripsNode->FirstChildElement("route"); trip; // for (TiXmlElement* trip = xTripsNode->FirstChildElement("route"); trip;
trip = trip->NextSiblingElement("route")) { // trip = trip->NextSiblingElement("route")) {
//
double id = xmltof(trip->Attribute("id"), -1); // double id = xmltof(trip->Attribute("id"), -1);
if (id==-1) { // if (id==-1) {
Log->Write("ERROR:\t id missing for trip"); // Log->Write("ERROR:\t id missing for trip");
return false; // return false;
} // }
std::string sTrip = trip->FirstChild()->ValueStr(); // std::string sTrip = trip->FirstChild()->ValueStr();
std::vector<std::string> vTrip; // std::vector<std::string> vTrip;
vTrip.clear(); // vTrip.clear();
//
char* str = (char*) sTrip.c_str(); // char* str = (char*) sTrip.c_str();
char* p = strtok(str, ":"); // char* p = strtok(str, ":");
while (p) { // while (p) {
vTrip.push_back(xmltoa(p)); // vTrip.push_back(xmltoa(p));
p = strtok(NULL, ":"); // p = strtok(NULL, ":");
} // }
_configuration->GetRoutingEngine()->AddTrip(vTrip); // _configuration->GetRoutingEngine()->AddTrip(vTrip);
} // }
Log->Write("INFO:\tdone with loading extra routing information"); Log->Write("INFO:\tdone with loading extra routing information");
return true; return true;
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "../general/Configuration.h" #include "../general/Configuration.h"
#include "../geometry/Building.h" #include "../geometry/Building.h"
#include "../geometry/GeometryReader.h" #include "../geometry/GeometryReader.h"
#include "Trips.h" #include "../geometry/Trips.h"
//TODO: the class name GeoFileParser is misleading as the ``geometry'' file contains among others also relations (transitions) //TODO: the class name GeoFileParser is misleading as the ``geometry'' file contains among others also relations (transitions)
//TODO: between geometries/rooms. Probably, EnvironmentFileParser would be better, still parts of the environment are //TODO: between geometries/rooms. Probably, EnvironmentFileParser would be better, still parts of the environment are
......
...@@ -40,10 +40,13 @@ ...@@ -40,10 +40,13 @@
#include "../math/GradientModel.h" #include "../math/GradientModel.h"
#include "../math/VelocityModel.h" #include "../math/VelocityModel.h"
#include "../routing/global_shortest/GlobalRouter.h" #include "../routing/global_shortest/GlobalRouter.h"
#include "../routing/global_shortest_trips/GlobalRouterTrips.h"
#include "../routing/quickest/QuickestPathRouter.h" #include "../routing/quickest/QuickestPathRouter.h"
#include "../routing/smoke_router/SmokeRouter.h" #include "../routing/smoke_router/SmokeRouter.h"
#include "../routing/ai_router/AIRouter.h" #include "../routing/ai_router/AIRouter.h"
#include "../routing/ff_router/ffRouter.h" #include "../routing/ff_router/ffRouter.h"
#include "../routing/ff_router_trips/ffRouterTrips.h"
#include "../routing/trips_router/TripsRouter.h"
/* https://stackoverflow.com/questions/38530981/output-compiler-version-in-a-c-program#38531037 */ /* https://stackoverflow.com/questions/38530981/output-compiler-version-in-a-c-program#38531037 */
std::string ver_string(int a, int b, int c) { std::string ver_string(int a, int b, int c) {
...@@ -1134,6 +1137,13 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag ...@@ -1134,6 +1137,13 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
Router *r = new GlobalRouter(id, ROUTING_GLOBAL_SHORTEST); Router *r = new GlobalRouter(id, ROUTING_GLOBAL_SHORTEST);
_config->GetRoutingEngine()->AddRouter(r); _config->GetRoutingEngine()->AddRouter(r);
} }
else if ((strategy == "global_shortest_trips") &&
(std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
//pRoutingStrategies.push_back(make_pair(id, ROUTING_GLOBAL_SHORTEST));
Router *r = new GlobalRouterTrips(id, ROUTING_GLOBAL_SHORTEST);
_config->GetRoutingEngine()->AddRouter(r);
}
else if ((strategy == "quickest") && else if ((strategy == "quickest") &&
(std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) { (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
//pRoutingStrategies.push_back(make_pair(id, ROUTING_QUICKEST)); //pRoutingStrategies.push_back(make_pair(id, ROUTING_QUICKEST));
...@@ -1169,14 +1179,30 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag ...@@ -1169,14 +1179,30 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
#endif #endif
} }
else if ((strategy == "ff_global_shortest") && else if ((strategy == "AI_trips") &&
(std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
#ifdef AIROUTER
Router *r = new AIRouterTrips(id, ROUTING_AI_TRIPS);
_config->GetRoutingEngine()->AddRouter(r);
Log->Write("\nINFO: \tUsing AIRouter Trips");
///Parsing additional options
if (!ParseAIOpts(e))
return false;
#else
std::cerr << "\nCan not use AI Router. Rerun cmake with option -DAIROUTER=true and recompile.\n";
exit(EXIT_FAILURE);
#endif
}
else if ((strategy == "ff_global_shortest_trips") &&
(std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) { (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
//pRoutingStrategies.push_back(make_pair(id, ROUTING_FF_GLOBAL_SHORTEST)); //pRoutingStrategies.push_back(make_pair(id, ROUTING_FF_GLOBAL_SHORTEST));
Router *r = new FFRouter(id, ROUTING_FF_GLOBAL_SHORTEST, hasSpecificGoals, _config); Router *r = new FFRouterTrips(id, ROUTING_FF_GLOBAL_SHORTEST, hasSpecificGoals, _config);
_config->GetRoutingEngine()->AddRouter(r); _config->GetRoutingEngine()->AddRouter(r);
if ((_exit_strat_number == 8) || (_exit_strat_number == 9)){ if ((_exit_strat_number == 8) || (_exit_strat_number == 9)){
Log->Write("\nINFO: \tUsing FF Global Shortest Router"); Log->Write("\nINFO: \tUsing FF Global Shortest Router Trips");
} }
else { else {
Log->Write("\nWARNING: \tExit Strategy Number is not 8 or 9!!!"); Log->Write("\nWARNING: \tExit Strategy Number is not 8 or 9!!!");
...@@ -1188,6 +1214,26 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag ...@@ -1188,6 +1214,26 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
return false; return false;
} }
} }
else if ((strategy == "ff_global_shortest") &&
(std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
//pRoutingStrategies.push_back(make_pair(id, ROUTING_FF_GLOBAL_SHORTEST));
Router *r = new FFRouter(id, ROUTING_FF_GLOBAL_SHORTEST, hasSpecificGoals, _config);
_config->GetRoutingEngine()->AddRouter(r);
if ((_exit_strat_number == 8) || (_exit_strat_number == 9)){
Log->Write("\nINFO: \tUsing FF Global Shortest Router");
}
else {
Log->Write("\nWARNING: \tExit Strategy Number is not 8 or 9!!!");
// config object holds default values, so we omit any set operations
}
///Parsing additional options
if (!ParseFfRouterOps(e, ROUTING_FF_GLOBAL_SHORTEST)) {
return false;
}
}
else if ((strategy == "ff_local_shortest") && else if ((strategy == "ff_local_shortest") &&
(std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) { (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
//pRoutingStrategies.push_back(make_pair(id, ROUTING_FF_GLOBAL_SHORTEST)); //pRoutingStrategies.push_back(make_pair(id, ROUTING_FF_GLOBAL_SHORTEST));
...@@ -1221,6 +1267,12 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag ...@@ -1221,6 +1267,12 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
return false; return false;
} }
} }
else if ((strategy == "trips") &&
(std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
Router *r = new TripsRouter(id, ROUTING_TRIPS, _config);
_config->GetRoutingEngine()->AddRouter(r);
}
else if (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) { else if (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) {
Log->Write("ERROR: \twrong value for routing strategy [%s]!!!\n", Log->Write("ERROR: \twrong value for routing strategy [%s]!!!\n",
strategy.c_str()); strategy.c_str());
......
...@@ -299,6 +299,12 @@ void Simulation::UpdateRoutesAndLocations() ...@@ -299,6 +299,12 @@ void Simulation::UpdateRoutesAndLocations()
const map<int, Goal*>& goals = _building->GetAllGoals(); const map<int, Goal*>& goals = _building->GetAllGoals();
auto allRooms = _building->GetAllRooms(); auto allRooms = _building->GetAllRooms();
// for (signed int p = 0; p < allPeds.size(); ++p) {
// Pedestrian* ped = allPeds[p];
//
// std::cout << "FinalDestination of [" << ped->GetID() << "] in (" << ped->GetRoomID() << ", " << ped->GetSubRoomID() << "/" << ped->GetSubRoomUID() << "): " << ped->GetFinalDestination() << std::endl;
// }
#pragma omp parallel for shared(pedsToRemove, allRooms) #pragma omp parallel for shared(pedsToRemove, allRooms)
for (signed int p = 0; p < allPeds.size(); ++p) { for (signed int p = 0; p < allPeds.size(); ++p) {
auto ped = allPeds[p]; auto ped = allPeds[p];
...@@ -307,8 +313,7 @@ void Simulation::UpdateRoutesAndLocations() ...@@ -307,8 +313,7 @@ void Simulation::UpdateRoutesAndLocations()
//set the new room if needed //set the new room if needed
if ((ped->GetFinalDestination() == FINAL_DEST_OUT) if ((ped->GetFinalDestination() == FINAL_DEST_OUT)
&& (room->GetCaption() == "outside")) { && (room->GetCaption() == "outside")) { //TODO Hier aendern fuer inside goals?
#pragma omp critical(Simulation_Update_pedsToRemove) #pragma omp critical(Simulation_Update_pedsToRemove)
pedsToRemove.insert(ped); pedsToRemove.insert(ped);
} else if ((ped->GetFinalDestination() != FINAL_DEST_OUT) } else if ((ped->GetFinalDestination() != FINAL_DEST_OUT)
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "math/OperationalModel.h" #include "math/OperationalModel.h"
#include "math/ODESolver.h" #include "math/ODESolver.h"
#include "routing/global_shortest/GlobalRouter.h" #include "routing/global_shortest/GlobalRouter.h"
#include "routing/global_shortest_trips/GlobalRouterTrips.h"
#include "routing/quickest/QuickestPathRouter.h" #include "routing/quickest/QuickestPathRouter.h"
#include "routing/DirectionStrategy.h" #include "routing/DirectionStrategy.h"
#include "routing/RoutingEngine.h" #include "routing/RoutingEngine.h"
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "ArgumentParser.h" #include "ArgumentParser.h"
#include "../pedestrian/AgentsParameters.h" #include "../pedestrian/AgentsParameters.h"
#include "../routing/global_shortest/GlobalRouter.h" #include "../routing/global_shortest/GlobalRouter.h"
#include "../routing/global_shortest_trips/GlobalRouterTrips.h"
#include "../routing/quickest/QuickestPathRouter.h" #include "../routing/quickest/QuickestPathRouter.h"
#include "../routing/smoke_router/SmokeRouter.h" #include "../routing/smoke_router/SmokeRouter.h"
#include "../IO/IniFileParser.h" #include "../IO/IniFileParser.h"
......
...@@ -128,10 +128,12 @@ enum RoutingStrategy { ...@@ -128,10 +128,12 @@ enum RoutingStrategy {
ROUTING_FROM_FILE, ROUTING_FROM_FILE,
ROUTING_SMOKE, ROUTING_SMOKE,
ROUTING_AI, ROUTING_AI,
ROUTING_AI_TRIPS,
ROUTING_FLOORFIELD, ROUTING_FLOORFIELD,
ROUTING_FF_GLOBAL_SHORTEST, ROUTING_FF_GLOBAL_SHORTEST,
ROUTING_FF_LOCAL_SHORTEST, ROUTING_FF_LOCAL_SHORTEST,
ROUTING_FF_QUICKEST, ROUTING_FF_QUICKEST,
ROUTING_TRIPS,
ROUTING_UNDEFINED =-1 ROUTING_UNDEFINED =-1
}; };
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// //
#include "Trips.h" #include "Trips.h"
//#include <random>
#include <boost/random/mersenne_twister.hpp> #include <boost/random/mersenne_twister.hpp>
#include <boost/random/discrete_distribution.hpp> #include <boost/random/discrete_distribution.hpp>
...@@ -39,7 +38,8 @@ VertexItr Trips::getGoal(int id) ...@@ -39,7 +38,8 @@ VertexItr Trips::getGoal(int id)
for (boost::tie(vi, vi_end) = boost::vertices(trips); vi != vi_end; ++vi) { for (boost::tie(vi, vi_end) = boost::vertices(trips); vi != vi_end; ++vi) {
if(trips[*vi].getID() == id) return vi; if(trips[*vi].getID() == id) return vi;
} }
return vi_end;} return vi_end;
}
void Trips::addConnection(int sourceId, int destinationId, EdgeProperty& weight) void Trips::addConnection(int sourceId, int destinationId, EdgeProperty& weight)
{ {
...@@ -87,12 +87,6 @@ int Trips::getNextGoal(int id) ...@@ -87,12 +87,6 @@ int Trips::getNextGoal(int id)
} }
// Random number generator // Random number generator
// std::random_device rd;
// std::mt19937 gen(rd());
//
// std::default_random_engine generator;
// std::discrete_distribution<double> distribution (weights.begin(), weights.end());
boost::mt19937 gen; boost::mt19937 gen;
boost::random::discrete_distribution<> dist(weights.begin(), weights.end()); boost::random::discrete_distribution<> dist(weights.begin(), weights.end());
......
...@@ -94,3 +94,7 @@ RoutingStrategy Router::GetStrategy() const ...@@ -94,3 +94,7 @@ RoutingStrategy Router::GetStrategy() const
return _strategy; return _strategy;
} }
void Router::SetTrips(const Trips& trips){
_trips = trips;
std::cout << _trips << std::endl;
}
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <vector> #include <vector>
#include "../general/Macros.h" #include "../general/Macros.h"
#include "../IO/Trips.h" #include "../geometry/Trips.h"
class Building; class Building;
class Pedestrian; class Pedestrian;
...@@ -140,6 +140,8 @@ public: ...@@ -140,6 +140,8 @@ public:
*/ */
virtual bool ParseAdditionalParameters(){return true;}; virtual bool ParseAdditionalParameters(){return true;};
void SetTrips(const Trips& trips);
}; };
#endif /* _ROUTING_H */ #endif /* _ROUTING_H */
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "RoutingEngine.h" #include "RoutingEngine.h"
#include "../pedestrian/Pedestrian.h" #include "../pedestrian/Pedestrian.h"
#include "../geometry/Trips.h"
using namespace std; using namespace std;
...@@ -68,19 +69,19 @@ void RoutingEngine::AddRouter(Router* router) ...@@ -68,19 +69,19 @@ void RoutingEngine::AddRouter(Router* router)
} }
_routersCollection.push_back(router); _routersCollection.push_back(router);
} }
//
const vector<string>& RoutingEngine::GetTrip(int index) const //const vector<string>& RoutingEngine::GetTrip(int index) const
{ //{
if ((index >= 0) && (index < (int) _tripsCollection.size())) // if ((index >= 0) && (index < (int) _tripsCollection.size()))
return _tripsCollection[index]; // return _tripsCollection[index];
else { // else {
char tmp[CLENGTH]; // char tmp[CLENGTH];
sprintf(tmp, "ERROR: \tWrong 'index' [%d] > [%d] in Routing::GetTrip()", // sprintf(tmp, "ERROR: \tWrong 'index' [%d] > [%d] in Routing::GetTrip()",
index, int(_tripsCollection.size())); // index, int(_tripsCollection.size()));
Log->Write(tmp); // Log->Write(tmp);
exit(EXIT_FAILURE); // exit(EXIT_FAILURE);
} // }
} //}
const std::vector<Router*> RoutingEngine::GetAvailableRouters() const const std::vector<Router*> RoutingEngine::GetAvailableRouters() const
{ {
...@@ -110,9 +111,14 @@ Router* RoutingEngine::GetRouter(int id) const ...@@ -110,9 +111,14 @@ Router* RoutingEngine::GetRouter(int id) const
return /*(Router*)*/ nullptr; return /*(Router*)*/ nullptr;
} }
void RoutingEngine::AddTrip(vector<string> trip) void RoutingEngine::AddTrip(Trips trip)
{ {
_tripsCollection.push_back(trip); // _tripsCollection.push_back(trip);
// _tripsCollection = trip;
for(Router* router:_routersCollection)
{
router->SetTrips(trip);
}
} }
bool RoutingEngine::Init(Building* building) bool RoutingEngine::Init(Building* building)
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
class Pedestrian; class Pedestrian;
class Trips;
class RoutingEngine { class RoutingEngine {
public: public:
...@@ -60,14 +61,14 @@ public: ...@@ -60,14 +61,14 @@ public:
* Add a new trip to the system. Individual pedestrian can be assigned a particular trip. * Add a new trip to the system. Individual pedestrian can be assigned a particular trip.
* @param trip * @param trip
*/ */
void AddTrip(std::vector<std::string> trip); void AddTrip(Trips trip);
/** // /**
* Return a trip/route with the particular id // * Return a trip/route with the particular id
* @param id, the trip id // * @param id, the trip id
* @return the corresponding trip // * @return the corresponding trip
*/ // */
const std::vector<std::string>& GetTrip(int id) const; // const std::vector<std::string>& GetTrip(int id) const;
/** /**
* @return all available routers * @return all available routers
...@@ -111,7 +112,7 @@ private: ...@@ -111,7 +112,7 @@ private:
/// collections of all routers used /// collections of all routers used
std::vector<Router*> _routersCollection; std::vector<Router*> _routersCollection;
/// collection of all trips/routes /// collection of all trips/routes
std::vector<std::vector<std::string> >_tripsCollection; Trips _tripsCollection;
}; };
#endif /* ROUTINGENGINE_H_ */ #endif /* ROUTINGENGINE_H_ */
This diff is collapsed.
/**
* \file CognitiveMapStorage.h
* \date Feb 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
* Cognitive Map Storage
*
*
**/
#ifndef BRAINSTORAGE_H_
#define BRAINSTORAGE_H_
#include <unordered_map>
#include <vector>
#include "./cognitiveMap/cognitivemap.h"
#include "./perception/visibleenvironment.h"
#include "Cortex.h"
class Building;
class Pedestrian;
class InternNavigationNetwork;
typedef const Pedestrian * BStorageKeyType;
typedef std::unique_ptr<Cortex> BStorageValueType;
typedef std::unordered_map<BStorageKeyType, BStorageValueType> BStorageType;
/**
* @brief Brain Storage
*
* Cares about corteces, creation and delivery
*
*/
class AIBrainStorage {
public:
AIBrainStorage(const Building * const b, const std::string& cogMapFiles="", const std::string& signFiles="");
Cortex* operator[] (BStorageKeyType key);
void DeleteCortex(BStorageKeyType ped);
private:
const Building * const _building;
BStorageType _corteces;
//perception
//Complete environment
VisibleEnvironment _visibleEnv;
//cognitive map
std::vector<AIRegion> _regions;
std::string _cogMapFiles;
std::string _signFiles;
//Cortex
void CreateCortex(BStorageKeyType ped);
void ParseCogMap(BStorageKeyType ped);
void ParseSigns();
// internal graph network in every room (for locomotion purposes)
void InitInternalNetwork(const SubRoom *sub_room);
std::unordered_map<const SubRoom*,ptrIntNetwork> _roominternalNetworks;
};
#endif /* BRAINSTORAGE_H_ */
This diff is collapsed.
#ifndef CORTEX_H
#define CORTEX_H
#include "cognitiveMap/cognitivemap.h"
#include "./perception/visibleenvironment.h"
#include "./cognitiveMap/internnavigationnetwork.h"
#include "./perception/visualsystem.h"
using ptrIntNetwork = std::unique_ptr<InternNavigationNetwork>;
class Cortex
{
public:
Cortex();
Cortex(const Building* b,const Pedestrian* ped, const VisibleEnvironment* env, std::unordered_map<const SubRoom*, ptrIntNetwork>* roominternalNetworks);
AICognitiveMap& GetCognitiveMap();
VisualSystem& GetPerceptionAbilities();
//to enable hline handling
const NavLine* GetNextNavLine(const NavLine *nextTarget);
bool HlineReached() const;
std::vector<const NavLine*> SortConGeneralKnow(const std::vector<const NavLine *> &navLines);
//select appropriate crossings