diff --git a/geometry/WaitingArea.cpp b/geometry/WaitingArea.cpp index e82d277d483950cdb7c6832c86922d603fa25386..653e3991b57452a9f14818703a1fd907ba968e21 100644 --- a/geometry/WaitingArea.cpp +++ b/geometry/WaitingArea.cpp @@ -101,5 +101,18 @@ void WaitingArea::setWaitingTime(double waitingTime) std::vector<Line> WaitingArea::getAllLines() { - } + +int WaitingArea::GetNextGoal() +{ + double random = std::rand()/RAND_MAX; + double cumProb = 0.; + + for (auto& nextGoal : nextGoals){ + cumProb += nextGoal.second; + if (random <= cumProb ){ + return nextGoal.first; + } + } + +} \ No newline at end of file diff --git a/geometry/WaitingArea.h b/geometry/WaitingArea.h index 3070ad45de1de11be7fabdb5b1894822da93860d..390211de5d16f9d60fbb0912a56924ec12dc11ac 100644 --- a/geometry/WaitingArea.h +++ b/geometry/WaitingArea.h @@ -66,6 +66,8 @@ public: std::vector<Line> getAllLines(); + int GetNextGoal(); + private: void updateProbabilities(); bool checkProbabilities(); diff --git a/routing/ff_router_trips/ffRouterTrips.cpp b/routing/ff_router_trips/ffRouterTrips.cpp index e16e4eb140c8b9058456bdc5efa62b252bb945a9..bcbe268586c6c76aef77d027fc2cc64adbf1c55f 100644 --- a/routing/ff_router_trips/ffRouterTrips.cpp +++ b/routing/ff_router_trips/ffRouterTrips.cpp @@ -487,10 +487,12 @@ int FFRouterTrips::FindExit(Pedestrian* ped) // yes: set next goal and return findExit(p) if (subroom->IsInSubRoom(goal->GetCentroid())){ std::cout << "Ped and Goal in same subroom: " << subroom->IsInSubRoom(goal->GetCentroid()) << std::endl; - int bestDoor = 31; - ped->SetExitIndex(bestDoor); - ped->SetExitLine(_CroTrByUID.at(bestDoor)); - + std::cout << "Ped Final Destination before: " << ped->GetFinalDestination() << std::endl; + if(WaitingArea* wa = dynamic_cast<WaitingArea*>(goal)) { + ped->SetFinalDestination(wa->GetNextGoal()); + } + std::cout << "Ped Final Destination after: " << ped->GetFinalDestination() << std::endl; + ret = FindExit1(ped); }else{ ret = FindExit1(ped); }