Skip to content
Snippets Groups Projects
Commit 4109b576 authored by Ulrich Kemloh's avatar Ulrich Kemloh
Browse files

random number generator in the global router actualized

parent 7e07a914
Branches
Tags v0.4
No related merge requests found
...@@ -70,8 +70,8 @@ ...@@ -70,8 +70,8 @@
<group group_id="5" room_id="0" subroom_id="0" number="0" goal_id="" router_id="1" route_id="" motivation=""/> <group group_id="5" room_id="0" subroom_id="0" number="0" goal_id="" router_id="1" route_id="" motivation=""/>
<group group_id="0" room_id="0" subroom_id="0" number="0" goal_id="" router_id="1" route_id="" /> <group group_id="0" room_id="0" subroom_id="0" number="0" goal_id="" router_id="1" route_id="" />
<group group_id="1" room_id="0" subroom_id="1" number="0" goal_id="" router_id="2" route_id="" patience="5"/> <group group_id="1" room_id="0" subroom_id="1" number="0" goal_id="" router_id="2" route_id="" patience="5"/>
<group group_id="2" room_id="0" number="700" goal_id="-1" router_id="2" patience="40"/> <group group_id="2" room_id="0" number="500" goal_id="-1" router_id="2" patience="40"/>
<group group_id="3" room_id="1" subroom_id="1" number="10" goal_id="-1" router_id="2" patience="20"/> <group group_id="3" room_id="1" subroom_id="1" number="0" goal_id="-1" router_id="2" patience="20"/>
</agents_distribution> </agents_distribution>
</agents> </agents>
......
...@@ -48,11 +48,14 @@ using namespace std; ...@@ -48,11 +48,14 @@ using namespace std;
GlobalRouter::GlobalRouter() : GlobalRouter::GlobalRouter() :
Router() { Router() {
_accessPoints = map<int, AccessPoint*>(); _accessPoints = map<int, AccessPoint*>();
_map_id_to_index = std::map<int, int>(); _map_id_to_index = map<int, int>();
_map_index_to_id = std::map<int, int>(); _map_index_to_id = map<int, int>();
_distMatrix = NULL; _distMatrix = NULL;
_pathsMatrix = NULL; _pathsMatrix = NULL;
_building = NULL; _building = NULL;
_rdDistribution = uniform_real_distribution<double> (0,1);
_rdGenerator = default_random_engine(56);
} }
...@@ -626,6 +629,12 @@ int GlobalRouter::FindExit(Pedestrian* ped) { ...@@ -626,6 +629,12 @@ int GlobalRouter::FindExit(Pedestrian* ped) {
} }
int GlobalRouter::GetBestDefaultRandomExit(Pedestrian* ped) { int GlobalRouter::GetBestDefaultRandomExit(Pedestrian* ped) {
// prob parameters
//double alpha=0.2000005;
//double normFactor=0.0;
//map <int, double> doorProb;
// get the opened exits // get the opened exits
SubRoom* sub = _building->GetRoom(ped->GetRoomID())->GetSubRoom( SubRoom* sub = _building->GetRoom(ped->GetRoomID())->GetSubRoom(
ped->GetSubRoomID()); ped->GetSubRoomID());
...@@ -642,6 +651,9 @@ int GlobalRouter::GetBestDefaultRandomExit(Pedestrian* ped) { ...@@ -642,6 +651,9 @@ int GlobalRouter::GetBestDefaultRandomExit(Pedestrian* ped) {
//for (unsigned int i = 0; i < accessPointsInSubRoom.size(); i++) { //for (unsigned int i = 0; i < accessPointsInSubRoom.size(); i++) {
// int apID = accessPointsInSubRoom[i]; // int apID = accessPointsInSubRoom[i];
for(unsigned int g=0;g<relevantAPs.size();g++){ for(unsigned int g=0;g<relevantAPs.size();g++){
AccessPoint* ap=relevantAPs[g]; AccessPoint* ap=relevantAPs[g];
//int exitid=ap->GetID(); //int exitid=ap->GetID();
...@@ -669,9 +681,12 @@ int GlobalRouter::GetBestDefaultRandomExit(Pedestrian* ped) { ...@@ -669,9 +681,12 @@ int GlobalRouter::GetBestDefaultRandomExit(Pedestrian* ped) {
continue; continue;
} }
double dist = ap->GetDistanceTo(ped->GetFinalDestination()) double dist = ap->GetDistanceTo(ped->GetFinalDestination())
+ ap->DistanceTo(posA.GetX(), posA.GetY()); + ap->DistanceTo(posA.GetX(), posA.GetY());
// doorProb[ap->GetID()]= exp(-alpha*dist);
// normFactor += doorProb[ap->GetID()];
if (dist < minDist) { if (dist < minDist) {
bestAPsID = ap->GetID(); bestAPsID = ap->GetID();
...@@ -679,6 +694,23 @@ int GlobalRouter::GetBestDefaultRandomExit(Pedestrian* ped) { ...@@ -679,6 +694,23 @@ int GlobalRouter::GetBestDefaultRandomExit(Pedestrian* ped) {
} }
} }
// normalize the probs
// double randomVar = _rdDistribution(_rdGenerator);
//
// for (auto it = doorProb.begin(); it!=doorProb.end(); ++it){
// it->second = it->second / normFactor;
// }
//
// double cumProb= doorProb.begin()->second;
// auto it = doorProb.begin();
// while(cumProb<randomVar) {
// it++;
// cumProb+=it->second;
// }
// bestAPsID=it->first;
//exit(0);
if (bestAPsID != -1) { if (bestAPsID != -1) {
ped->SetExitIndex(bestAPsID); ped->SetExitIndex(bestAPsID);
ped->SetExitLine(_accessPoints[bestAPsID]->GetNavLine()); ped->SetExitLine(_accessPoints[bestAPsID]->GetNavLine());
......
...@@ -184,6 +184,9 @@ private: ...@@ -184,6 +184,9 @@ private:
///map the internal crossings/transition id to ///map the internal crossings/transition id to
///the global ID (description) for that final destination ///the global ID (description) for that final destination
std::map<int, int> _mapIdToFinalDestination; std::map<int, int> _mapIdToFinalDestination;
// normalize the probs
std::default_random_engine _rdGenerator;
std::uniform_real_distribution<double> _rdDistribution;
protected: protected:
std::map <int, AccessPoint*> _accessPoints; std::map <int, AccessPoint*> _accessPoints;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment