Commit 9850645b authored by qiancheng xu's avatar qiancheng xu

Moving pedestrians in clogging instead of deleting

parent bd61d84b
Pipeline #22338 passed with stages
in 9 minutes and 24 seconds
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<geometry version="0.8" caption="Projectname" gridSizeX="20.000000"
gridSizeY="20.000000" unit="m"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_geoemtry.xsd ">
<rooms>
<room id="0" closed="0" zpos="0.0">
<subroom id="0" closed="0" class="subroom">
<polygon caption="SourceLeft">
<vertex px="0.0" py="8.0"/>
<vertex px="-8.0" py="8.0"/>
</polygon>
<polygon caption="SourceRight">
<vertex px="-8.0" py="0.0"/>
<vertex px="0.0" py="0.0"/>
</polygon>
</subroom>
</room>
<room id="1" closed="0" zpos="0.0">
<subroom id="0" closed="0" class="subroom">
<polygon caption="MainRoomLeftWall">
<vertex px="0.0" py="8.0"/>
<vertex px="10.0" py="8.0"/>
<vertex px="10.0" py="4.5"/>
</polygon>
<polygon caption="MainRoomRightWall">
<vertex px="0.0" py="0.0"/>
<vertex px="10.0" py="0.0"/>
<vertex px="10.0" py="3.5"/>
</polygon>
</subroom>
</room>
<room id="2" closed="0" zpos="0.0">
<subroom id="0" closed="0" class="subroom">
<polygon caption="CorridorLeftWall">
<vertex px="10.0" py="3.5"/>
<vertex px="12.0" py="3.5"/>
</polygon>
<polygon capton="CorridorRightWall">
<vertex px="10.0" py="4.5"/>
<vertex px="12.0" py="4.5"/>
</polygon>
</subroom>
</room>
<room id="3" closed="0" zpos="0.0">
<subroom id="0" closed="0" class="subroom">
<polygon caption="Waiting_area">
<vertex px="-8.0" py="8.0"/>
<vertex px="-26.0" py="8.0"/>
<vertex px="-26.0" py="0.0"/>
<vertex px="-8.0" py="0.0"/>
</polygon>
</subroom>
</room>
</rooms>
<transitions>
<transition id="0" type="emergency"
room1_id="0" subroom1_id="0" room2_id="1"
subroom2_id="0">
<vertex px="0" py="0"/>
<vertex px="0" py="8"/>
</transition>
<transition id="1" type="emergency"
room1_id="1" subroom1_id="0" room2_id="2"
subroom2_id="0">
<vertex px="10" py="3.5"/>
<vertex px="10" py="4.5"/>
</transition>
<transition id="2" type="emergency"
room1_id="2" subroom1_id="0" room2_id="-1"
subroom2_id="-1">
<vertex px="12" py="3.5"/>
<vertex px="12" py="4.5"/>
</transition>
<transition id="3" type="emergency"
room1_id="0" subroom1_id="0" room2_id="3"
subroom2_id="0">
<vertex px="-8" py="0"/>
<vertex px="-8" py="8"/>
</transition>
</transitions>
</geometry>
......@@ -4,13 +4,13 @@
<num_threads>8</num_threads>
<max_sim_time unit="sec">500</max_sim_time>
<logfile>log.txt</logfile>
<geometry>clogging_geo.xml</geometry>
<geometry>clogging_geo_nod.xml</geometry>
<trajectories embed_mesh="false" format="xml-plain" fps="20">
<file location="clogging_traj.xml" />
</trajectories>
<show_statistics>false</show_statistics>
<show_statistics>true</show_statistics>
<agents operational_model_id="7">
<agents_distribution>
......@@ -42,10 +42,10 @@
<force_wall D="0.05" a="6" />
<time_parameters Td="0.3" Ts="0.3" />
<update_method parallel="1"/> <!-- Update method is parallel when parallel=1, while unparallel when parallel=0 -->
<waiting_time Tw="0"/> <!-- Deleting pedestrian Tw seconds after the clogging -->
<clogging_area size="0.6" /> <!-- Only deleting pedestrian when the distance between clogging to exit is smaller than the size-->
<waiting_time Tw="1"/> <!-- Deleting pedestrian Tw seconds after the clogging -->
<clogging_area size="1" /> <!-- Only deleting pedestrian when the distance between clogging to exit is smaller than the size-->
<model_submodel direction="1" speed="1"/> <!-- When direction=1 means using direction part, when speed=1 means using speed part -->
<GCVM using="0"/> <!-- When using=1 menas we using GCVM in the simulation -->
<GCVM using="1"/> <!-- When using=1 menas we using GCVM in the simulation -->
</model_parameters>
<agent_parameters agent_parameter_id="1">
<v0 mu="1.34" sigma="0.26" />
......
......@@ -448,7 +448,7 @@ void SimplestModel::ComputeNextTimeStep(double current, double deltaT, Building*
if (converse != relations.end())
{
//using this when delete pedestrian
//*converse = ID_pair(first_ID, second_ID);
*converse = ID_pair(first_ID, second_ID);
}
for (int p = start; p <= end; ++p) {
Pedestrian* ped = allPeds[p];
......@@ -460,10 +460,37 @@ void SimplestModel::ComputeNextTimeStep(double current, double deltaT, Building*
}
else {
ped->SetInCloggingTime(0);
clogging_times++;
std::ofstream ofile;
string ProjectFileName = building->GetProjectFilename();
int start= ProjectFileName.find_last_of("\\");
start = start == -1 ? ProjectFileName.find_last_of("/") : start;
int end = ProjectFileName.find(".xml");
string InifileName = ProjectFileName.substr(start+1,end-start-1);
if (clogging_times == 1) {
ofile.open(building->GetProjectRootDir() + "CloggingLog_"+InifileName+".txt", std::ofstream::trunc);
ofile <<"#inifile: "<< building->GetProjectFilename()<<"\n";
ofile << "#Commit date: " << GIT_COMMIT_DATE << "\n";
ofile << "#Branch: " << GIT_BRANCH << "\n";
ofile << "#Timestep: " << deltaT << " (s)\n";
ofile << "#Waiting time: " << _WaitingTime << " (s)\n";
ofile << "#Parallel: " << _Parallel << " (1:parallel,0:unparallel)\n";
ofile << "#Direction: " << _SubmodelDirection << " (1:Using direction submodel,0:Not using direction submodel)\n";
ofile << "#Speed: " << _SubmodelSpeed << " (1:Using speed submodel,0:Not using speed submodel)\n";
ofile << "#GCVM: " << _GCVMUsing << " (1:Using GCVM instead of simplest model,0:Using simplest model)\n";
ofile << "#ID\ttime(s)\tamount\tposition_x\tpostion_y\n";
}
else {
ofile.open(building->GetProjectRootDir() + "CloggingLog_" + InifileName+".txt", std::ofstream::app);
}
//ofile << "\nDELETE: \tPed " << ped->GetID() << " is deleted at time " << current << " to slove clogging, clogging times: " << clogging_times << " !\n";
ofile << ped->GetID() << "\t" << current << "\t" << clogging_times << "\t" << ped->GetPos()._x << "\t" << ped->GetPos()._y << "\n";
ofile.close();
/*
// Todo: Cooperation-----------------------------------------------------------
double velocity_x=ped->GetEllipse().GetCosPhi();
double velocity_y=ped->GetEllipse().GetSinPhi();
Point position=ped->GetPos();
int random = rand() % 10000;
if (random<2500)
{
......@@ -489,36 +516,16 @@ void SimplestModel::ComputeNextTimeStep(double current, double deltaT, Building*
Point velocity(velocity_y,velocity_x);
ped->SetPos(position+velocity*-1.34*deltaT);
}
//---------------------------------------------------------------------------
*/
// Clogging experiment
// Delete
//pedsToRemove.push_back(ped);
clogging_times++;
std::ofstream ofile;
string ProjectFileName = building->GetProjectFilename();
int start= ProjectFileName.find_last_of("\\");
start = start == -1 ? ProjectFileName.find_last_of("/") : start;
int end = ProjectFileName.find(".xml");
string InifileName = ProjectFileName.substr(start+1,end-start-1);
if (clogging_times == 1) {
ofile.open(building->GetProjectRootDir() + "CloggingLog_"+InifileName+".txt", std::ofstream::trunc);
ofile <<"#inifile: "<< building->GetProjectFilename()<<"\n";
ofile << "#Commit date: " << GIT_COMMIT_DATE << "\n";
ofile << "#Branch: " << GIT_BRANCH << "\n";
ofile << "#Timestep: " << deltaT << " (s)\n";
ofile << "#Waiting time: " << _WaitingTime << " (s)\n";
ofile << "#Parallel: " << _Parallel << " (1:parallel,0:unparallel)\n";
ofile << "#Direction: " << _SubmodelDirection << " (1:Using direction submodel,0:Not using direction submodel)\n";
ofile << "#Speed: " << _SubmodelSpeed << " (1:Using speed submodel,0:Not using speed submodel)\n";
ofile << "#GCVM: " << _GCVMUsing << " (1:Using GCVM instead of simplest model,0:Using simplest model)\n";
ofile << "#ID\ttime(s)\tamount\tposition_x\tpostion_y\n";
}
else {
ofile.open(building->GetProjectRootDir() + "CloggingLog_" + InifileName+".txt", std::ofstream::app);
}
//ofile << "\nDELETE: \tPed " << ped->GetID() << " is deleted at time " << current << " to slove clogging, clogging times: " << clogging_times << " !\n";
ofile << ped->GetID() << "\t" << current << "\t" << clogging_times << "\t" << ped->GetPos()._x << "\t" << ped->GetPos()._y << "\n";
ofile.close();
// Moving to waiting area
Point position=ped->GetPos();
Point position_w(position._x-18,position._y);
ped->SetPos(position_w,true);
ped->SetmoveManually(true);
//Log->Write("\nDELETE: \tPed (ID %d) is deleted to slove clogging, Clogging times = %d !", ped->GetID(), clogging_times);
break;
......
......@@ -1226,6 +1226,28 @@ bool Pedestrian::Relocate(std::function<void(const Pedestrian&)> flowupdater) {
{
auto& room = it_room.second;
auto subrooms = room->GetAllSubRooms();
// This part is used for move pedestrian in geometry manually
if (GetmoveManually()==true){
auto sub_in =
std::find_if(subrooms.begin(), subrooms.end(), [&] (std::pair<int, std::shared_ptr<SubRoom>> iterator) {
return (iterator.second->IsInSubRoom(this));
});
if (sub_in!=subrooms.end()){
ClearMentalMap(); // reset the destination
SetRoomID(room->GetID(), room->GetCaption());
SetSubRoomID(sub_in->second->GetSubRoomID());
SetSubRoomUID(sub_in->second->GetUID());
_router->FindExit(this);
status=true;
SetmoveManually(false);
break;
}else{
continue;
}
}
map<int, std::shared_ptr<SubRoom> >::iterator sub =
std::find_if(subrooms.begin(), subrooms.end(), [&] (std::pair<int, std::shared_ptr<SubRoom>> iterator) {
return ((iterator.second->IsDirectlyConnectedWith(allRooms[_roomID]->GetSubRoom(_subRoomID))) && iterator.second->IsInSubRoom(this));
......@@ -1279,3 +1301,11 @@ void Pedestrian::SetInCloggingTime(double t) {
double Pedestrian::GetInCloggingTime() const {
return _InCloggingTime;
}
void Pedestrian::SetmoveManually(bool m){
_moveManually = m;
}
bool Pedestrian::GetmoveManually() const{
return _moveManually;
}
......@@ -154,7 +154,9 @@ private:
int _lastGoalID = -1;
bool _insideGoal =false;
double _InCloggingTime = 0;
double _InCloggingTime = 0;
bool _moveManually = false;
public:
......@@ -510,9 +512,13 @@ public:
bool IsInsideGoal() const;
void SetInCloggingTime(double t);
void SetInCloggingTime(double t);
double GetInCloggingTime() const;
double GetInCloggingTime() const;
void SetmoveManually(bool m);
bool GetmoveManually() const;
};
#endif /* _PEDESTRIAN_H */
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