Commit 3e9a3fb0 authored by Mohcine Chraibi's avatar Mohcine Chraibi

WIP: Adress issue #158

parent f45cd63c
...@@ -93,14 +93,15 @@ bool AgentsSourcesManager::ProcessAllSources() const ...@@ -93,14 +93,15 @@ bool AgentsSourcesManager::ProcessAllSources() const
{ {
bool empty=true; bool empty=true;
double current_time = Pedestrian::GetGlobalTime(); double current_time = Pedestrian::GetGlobalTime();
// std::cout << "\n -- current time: " << current_time << " number " << _building->GetAllPedestrians().size() << std::endl;
for (const auto& src : _sources) for (const auto& src : _sources)
{ {
std::cout << "src: " << src->GetId() << " -- current time: " << current_time << " number of peds " << _building->GetAllPedestrians().size() << std::endl;
if (src->GetPoolSize() && (src->GetPlanTime() <= current_time) )// maybe diff<eps if (src->GetPoolSize() && (src->GetPlanTime() <= current_time) )// maybe diff<eps
{ {
vector<Pedestrian*> peds; vector<Pedestrian*> peds;
src->RemoveAgentsFromPool(peds,src->GetFrequency()); src->RemoveAgentsFromPool(peds,src->GetFrequency());
Log->Write("INFO:\tSource %d generating %d agents (%d remaining)",src->GetId(),peds.size(),src->GetPoolSize()); Log->Write("> INFO:\tSource %d generating %d agents (%d remaining)\n",src->GetId(),peds.size(),src->GetPoolSize());
//ComputeBestPositionRandom(src.get(), peds); //ComputeBestPositionRandom(src.get(), peds);
//todo: here every pedestrian needs an exitline //todo: here every pedestrian needs an exitline
...@@ -109,7 +110,7 @@ bool AgentsSourcesManager::ProcessAllSources() const ...@@ -109,7 +110,7 @@ bool AgentsSourcesManager::ProcessAllSources() const
AgentsQueueIn::Add(peds); AgentsQueueIn::Add(peds);
empty = false; empty = false;
//src->Dump(); src->Dump();
} }
if (src->GetPlanTime() > current_time) // for the case we still expect if (src->GetPlanTime() > current_time) // for the case we still expect
// agents coming // agents coming
...@@ -148,9 +149,11 @@ void AgentsSourcesManager::ComputeBestPositionCompleteRandom(AgentsSource* src, ...@@ -148,9 +149,11 @@ void AgentsSourcesManager::ComputeBestPositionCompleteRandom(AgentsSource* src,
auto dist = src->GetStartDistribution(); auto dist = src->GetStartDistribution();
auto subroom = _building->GetRoom(dist->GetRoomId())->GetSubRoom(dist->GetSubroomID()); auto subroom = _building->GetRoom(dist->GetRoomId())->GetSubRoom(dist->GetSubroomID());
vector<Point> positions = PedDistributor::PossiblePositions(*subroom); vector<Point> positions = PedDistributor::PossiblePositions(*subroom);
double seed = time(NULL);
//TODO: get the seed from the simulation //TODO: get the seed from the simulation
srand (time(NULL)); std:: cout << "seed: "<< seed << std::endl;
srand (seed);
for (auto& ped : peds) for (auto& ped : peds)
{ {
...@@ -160,6 +163,8 @@ void AgentsSourcesManager::ComputeBestPositionCompleteRandom(AgentsSource* src, ...@@ -160,6 +163,8 @@ void AgentsSourcesManager::ComputeBestPositionCompleteRandom(AgentsSource* src,
Point new_pos = positions[index]; Point new_pos = positions[index];
positions.erase(positions.begin() + index); positions.erase(positions.begin() + index);
ped->SetPos(new_pos, true); ped->SetPos(new_pos, true);
std:: cout << "pos: " << new_pos._x << new_pos._y << std::endl;
AdjustVelocityByNeighbour(ped); AdjustVelocityByNeighbour(ped);
} }
else else
...@@ -438,7 +443,7 @@ void AgentsSourcesManager::AdjustVelocityByNeighbour(Pedestrian* ped) const ...@@ -438,7 +443,7 @@ void AgentsSourcesManager::AdjustVelocityByNeighbour(Pedestrian* ped) const
} }
else else
{ {
Log->Write("ERROR:\t no route could be found for agent [%d] going to [%d]",ped->GetID(),ped->GetFinalDestination()); Log->Write(">> ERROR:\t no route could be found for agent [%d] going to [%d]",ped->GetID(),ped->GetFinalDestination());
//that will be most probably be fixed in the next computation step. //that will be most probably be fixed in the next computation step.
// so do not abort // so do not abort
} }
...@@ -485,7 +490,7 @@ void AgentsSourcesManager::AdjustVelocityUsingWeidmann(Pedestrian* ped) const ...@@ -485,7 +490,7 @@ void AgentsSourcesManager::AdjustVelocityUsingWeidmann(Pedestrian* ped) const
} }
else else
{ {
Log->Write("ERROR:\t no route could be found for agent [%d] going to [%d]",ped->GetID(),ped->GetFinalDestination()); Log->Write(">>> ERROR:\t no route could be found for agent [%d] going to [%d]",ped->GetID(),ped->GetFinalDestination());
//that will be most probably be fixed in the next computation step. //that will be most probably be fixed in the next computation step.
// so do not abort // so do not abort
} }
......
...@@ -96,6 +96,8 @@ bool ComputeBestPositionVoronoiBoost(AgentsSource* src, std::vector<Pedestrian*> ...@@ -96,6 +96,8 @@ bool ComputeBestPositionVoronoiBoost(AgentsSource* src, std::vector<Pedestrian*>
std::vector<Pedestrian*> existing_peds; std::vector<Pedestrian*> existing_peds;
std::vector<Pedestrian*> peds_without_place; std::vector<Pedestrian*> peds_without_place;
building->GetPedestrians(roomID, subroomID, existing_peds); building->GetPedestrians(roomID, subroomID, existing_peds);
for (auto pp : existing_peds)
std::cout << "existing peds: " << pp->GetID() << " in " << pp->GetPos()._x << ", " << pp->GetPos()._y << std::endl;
double radius = 0.3; //radius of a person, 0.3 is just some number(needed for the fake_peds bellow), will be changed afterwards double radius = 0.3; //radius of a person, 0.3 is just some number(needed for the fake_peds bellow), will be changed afterwards
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment