Commit 0e5c688f authored by Ulrich Kemloh's avatar Ulrich Kemloh

Refactoring events manager and part merging of the information sharing.

parent 5c9d5b77
...@@ -26,7 +26,7 @@ the implied warranties of merchantability and fitness for a particular purpose. ...@@ -26,7 +26,7 @@ the implied warranties of merchantability and fitness for a particular purpose.
The software and accompanying documentation, if any, provided hereunder is The software and accompanying documentation, if any, provided hereunder is
provided “as is”. JuPedSim has no obligation to provide maintenance, support, provided “as is”. JuPedSim has no obligation to provide maintenance, support,
updates, enhancements, or modifications. updates, enhancements, or modifications.
Forschungszentrum J ̈ulich GmbH makes no warranty, expressed or implied, Forschungszentrum Julich GmbH makes no warranty, expressed or implied,
to users of JuPedSim, and accepts no responsibility for its use. Users of JuPedSim to users of JuPedSim, and accepts no responsibility for its use. Users of JuPedSim
assume sole responsibility for determining the appropriateness of its use; and for assume sole responsibility for determining the appropriateness of its use; and for
any actions taken or not taken as a result of analyses performed using this tool. any actions taken or not taken as a result of analyses performed using this tool.
......
...@@ -292,15 +292,15 @@ int Simulation::RunSimulation() ...@@ -292,15 +292,15 @@ int Simulation::RunSimulation()
// update the positions // update the positions
_operationalModel->ComputeNextTimeStep(t, _deltaT, _building.get()); _operationalModel->ComputeNextTimeStep(t, _deltaT, _building.get());
// update the routes and locations //update the routes and locations
//Update();
UpdateRoutesAndLocations(); UpdateRoutesAndLocations();
//update the events //update the events
_em->Update_Events(t, _deltaT); _em->Update_Events(t);
//_em->ProcessEvent();
//other updates //other updates
//someone might have leave the building //someone might have left the building
_nPeds = _building->GetAllPedestrians().size(); _nPeds = _building->GetAllPedestrians().size();
//update the linked cells //update the linked cells
......
This diff is collapsed.
...@@ -29,6 +29,10 @@ ...@@ -29,6 +29,10 @@
#include <string> #include <string>
class Building; class Building;
class Router;
class GlobalRouter;
class QuickestPathRouter;
class RoutingEngine;
extern OutputHandler* Log; extern OutputHandler* Log;
...@@ -42,22 +46,83 @@ private: ...@@ -42,22 +46,83 @@ private:
std::string _projectFilename; std::string _projectFilename;
std::string _projectRootDir; std::string _projectRootDir;
Building *_building; Building *_building;
double _deltaT;
FILE *_file; FILE *_file;
bool _dynamic; bool _dynamic;
int _eventCounter; int _eventCounter;
long int _lastUpdateTime; long int _lastUpdateTime;
//save the router corresponding to the actual state of the building
std::map<std::string, RoutingEngine*> _eventEngineStorage;
//save the available routers defined in the simulation
std::vector<RoutingStrategy> _availableRouters;
private:
/**
* collect the close doors and generate a new graph
* @param _building
*/
bool CreateRoutingEngine(Building* _b, int first_engine=false);
/**
* Create a router corresponding to the given strategy
* @param strategy
* @return a router/NULL for invalid strategies
*/
Router * CreateRouter(const RoutingStrategy& strategy);
/**
* Update the knowledge about closed doors.
* Each pedestrian who is xx metres from a closed door,
* will save that information
* @param _b, the building object
*/
bool UpdateAgentKnowledge(Building* _b);
/**
* Merge the knowledge of the two pedestrians.
* The information with the newest timestamp
* is always accepted with a probability of one.
* @param p1, first pedestrian
* @param p2, second pedestrian
*/
void MergeKnowledge(Pedestrian* p1, Pedestrian* p2);
/**
* Update the pedestrian route based on the new information
* @param p1
* @return
*/
bool UpdateRoute(Pedestrian* p1);
public: public:
//constructor ///constructor
EventManager(Building *_b); EventManager(Building *_b);
void SetProjectFilename(const std::string &filename);
void SetProjectRootDir(const std::string &filename); /**
* Read and parse the events
* @return false if an error occured
*/
bool ReadEventsXml(); bool ReadEventsXml();
/**
* Print the parsed events
*/
void ListEvents(); void ListEvents();
/**
* Read and parse events from a text file
* @param time
*/
void ReadEventsTxt(double time); void ReadEventsTxt(double time);
//Update
void Update_Events(double time, double d); /**
* Process the events at runtime
* @param time
*/
void Update_Events(double time);
//process the event using the current time stamp
//from the pedestrian class
void ProcessEvent();
//Eventhandling //Eventhandling
void CloseDoor(int id); void CloseDoor(int id);
void OpenDoor(int id); void OpenDoor(int id);
......
...@@ -699,7 +699,7 @@ void Building::AddHline(Hline* line) ...@@ -699,7 +699,7 @@ void Building::AddHline(Hline* line)
// check if the lines are identical // check if the lines are identical
Hline* ori= _hLines[line->GetID()]; Hline* ori= _hLines[line->GetID()];
if(ori->operator ==(*line)) { if(ori->operator ==(*line)) {
Log->Write("INFO: Skipping identical hlines with ID [%d]",line->GetID()); Log->Write("INFO: \tSkipping identical hlines with ID [%d]",line->GetID());
return; return;
} else { } else {
Log->Write( Log->Write(
...@@ -869,7 +869,7 @@ bool Building::IsVisible(Line* l1, Line* l2, bool considerHlines) ...@@ -869,7 +869,7 @@ bool Building::IsVisible(Line* l1, Line* l2, bool considerHlines)
return true; return true;
} }
bool Building::ped_is_visible(const Point& p1, const Point& p2, bool considerHlines) bool Building::IsVisible(const Point& p1, const Point& p2, bool considerHlines)
{ {
for (unsigned int i = 0; i < _rooms.size(); i++) { for (unsigned int i = 0; i < _rooms.size(); i++) {
Room* room = _rooms[i]; Room* room = _rooms[i];
......
...@@ -133,7 +133,7 @@ public: ...@@ -133,7 +133,7 @@ public:
* Alls walls and transitions and crossings are used in this check. * Alls walls and transitions and crossings are used in this check.
* The use of hlines is optional, because they are not real, can be considered transparent * The use of hlines is optional, because they are not real, can be considered transparent
*/ */
bool ped_is_visible(const Point& p1, const Point& p2, bool considerHlines=false); bool IsVisible(const Point& p1, const Point& p2, bool considerHlines=false);
/** /**
* @return a crossing or a transition matching the given caption. * @return a crossing or a transition matching the given caption.
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JPScore project="JPS-Project" version="0.5" <JPScore project="JPS-Project" version="0.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xsd/jps_events.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <events>
xsi:noNamespaceSchemaLocation="../../xsd/jps_events.xsd"> <event time="1" type="door" state="close" id="8" caption="left_exit" />
<events> <event time="10" type="door" state="open" id="8" caption="left_exit" />
<event time="1" type="door" state="close" id="8" caption="left_exit" /> <event time="25" type="door" state="close" id="4" caption="main_exit" />
<event time="10" type="door" state="open" id="8" caption="left_exit" /> <event time="40" type="door" state="open" id="4" caption="main_exit" />
<event time="25" type="door" state="close" id="4" caption="main_exit" /> <event time="70" type="door" state="close" id="8" caption="main_exit" />
<event time="40" type="door" state="open" id="4" caption="main_exit" /> </events>
</events>
</JPScore> </JPScore>
\ No newline at end of file
...@@ -163,7 +163,7 @@ void GCFMModel::ComputeNextTimeStep(double current, double deltaT, Building* bui ...@@ -163,7 +163,7 @@ void GCFMModel::ComputeNextTimeStep(double current, double deltaT, Building* bui
Pedestrian* ped1 = neighbours[i]; Pedestrian* ped1 = neighbours[i];
Point p1 = ped->GetPos(); Point p1 = ped->GetPos();
Point p2 = ped1->GetPos(); Point p2 = ped1->GetPos();
bool ped_is_visible = building->ped_is_visible(p1, p2, false); bool ped_is_visible = building->IsVisible(p1, p2, false);
if (!ped_is_visible) if (!ped_is_visible)
continue; continue;
// if(debugPed == ped->GetID()) // if(debugPed == ped->GetID())
......
...@@ -201,7 +201,7 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building* ...@@ -201,7 +201,7 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
//if they are in the same subroom //if they are in the same subroom
Point p1 = ped->GetPos(); Point p1 = ped->GetPos();
Point p2 = ped1->GetPos(); Point p2 = ped1->GetPos();
bool isVisible = building->ped_is_visible(p1, p2, false); bool isVisible = building->IsVisible(p1, p2, false);
if (!isVisible) if (!isVisible)
continue; continue;
// if(debugPed == ped->GetID()) // if(debugPed == ped->GetID())
......
...@@ -73,8 +73,9 @@ Pedestrian::Pedestrian() ...@@ -73,8 +73,9 @@ Pedestrian::Pedestrian()
_lastPosition = Point(0,0); _lastPosition = Point(0,0);
_lastCellPosition = -1; _lastCellPosition = -1;
_recordingTime = 20; //seconds _recordingTime = 20; //seconds
_knownDoors = map<int, NavLineState>(); // _knownDoors = map<int, NavLineState>();
_height = 160; _knownDoors.clear();
_height = 170;
_age = 30; _age = 30;
_gender = "male"; _gender = "male";
_trip = vector<int> (); _trip = vector<int> ();
...@@ -82,7 +83,8 @@ Pedestrian::Pedestrian() ...@@ -82,7 +83,8 @@ Pedestrian::Pedestrian()
_spotlight = false; _spotlight = false;
_V0UpStairs=0.0; _V0UpStairs=0.0;
_V0DownStairs=0.0; _V0DownStairs=0.0;
_DistToBlockade=0.0; _distToBlockade=0.0;
_routingStrategy=ROUTING_GLOBAL_SHORTEST;
} }
...@@ -243,6 +245,11 @@ int Pedestrian::GetUniqueRoomID() const ...@@ -243,6 +245,11 @@ int Pedestrian::GetUniqueRoomID() const
return _roomID * 1000 + _subRoomID; return _roomID * 1000 + _subRoomID;
} }
RoutingStrategy Pedestrian::GetRoutingStrategy() const
{
return _routingStrategy;
}
// returns the exit Id corresponding to the // returns the exit Id corresponding to the
// unique subroom identifier // unique subroom identifier
...@@ -286,12 +293,14 @@ void Pedestrian::ClearMentalMap() ...@@ -286,12 +293,14 @@ void Pedestrian::ClearMentalMap()
_exitIndex = -1; _exitIndex = -1;
} }
void Pedestrian::AddKnownClosedDoor(int door) void Pedestrian::AddKnownClosedDoor(int door, double time)
{ {
if(_knownDoors.find(door) == _knownDoors.end()) { // if(_knownDoors.find(door) == _knownDoors.end()) {
_knownDoors[door].close(GetGlobalTime()); // _knownDoors[door].close(GetGlobalTime());
} // }
return; // return;
if(time==0) time=_globalTime;
_knownDoors[door].SetState(true,time);
} }
int Pedestrian::DoorKnowledgeCount() const int Pedestrian::DoorKnowledgeCount() const
...@@ -314,11 +323,22 @@ set<int> Pedestrian::GetKnownClosedDoors() ...@@ -314,11 +323,22 @@ set<int> Pedestrian::GetKnownClosedDoors()
return doors_closed; return doors_closed;
} }
//TODO: remove
map<int, NavLineState> * Pedestrian::GetKnownDoors() map<int, NavLineState> * Pedestrian::GetKnownDoors()
{ {
return & _knownDoors; return & _knownDoors;
} }
void Pedestrian::ClearKnowledge()
{
_knownDoors.clear();
}
const map<int, NavLineState>& Pedestrian::GetKnownledge() const
{
return _knownDoors;
}
void Pedestrian::MergeKnownClosedDoors( map<int, NavLineState> * input) void Pedestrian::MergeKnownClosedDoors( map<int, NavLineState> * input)
{ {
map<int, NavLineState>::iterator it; map<int, NavLineState>::iterator it;
...@@ -444,7 +464,7 @@ const Point& Pedestrian::GetV0(const Point& target) ...@@ -444,7 +464,7 @@ const Point& Pedestrian::GetV0(const Point& target)
//new_v0 = delta.NormalizedMolified(); //new_v0 = delta.NormalizedMolified();
new_v0 = delta.Normalized(); new_v0 = delta.Normalized();
// -------------------------------------- Handover new target // -------------------------------------- Handover new target
t = _newOrientationDelay++ *_deltaT/(1.0+1000* _DistToBlockade); t = _newOrientationDelay++ *_deltaT/(1.0+1000* _distToBlockade);
_V0 = _V0 + (new_v0 - _V0)*( 1 - exp(-t/_tau) ); _V0 = _V0 + (new_v0 - _V0)*( 1 - exp(-t/_tau) );
#if DEBUG #if DEBUG
...@@ -452,7 +472,7 @@ const Point& Pedestrian::GetV0(const Point& target) ...@@ -452,7 +472,7 @@ const Point& Pedestrian::GetV0(const Point& target)
printf("Goal Line=[%f, %f]-[%f, %f]\n", _navLine->GetPoint1().GetX(), _navLine->GetPoint1().GetY(), _navLine->GetPoint2().GetX(), _navLine->GetPoint2().GetY()); printf("Goal Line=[%f, %f]-[%f, %f]\n", _navLine->GetPoint1().GetX(), _navLine->GetPoint1().GetY(), _navLine->GetPoint2().GetX(), _navLine->GetPoint2().GetY());
printf("Ped=%d, sub=%d, room=%d pos=[%f, %f], target=[%f, %f]\n", _id, _subRoomID, _roomID, pos.GetX(), pos.GetY(), target.GetX(), target.GetY()); printf("Ped=%d, sub=%d, room=%d pos=[%f, %f], target=[%f, %f]\n", _id, _subRoomID, _roomID, pos.GetX(), pos.GetY(), target.GetX(), target.GetY());
printf("Ped=%d : BEFORE new_v0=%f %f norm = %f\n", _id, new_v0.GetX(), new_v0.GetY(), new_v0.Norm()); printf("Ped=%d : BEFORE new_v0=%f %f norm = %f\n", _id, new_v0.GetX(), new_v0.GetY(), new_v0.Norm());
printf("ped=%d: t=%f, _newOrientationFlag=%d, neworientationDelay=%d, _DistToBlockade=%f\n", _id,t, _newOrientationFlag, _newOrientationDelay, _DistToBlockade); printf("ped=%d: t=%f, _newOrientationFlag=%d, neworientationDelay=%d, _DistToBlockade=%f\n", _id,t, _newOrientationFlag, _newOrientationDelay, _distToBlockade);
printf("_v0=[%f, %f] norm = %f\n", _V0.GetX(), _V0.GetY(), _V0.Norm()); printf("_v0=[%f, %f] norm = %f\n", _V0.GetX(), _V0.GetY(), _V0.Norm());
} }
// getc(stdin); // getc(stdin);
...@@ -485,7 +505,7 @@ double Pedestrian::GetTimeInJam() const ...@@ -485,7 +505,7 @@ double Pedestrian::GetTimeInJam() const
void Pedestrian::SetSmoothTurning() void Pedestrian::SetSmoothTurning()
{ {
_newOrientationDelay = 0; _newOrientationDelay = 0;
} }
...@@ -536,42 +556,42 @@ bool Pedestrian::IsReadyForRerouting() ...@@ -536,42 +556,42 @@ bool Pedestrian::IsReadyForRerouting()
double Pedestrian::GetReroutingTime() double Pedestrian::GetReroutingTime()
{ {
return _timeBeforeRerouting; return _timeBeforeRerouting;
} }
bool Pedestrian::GetNewEventFlag() bool Pedestrian::GetNewEventFlag()
{ {
return _newEventFlag; return _newEventFlag;
} }
bool Pedestrian::GetNewOrientationFlag() bool Pedestrian::GetNewOrientationFlag()
{ {
return _newOrientationFlag; return _newOrientationFlag;
} }
void Pedestrian::SetDistToBlockade(double dist) void Pedestrian::SetDistToBlockade(double dist)
{ {
_DistToBlockade = dist; _distToBlockade = dist;
} }
double Pedestrian::GetDistToBlockade() double Pedestrian::GetDistToBlockade()
{ {
return _DistToBlockade; return _distToBlockade;
} }
void Pedestrian::SetNewOrientationFlag(bool flag) void Pedestrian::SetNewOrientationFlag(bool flag)
{ {
_newOrientationFlag=flag; _newOrientationFlag=flag;
} }
void Pedestrian::SetNewEventFlag(bool flag) void Pedestrian::SetNewEventFlag(bool flag)
{ {
_newEventFlag=flag; _newEventFlag=flag;
} }
double Pedestrian::GetAge() const double Pedestrian::GetAge() const
{ {
return _age; return _age;
} }
void Pedestrian::SetAge(double age) void Pedestrian::SetAge(double age)
...@@ -626,9 +646,9 @@ double Pedestrian::GetRecordingTime() const ...@@ -626,9 +646,9 @@ double Pedestrian::GetRecordingTime() const
} }
double Pedestrian::GetMeanVelOverRecTime() const { double Pedestrian::GetMeanVelOverRecTime() const {
//just few position were saved //just few position were saved
if (_lastPositions.size()<2) return _ellipse.GetV().Norm(); if (_lastPositions.size()<2) return _ellipse.GetV().Norm();
return fabs ( (_lastPositions.back()-_lastPositions.front()).Norm() / _recordingTime ); return fabs ( (_lastPositions.back()-_lastPositions.front()).Norm() / _recordingTime );
} }
double Pedestrian::GetDistanceToNextTarget() const double Pedestrian::GetDistanceToNextTarget() const
...@@ -684,7 +704,7 @@ void Pedestrian::Dump(int ID, int pa) ...@@ -684,7 +704,7 @@ void Pedestrian::Dump(int ID, int pa)
switch (pa) { switch (pa) {
case 0: { case 0:
printf(">> Room/Subroom [%d / %d]\n", _roomID, _subRoomID); printf(">> Room/Subroom [%d / %d]\n", _roomID, _subRoomID);
printf(">> Destination [ %d ]\n", _exitIndex); printf(">> Destination [ %d ]\n", _exitIndex);
printf(">> Final Destination [ %d ]\n", _desiredFinalDestination); printf(">> Final Destination [ %d ]\n", _desiredFinalDestination);
...@@ -693,17 +713,14 @@ void Pedestrian::Dump(int ID, int pa) ...@@ -693,17 +713,14 @@ void Pedestrian::Dump(int ID, int pa)
printf(">> Velocity [%0.2f, %0.2f] Norm = [%0.2f]\n", GetV().GetX(), GetV().GetY(), GetV().Norm()); printf(">> Velocity [%0.2f, %0.2f] Norm = [%0.2f]\n", GetV().GetX(), GetV().GetY(), GetV().Norm());
if(GetExitLine()) { if(GetExitLine()) {
printf(">> ExitLine: (%0.2f, %0.2f) -- (%0.2f, %0.2f)\n", GetExitLine()->GetPoint1().GetX(), GetExitLine()->GetPoint1().GetY(), printf(">> ExitLine: (%0.2f, %0.2f) -- (%0.2f, %0.2f)\n", GetExitLine()->GetPoint1().GetX(), GetExitLine()->GetPoint1().GetY(),
GetExitLine()->GetPoint2().GetX(), GetExitLine()->GetPoint2().GetY()); GetExitLine()->GetPoint2().GetX(), GetExitLine()->GetPoint2().GetY());
printf(">> dist: %f\n", GetExitLine()->DistTo(GetPos())); printf(">> dist: %f\n", GetExitLine()->DistTo(GetPos()));
} }
printf(">> smooth rotating: %s \n", (_newOrientationDelay > 0) ? "yes" : "no"); printf(">> smooth rotating: %s \n", (_newOrientationDelay > 0) ? "yes" : "no");
printf(">> mental map"); printf(">> mental map");
map<int, int>::iterator iter; for(auto&& item: _mentalMap)
for (iter = _mentalMap.begin(); iter != _mentalMap.end(); iter++) { printf("\t room / destination [%d, %d]\n", item.first, item.second);
printf("\t room / destination [%d, %d]\n", iter->first, iter->second); break;
}
}
break;
case 1: case 1:
printf(">> Position [%f, %f]\n", GetPos().GetX(), GetPos().GetY()); printf(">> Position [%f, %f]\n", GetPos().GetX(), GetPos().GetY());
...@@ -724,14 +741,20 @@ void Pedestrian::Dump(int ID, int pa) ...@@ -724,14 +741,20 @@ void Pedestrian::Dump(int ID, int pa)
case 5: case 5:
printf(">> Destination [ %d ]\n", _exitIndex); printf(">> Destination [ %d ]\n", _exitIndex);
break; break;
case 6: { //Mental Map
case 6: //Mental Map
printf(">> mental map"); printf(">> mental map");
map<int, int>::iterator iter; for(auto&& item: _mentalMap)
for (iter = _mentalMap.begin(); iter != _mentalMap.end(); iter++) { printf("\t room / destination [%d, %d]", item.first, item.second);
printf("\t room / destination [%d, %d]", iter->first, iter->second); break;
}
} case 7:
break; for(auto&& item:_knownDoors)
printf("\t door [%d] closed since [%lf] sec\n", item.first, item.second.GetTime());
break;
default:
break;
} }
fflush(stdout); fflush(stdout);
...@@ -756,6 +779,7 @@ double Pedestrian::GetGlobalTime() ...@@ -756,6 +779,7 @@ double Pedestrian::GetGlobalTime()
void Pedestrian::SetRouter(Router* router) void Pedestrian::SetRouter(Router* router)
{ {
_router=router; _router=router;
_routingStrategy=router->GetStrategy();
} }
Router* Pedestrian::GetRouter() const Router* Pedestrian::GetRouter() const
......
...@@ -45,9 +45,9 @@ class NavLine; ...@@ -45,9 +45,9 @@ class NavLine;
class Router; class Router;
class Pedestrian { class Pedestrian
{
private: private:
//generic parameters, independent from models //generic parameters, independent from models
int _id; //starting with 1 int _id; //starting with 1
int _exitIndex; // current exit int _exitIndex; // current exit
...@@ -85,15 +85,11 @@ private: ...@@ -85,15 +85,11 @@ private:
Point _lastPosition; Point _lastPosition;
int _lastCellPosition; int _lastCellPosition;
/** ///state of doors with time stamps
* A set with UniqueIDs of closed crossings,
* transitions or hlines (hlines doesnt make that much sense,
* just that they are removed from the routing graph)
*/
std::map<int, NavLineState> _knownDoors; std::map<int, NavLineState> _knownDoors;
/// distance to nearest obstacle that blocks the sight of ped.
double _DistToBlockade=0; // distance to nearest obstacle that blocks the sight of ped. double _distToBlockade;
//routing parameters //routing parameters
/// new orientation after 10 seconds /// new orientation after 10 seconds
double _reroutingThreshold; double _reroutingThreshold;
...@@ -109,6 +105,8 @@ private: ...@@ -109,6 +105,8 @@ private:
std::queue <Point> _lastPositions; std::queue <Point> _lastPositions;
/// store the last velocities /// store the last velocities
std::queue <Point> _lastVelocites; std::queue <Point> _lastVelocites;
/// routing strategy followed
RoutingStrategy _routingStrategy;
int _newOrientationDelay; //2 seconds, in steps int _newOrientationDelay; //2 seconds, in steps
...@@ -183,6 +181,7 @@ public: ...@@ -183,6 +181,7 @@ public:
const Point& GetV0() const; const Point& GetV0() const;
const Point& GetV0(const Point& target); const Point& GetV0(const Point& target);
void InitV0(const Point& target); void InitV0(const Point& target);
/** /**
* the desired speed is the projection of the speed on the horizontal plane. * the desired speed is the projection of the speed on the horizontal plane.
* @return the norm of the desired speed. * @return the norm of the desired speed.
...@@ -198,12 +197,20 @@ public: ...@@ -198,12 +197,20 @@ public:
void ClearMentalMap(); // erase the peds memory void ClearMentalMap(); // erase the peds memory
// functions for known closed Doors (needed for the Graphrouting and Rerouting) // functions for known closed Doors (needed for the Graphrouting and Rerouting)
void AddKnownClosedDoor(int door); void AddKnownClosedDoor(int door, double time=0);//TODo: refactor and remove =0
std::set<int> GetKnownClosedDoors(); std::set<int> GetKnownClosedDoors();
void MergeKnownClosedDoors(std::map<int, NavLineState> * input); void MergeKnownClosedDoors(std::map<int, NavLineState> * input);
std::map<int, NavLineState> * GetKnownDoors(); std::map<int, NavLineState> * GetKnownDoors();
int DoorKnowledgeCount() const; int DoorKnowledgeCount() const;
// needed for information sharing
const std::map<int, NavLineState>& GetKnownledge() const;
/**
* clear all information related to the knowledge about closed doors
*/
void ClearKnowledge();
RoutingStrategy GetRoutingStrategy() const;
int GetUniqueRoomID() const; int GetUniqueRoomID() const;
int GetNextDestination(); int GetNextDestination();
int GetLastDestination(); int GetLastDestination();
......
...@@ -296,7 +296,7 @@ bool GlobalRouter::Init(Building* building) ...@@ -296,7 +296,7 @@ bool GlobalRouter::Init(Building* building)
if (nav1->operator ==(*nav2)) if (nav1->operator ==(*nav2))
continue; continue;
if (building->ped_is_visible(nav1->GetCentre(), nav2->GetCentre(), true)) { if (building->IsVisible(nav1->GetCentre(), nav2->GetCentre(), true)) {
int to_door = _map_id_to_index[nav2->GetUniqueID()]; int to_door = _map_id_to_index[nav2->GetUniqueID()];
_distMatrix[from_door][to_door] = penalty*(nav1->GetCentre() _distMatrix[from_door][to_door] = penalty*(nav1->GetCentre()
- nav2->GetCentre()).Norm(); - nav2->GetCentre()).Norm();
......
...@@ -69,7 +69,7 @@ void RoutingEngine::AddRouter(Router* router) ...@@ -69,7 +69,7 @@ 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];
...@@ -82,23 +82,31 @@ const vector<string> RoutingEngine::GetTrip(int index) const ...@@ -82,23 +82,31 @@ const vector<string> RoutingEngine::GetTrip(int index) const
} }
} }
const std::vector<Router*> RoutingEngine::GetAvailableRouters() const
{
return _routersCollection;
}
Router* RoutingEngine::GetRouter(RoutingStrategy strategy) const Router* RoutingEngine::GetRouter(RoutingStrategy strategy) const
{ {
for(unsigned int r=0; r<_routersCollection.size(); r++) { for(Router* router:_routersCollection)
if(_routersCollection[r]->GetStrategy()==strategy) {