Commit 070ceaee authored by Andrijana Brkic's avatar Andrijana Brkic

changes in SortPositionByDensity-fix needed and voronoi-boost changes

parent 548a76e5
......@@ -5,12 +5,12 @@
<!-- seed used for initialising random generator -->
<seed>12542</seed>
<!-- geometry file -->
<geometry>experiment_traj.xml</geometry>
<geometry>experiment_geo.xml</geometry>
<max_sim_time>4000</max_sim_time>
<!-- trajectories file and format -->
<trajectories format="xml-plain" fps="16">
<file location="../../../../Documents/Documentation/Experiment/trajectories2/traj_10.xml" />
<file location="experiment_traj.xml" />
<socket_ hostname="127.0.0.1" port="8989" />
</trajectories>
......
......@@ -19,13 +19,13 @@
<!--<hybrid_simulation server="zam597" port="9999" />-->
<!-- where to store the logs -->
<!--<logfile>outputfiles/log.txt</logfile> -->
<!--<logfile>outputfiles/log.txt</logfile>-->
<!-- traffic information: e.g closed doors or smoked rooms -->
<traffic_constraints>
<!-- doors states are: close or open -->
<doors>
<door trans_id="5" caption="exit" state="closed" />
<door trans_id="5" caption="exit" state="close" />
</doors>
</traffic_constraints>
......@@ -85,7 +85,7 @@
</agents_distribution>
<agents_sources><!-- frequency in persons/seconds -->
<source id="1" frequency="7" agents_max="100" group_id="6" caption="source 1" />
<source id="1" frequency="6" agents_max="500" group_id="6" caption="source 1" />
<source_ id="2" frequency="10" agents_max="50" group_id="2" caption="source 2" />
<source_ id="3" frequency="10" agents_max="50" group_id="3" caption="source 3" />
<source_ id="4" frequency="10" agents_max="50" group_id="4" caption="source 4" />
......
This diff is collapsed.
......@@ -310,14 +310,18 @@ void AgentsSourcesManager::ComputeBestPositionRandom(AgentsSource* src,
double bounds[4] = { 0, 0, 0, 0 };
dist->Getbounds(bounds);
std::vector<Pedestrian*> peds_without_place;
vector<Point> extra_positions;
for (auto& ped : peds)
std::vector<Pedestrian*>::iterator iter_ped;
for (iter_ped = peds.begin(); iter_ped != peds.end(); )
{
//need to be called at each iteration
SortPositionByDensity(positions, extra_positions);
int index = -1;
double radius = ( (*iter_ped)->GetEllipse() ).GetBmax() ;
//in the case a range was specified
//just take the first element
......@@ -325,12 +329,32 @@ void AgentsSourcesManager::ComputeBestPositionRandom(AgentsSource* src,
{
Point pos = positions[a];
//cout<<"checking: "<<pos.toString()<<endl;
// for positions inside bounds, check it there is enough space
if ((bounds[0] <= pos._x) && (pos._x <= bounds[1])
&& (bounds[2] <= pos._y) && (pos._y < bounds[3]))
{
bool enough_space = true;
//checking enough space!!
vector<Pedestrian*> neighbours;
_building->GetGrid()->GetNeighbourhood(pos,neighbours);
for (const auto& ngh: neighbours)
if( (ngh->GetPos() - pos).NormSquare() < 4*radius*radius )
{
enough_space = false;
break;
}
if( enough_space )
{
index = a;
break;
}
}
}
if (index == -1)
{
......@@ -341,22 +365,33 @@ void AgentsSourcesManager::ComputeBestPositionRandom(AgentsSource* src,
bounds[0], bounds[1], bounds[2], bounds[3]);
Log->Write(" \t Specifying a subroom_id might help");
Log->Write(" \t %d positions were available",positions.size());
exit(EXIT_FAILURE);
//exit(EXIT_FAILURE);
}
//dump the pedestrian, move iterator
peds_without_place.push_back(*iter_ped);
iter_ped=peds.erase(iter_ped);
}
else
else //we found a position with enough space
{
const Point& pos = positions[index];
extra_positions.push_back(pos);
ped->SetPos(pos, true); //true for the initial position
(*iter_ped)->SetPos(pos, true); //true for the initial position
positions.erase(positions.begin() + index);
//at this point we have a position
//so we can adjust the velocity
//AdjustVelocityUsingWeidmann(ped);
AdjustVelocityByNeighbour(ped);
AdjustVelocityByNeighbour( (*iter_ped) );
//move iterator
iter_ped++;
}
//return the pedestrians without place
}
if(peds_without_place.size()>0)
src->AddAgentsToPool(peds_without_place);
}
void AgentsSourcesManager::AdjustVelocityByNeighbour(Pedestrian* ped) const
......@@ -477,7 +512,8 @@ void AgentsSourcesManager::SortPositionByDensity(std::vector<Point>& positions,
for(const auto& p: neighbours)
{
if( (pt-p->GetPos()).NormSquare()<=radius_square)
//FIXME: p can be null, if deleted in the main simulation thread.
if( p && (pt-p->GetPos()).NormSquare()<=radius_square)
density+=1.0;
}
......
......@@ -207,7 +207,7 @@ bool ComputeBestPositionVoronoiBoost(AgentsSource* src, std::vector<Pedestrian*>
voronoi_diagram<double>::const_vertex_iterator chosen_it = vd.vertices().begin();
double dis = 0;
VoronoiBestVertexMax(discrete_positions, vd, subroom, factor, chosen_it, dis, radius, goal_vector, *iter_ped );
VoronoiBestVertexRandMax(discrete_positions, vd, subroom, factor, chosen_it, dis, radius );
if( dis > 4*radius*factor*radius*factor)// be careful with the factor!! radius*factor, 2,3,4?
{
......@@ -325,13 +325,9 @@ void VoronoiBestVertexMax (const std::vector<Point>& discrete_positions, const v
//constructing the checking line
//ped->SetPos(vert_pos);
/*
Point p2 = (ped->GetExitLine()->ShortestPoint(vert_pos)-vert_pos).Normalized(); //problem: ped does not have a position
p2 = p2 + p2; //looking 2m in front
//Point p2 = nav_line->GetPoint1() - nav_line->GetPoint2() ;
//p2 = p2/ p2.Norm();
//p2 = p2+p2;
//p2 = nav_line->GetPoint1() + p2;
Line check_line(vert_pos, vert_pos + p2); //this is the first 2m of exit line
do
......@@ -351,7 +347,7 @@ void VoronoiBestVertexMax (const std::vector<Point>& discrete_positions, const v
p = discrete_positions[index]/factor;
} while( edge != vertex.incident_edge() );
*/
if(score > max_score)
{
max_score =score;
......
......@@ -28,6 +28,8 @@ class Building;
class Pedestrian;
class Point;
// TODO: bool IsSpace(SubRoom* subroom, Point& pt,Point& v1);
/**
* Calculates if a point (which is inside the subroom) is far enough from the walls, transitions, crossings ( > radius of a person)
* @param subroom
......
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