Commit f9940660 authored by Andrijana Brkic's avatar Andrijana Brkic

workaround for the initial number of agents in LCgrid.cpp

parent 69eca9a9
......@@ -40,7 +40,7 @@
using namespace std;
#define MAX_AGENT_COUNT 0 // 1000000
#define MAX_AGENT_COUNT 1000 // 1000000
LCGrid::LCGrid(double boundaries[4], double cellsize, int nPeds)
{
......
......@@ -79,7 +79,7 @@ void AgentsSourcesManager::Run()
//it might be better to use a timer
_isCompleted = false;
bool finished = false;
long updateFrequency = 3; // 1 = second
long updateFrequency = 2; // 1 = second
do
{
int current_time = Pedestrian::GetGlobalTime();
......@@ -112,6 +112,7 @@ bool AgentsSourcesManager::ProcessAllSources() const
//todo: compute the optimal position for insertion using voronoi
if( !ComputeBestPositionVoronoiBoost(src.get(), peds, _building) )
Log->Write("INFO:\t there was no place for some pedestrians");
//ComputeBestPositionTotalRandom(src.get(), peds );
//ComputeBestPositionDummy( src.get(), peds );
/*for (auto&& ped : peds)
{
......@@ -147,6 +148,35 @@ void AgentsSourcesManager::ComputeBestPositionDummy(AgentsSource* src,
ped->SetV(v);
}
}
void AgentsSourcesManager::ComputeBestPositionCompleteRandom(AgentsSource* src,
vector<Pedestrian*>& peds)const
{
auto dist = src->GetStartDistribution();
auto subroom = _building->GetRoom(dist->GetRoomId())->GetSubRoom(dist->GetSubroomID());
vector<Point> positions = PedDistributor::PossiblePositions(*subroom);
srand (time(NULL));
for (auto& ped : peds)
{
if( positions.size() )
{
int index = rand()%positions.size();
Point new_pos = positions[index];
positions.erase(positions.begin() + index);
ped->SetPos(new_pos, true);
AdjustVelocityByNeighbour(ped);
}
else
{
Log->Write("\t No place for a pedestrian");
break;
}
}
}
/*
void AgentsSourcesManager::ComputeBestPositionVoronoi(AgentsSource* src,
Pedestrian* agent) const
......
......@@ -127,6 +127,12 @@ private:
void ComputeBestPositionDummy(AgentsSource* src, std::vector<Pedestrian*>& peds) const;
/**
* Position incoming pedestrians completely random
*/
void ComputeBestPositionCompleteRandom(AgentsSource* src, std::vector<Pedestrian*>& peds) const;
/**
* Position incoming pedestrians randomly
* @param src
......
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