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)
std::cout << waitingArea->toString() << std::endl;
}
// building->AddTrip(trips);
_configuration->GetRoutingEngine()->AddTrip(trips);
std::cout << trips;
}
//load routes
TiXmlNode* xTripsNode = xRootNode->FirstChild("routing")->FirstChild("routes");
if (xTripsNode)
for (TiXmlElement* trip = xTripsNode->FirstChildElement("route"); trip;
trip = trip->NextSiblingElement("route")) {
double id = xmltof(trip->Attribute("id"), -1);
if (id==-1) {
Log->Write("ERROR:\t id missing for trip");
return false;
}
std::string sTrip = trip->FirstChild()->ValueStr();
std::vector<std::string> vTrip;
vTrip.clear();
char* str = (char*) sTrip.c_str();
char* p = strtok(str, ":");
while (p) {
vTrip.push_back(xmltoa(p));
p = strtok(NULL, ":");
}
_configuration->GetRoutingEngine()->AddTrip(vTrip);
}
// TiXmlNode* xTripsNode = xRootNode->FirstChild("routing")->FirstChild("routes");
//
// if (xTripsNode)
// for (TiXmlElement* trip = xTripsNode->FirstChildElement("route"); trip;
// trip = trip->NextSiblingElement("route")) {
//
// double id = xmltof(trip->Attribute("id"), -1);
// if (id==-1) {
// Log->Write("ERROR:\t id missing for trip");
// return false;
// }
// std::string sTrip = trip->FirstChild()->ValueStr();
// std::vector<std::string> vTrip;
// vTrip.clear();
//
// char* str = (char*) sTrip.c_str();
// char* p = strtok(str, ":");
// while (p) {
// vTrip.push_back(xmltoa(p));
// p = strtok(NULL, ":");
// }
// _configuration->GetRoutingEngine()->AddTrip(vTrip);
// }
Log->Write("INFO:\tdone with loading extra routing information");
return true;
}
......
......@@ -25,7 +25,7 @@
#include "../general/Configuration.h"
#include "../geometry/Building.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: between geometries/rooms. Probably, EnvironmentFileParser would be better, still parts of the environment are
......
......@@ -40,10 +40,13 @@
#include "../math/GradientModel.h"
#include "../math/VelocityModel.h"
#include "../routing/global_shortest/GlobalRouter.h"
#include "../routing/global_shortest_trips/GlobalRouterTrips.h"
#include "../routing/quickest/QuickestPathRouter.h"
#include "../routing/smoke_router/SmokeRouter.h"
#include "../routing/ai_router/AIRouter.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 */
std::string ver_string(int a, int b, int c) {
......@@ -1134,6 +1137,13 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
Router *r = new GlobalRouter(id, ROUTING_GLOBAL_SHORTEST);
_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") &&
(std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
//pRoutingStrategies.push_back(make_pair(id, ROUTING_QUICKEST));
......@@ -1169,14 +1179,30 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
exit(EXIT_FAILURE);
#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()) ) {
//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);
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 {
Log->Write("\nWARNING: \tExit Strategy Number is not 8 or 9!!!");
......@@ -1188,6 +1214,26 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
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") &&
(std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
//pRoutingStrategies.push_back(make_pair(id, ROUTING_FF_GLOBAL_SHORTEST));
......@@ -1221,6 +1267,12 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
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()) {
Log->Write("ERROR: \twrong value for routing strategy [%s]!!!\n",
strategy.c_str());
......
......@@ -299,6 +299,12 @@ void Simulation::UpdateRoutesAndLocations()
const map<int, Goal*>& goals = _building->GetAllGoals();
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)
for (signed int p = 0; p < allPeds.size(); ++p) {
auto ped = allPeds[p];
......@@ -307,8 +313,7 @@ void Simulation::UpdateRoutesAndLocations()
//set the new room if needed
if ((ped->GetFinalDestination() == FINAL_DEST_OUT)
&& (room->GetCaption() == "outside")) {
&& (room->GetCaption() == "outside")) { //TODO Hier aendern fuer inside goals?
#pragma omp critical(Simulation_Update_pedsToRemove)
pedsToRemove.insert(ped);
} else if ((ped->GetFinalDestination() != FINAL_DEST_OUT)
......
......@@ -41,6 +41,7 @@
#include "math/OperationalModel.h"
#include "math/ODESolver.h"
#include "routing/global_shortest/GlobalRouter.h"
#include "routing/global_shortest_trips/GlobalRouterTrips.h"
#include "routing/quickest/QuickestPathRouter.h"
#include "routing/DirectionStrategy.h"
#include "routing/RoutingEngine.h"
......
......@@ -43,6 +43,7 @@
#include "ArgumentParser.h"
#include "../pedestrian/AgentsParameters.h"
#include "../routing/global_shortest/GlobalRouter.h"
#include "../routing/global_shortest_trips/GlobalRouterTrips.h"
#include "../routing/quickest/QuickestPathRouter.h"
#include "../routing/smoke_router/SmokeRouter.h"
#include "../IO/IniFileParser.h"
......
......@@ -128,10 +128,12 @@ enum RoutingStrategy {
ROUTING_FROM_FILE,
ROUTING_SMOKE,
ROUTING_AI,
ROUTING_AI_TRIPS,
ROUTING_FLOORFIELD,
ROUTING_FF_GLOBAL_SHORTEST,
ROUTING_FF_LOCAL_SHORTEST,
ROUTING_FF_QUICKEST,
ROUTING_TRIPS,
ROUTING_UNDEFINED =-1
};
......
......@@ -3,7 +3,6 @@
//
#include "Trips.h"
//#include <random>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/discrete_distribution.hpp>
......@@ -39,7 +38,8 @@ VertexItr Trips::getGoal(int id)
for (boost::tie(vi, vi_end) = boost::vertices(trips); vi != vi_end; ++vi) {
if(trips[*vi].getID() == id) return vi;
}
return vi_end;}
return vi_end;
}
void Trips::addConnection(int sourceId, int destinationId, EdgeProperty& weight)
{
......@@ -87,12 +87,6 @@ int Trips::getNextGoal(int id)
}
// 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::random::discrete_distribution<> dist(weights.begin(), weights.end());
......
......@@ -94,3 +94,7 @@ RoutingStrategy Router::GetStrategy() const
return _strategy;
}
void Router::SetTrips(const Trips& trips){
_trips = trips;
std::cout << _trips << std::endl;
}
......@@ -34,7 +34,7 @@
#include <vector>
#include "../general/Macros.h"
#include "../IO/Trips.h"
#include "../geometry/Trips.h"
class Building;
class Pedestrian;
......@@ -140,6 +140,8 @@ public:
*/
virtual bool ParseAdditionalParameters(){return true;};
void SetTrips(const Trips& trips);
};
#endif /* _ROUTING_H */
......@@ -28,6 +28,7 @@
#include "RoutingEngine.h"
#include "../pedestrian/Pedestrian.h"
#include "../geometry/Trips.h"
using namespace std;
......@@ -68,19 +69,19 @@ void RoutingEngine::AddRouter(Router* router)
}
_routersCollection.push_back(router);
}
const vector<string>& RoutingEngine::GetTrip(int index) const
{
if ((index >= 0) && (index < (int) _tripsCollection.size()))
return _tripsCollection[index];
else {
char tmp[CLENGTH];
sprintf(tmp, "ERROR: \tWrong 'index' [%d] > [%d] in Routing::GetTrip()",
index, int(_tripsCollection.size()));
Log->Write(tmp);
exit(EXIT_FAILURE);
}
}
//
//const vector<string>& RoutingEngine::GetTrip(int index) const
//{
// if ((index >= 0) && (index < (int) _tripsCollection.size()))
// return _tripsCollection[index];
// else {
// char tmp[CLENGTH];
// sprintf(tmp, "ERROR: \tWrong 'index' [%d] > [%d] in Routing::GetTrip()",
// index, int(_tripsCollection.size()));
// Log->Write(tmp);
// exit(EXIT_FAILURE);
// }
//}
const std::vector<Router*> RoutingEngine::GetAvailableRouters() const
{
......@@ -110,9 +111,14 @@ Router* RoutingEngine::GetRouter(int id) const
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)
......
......@@ -36,6 +36,7 @@
class Pedestrian;
class Trips;
class RoutingEngine {
public:
......@@ -60,14 +61,14 @@ public:
* Add a new trip to the system. Individual pedestrian can be assigned a particular trip.
* @param trip
*/
void AddTrip(std::vector<std::string> trip);
void AddTrip(Trips trip);
/**
* Return a trip/route with the particular id
* @param id, the trip id
* @return the corresponding trip
*/
const std::vector<std::string>& GetTrip(int id) const;
// /**
// * Return a trip/route with the particular id
// * @param id, the trip id
// * @return the corresponding trip
// */
// const std::vector<std::string>& GetTrip(int id) const;
/**
* @return all available routers
......@@ -111,7 +112,7 @@ private:
/// collections of all routers used
std::vector<Router*> _routersCollection;
/// collection of all trips/routes
std::vector<std::vector<std::string> >_tripsCollection;
Trips _tripsCollection;
};
#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
const NavLine FindApprCrossing(const std::vector<NavLine> &navLines);
const NavLine FindApprVisibleCrossing(const NavLine& navLine, const std::vector<NavLine> &navLines);
const NavLine TargetToHead(const NavLine *visibleCrossing) const;
//implement sign instruction
std::vector<const NavLine *> SortConSignage(const std::vector<const NavLine *>& navLines);
const Sign* DetermineDecisiveSign(const std::vector<const Sign *> &signs);
double OrthogonalDistanceFromTo(const Sign& sign1, const Sign& sign2) const;
double OrthogonalDistanceFromTo(const NavLine* navLine, const Sign &sign) const;
double OrthogonalDistanceFromTo(const NavLine* navLine, const Point& pos, const double& angle) const;
private:
const Building* _b;
const Pedestrian* _ped;
AICognitiveMap _cMap;
//whole environment
const VisibleEnvironment* _wholeEnvironment;
// reference of roominternalNetwork
std::unordered_map<const SubRoom*, ptrIntNetwork>* _intNetworks;
InternNavigationNetwork _currentIntNetwork;
//perception abilities
VisualSystem _perceptionAbilities;
NavLine _lastBestVisNavLine;
bool _statPreferToGoDown;
std::vector<const Sign*> _notUsedSigns;
};
bool IsInsideRectangle(const Point& point, const Point& leftUp, const Point& rightDown);
#endif // CORTEX_H
#include "associations.h"
#include "connection.h"
AIAssociation::AIAssociation()
{
_landmark=nullptr;
_associatedLandmark=nullptr;
}
AIAssociation::AIAssociation(const AILandmark *landmark, const AILandmark *associated_landmark, bool connected)
{
_landmark=landmark;
_associatedLandmark=associated_landmark;
// if (connected)
// _connection = std::make_shared<Connection>(_landmark, _associatedLandmark);
// else
_connection=nullptr;
}
AIAssociation::AIAssociation(const AIConnection *connection)
{
_connection=connection;
_landmark=nullptr;
_associatedLandmark=nullptr;
}
AIAssociation::~AIAssociation()
{
}
const AILandmark *AIAssociation::GetLandmarkAssociation(const AILandmark *landmark) const
{
if (landmark==nullptr)
return nullptr;
if (_landmark==landmark)
{
return _associatedLandmark;
}
else
return nullptr;
}
const AIConnection *AIAssociation::GetConnectionAssoziation() const
{
return _connection;
}
bool AIAssociation::operator==(const AIAssociation &asso2) const
{
return this==&asso2;
}
#ifndef ASSOCIATIONS_H
#define ASSOCIATIONS_H
#include<memory>
class AILandmark;
class AIConnection;
class AIAssociation
{
public:
AIAssociation();
AIAssociation(const AILandmark* landmark, const AILandmark* associated_landmark, bool connected=false);
AIAssociation(const AIConnection* connection);
~AIAssociation();
const AILandmark* GetLandmarkAssociation(const AILandmark* landmark) const;
const AIConnection* GetConnectionAssoziation() const;