Commit 4d24cda4 authored by Ulrich Kemloh's avatar Ulrich Kemloh

bug fixes

refactoring
add statistics on door usages (simulation.PrintStatistics()
parent 4d77e686
......@@ -116,8 +116,8 @@ void IODispatcher::WriteGeometry(Building* building) {
sprintf(file_location, "\t<file location= \"%s\"/>\n", building->GetGeometryFilename().c_str());
embed_geometry.append(file_location);
embed_geometry.append("\t</geometry>\n");
Write(embed_geometry);
return;
//Write(embed_geometry);
//return;
//
string geometry;
geometry.append("\t<geometry>\n");
......
......@@ -430,3 +430,15 @@ void Simulation::Update() {
_building->UpdateGrid();
}
void Simulation::PrintStatistics() {
Log->Write("\nEXIT USAGE:");
const map<int, Transition*>& transitions = _building->GetAllTransitions();
map<int, Transition*>::const_iterator itr;
for(itr = transitions.begin(); itr != transitions.end(); ++itr){
Transition* goal = itr->second;
if(goal->IsExit()){
Log->Write("Exit ID [%d] used by [%d] pedestrians",goal->GetID(),goal->GetDoorUsage());
}
}
}
......@@ -116,6 +116,12 @@ public:
*/
void Update();
/**
* print some statistics about the simulation
*/
void PrintStatistics();
};
#endif /*SIMULATION_H_*/
......@@ -631,10 +631,19 @@ void Building::AddTransition(Transition* line) {
void Building::AddHline(Hline* line) {
if (_hLines.count(line->GetID()) != 0) {
Log->Write(
"ERROR: Duplicate index for hlines found [%d] in Routing::AddHline()",
line->GetID());
exit(EXIT_FAILURE);
// check if the lines are identical
Hline* ori= _hLines[line->GetID()];
if(ori->operator ==(*line)){
Log->Write("INFO: Skipping identical hlines with ID [%d]",line->GetID());
return;
}
else
{
Log->Write(
"ERROR: Duplicate index for hlines found [%d] in Routing::AddHline(). You have [%d] hlines",
line->GetID(), _hLines.size());
exit(EXIT_FAILURE);
}
}
_hLines[line->GetID()] = line;
}
......@@ -730,7 +739,7 @@ Crossing* Building::GetTransOrCrossByName(string caption) const {
return NULL;
}
Crossing* Building::GetTransOrCrossByID(int id) const {
Crossing* Building::GetTransOrCrossByUID(int id) const {
{
//eventually
map<int, Transition*>::const_iterator itr;
......@@ -1345,6 +1354,11 @@ void Building::DeletePedestrian(Pedestrian* ped) {
cout << "rescued agent: " << (*it)->GetID() << endl;
_allPedestians.erase(it);
}
//update the stats before deleting
Transition* trans =GetTransitionByUID(ped->GetExitIndex());
if(trans) {
trans->IncreaseDoorUsage(1);
}
delete ped;
}
......@@ -1478,28 +1492,15 @@ int Building::GetNumberOfPedestrians() const {
return sum;
}
// FIXME: you should get rid of this method
//Crossing* Building::GetGoal(int index) {
// if (_transitions.count(index) == 1) {
// return _transitions[index];
// } else if (_crossings.count(index) == 1) {
// return _crossings[index];
// }else if (_hLines.count(index) == 1) {
// exit(EXIT_FAILURE);
// //return pHlines[index];
// }else {
// if (index == -1)
// return NULL;
// else {
// char tmp[CLENGTH];
// sprintf(tmp,
// "ERROR: Wrong 'index' [%d] > [%d] in Routing::GetGoal(), counts in map= [%d]",
// index, _crossings.size(),_crossings.count(index));
// Log->Write(tmp);
// exit(EXIT_FAILURE);
// }
// }
//}
Transition* Building::GetTransitionByUID(int uid) const {
//eventually
map<int, Transition*>::const_iterator itr;
for(itr = _transitions.begin(); itr != _transitions.end(); ++itr){
if (itr->second->GetUniqueID()== uid)
return itr->second;
}
return NULL;
}
#endif // _SIMULATOR
......@@ -140,12 +140,17 @@ public:
/**
* @return a crossing or a transition matching the given id.
* @return a crossing or a transition matching the given uid.
* Return NULL if none is found
*/
Crossing* GetTransOrCrossByID(int id) const;
Crossing* GetTransOrCrossByUID(int uid) const;
/**
* @return the transition matching the uid
*/
Transition* GetTransitionByUID(int uid) const;
//TOD0: rename later to GetGoal
Goal* GetFinalGoal(int id);
......
......@@ -37,6 +37,7 @@ using namespace std;
Transition::Transition() : Crossing() {
_isOpen = true;
_doorUsage=0;
_room2 = NULL;
}
......@@ -178,3 +179,11 @@ string Transition::WriteElement() const {
geometry.append("\t\t</door>\n");
return geometry;
}
void Transition::IncreaseDoorUsage(int number) {
_doorUsage+=number;
}
int Transition::GetDoorUsage() const {
return _doorUsage;
}
......@@ -38,6 +38,8 @@ private:
Room* _room2;
bool _isOpen;
std::string _type;
// number of agents that passed that exit
int _doorUsage;
public:
......@@ -66,6 +68,16 @@ public:
*/
void SetRoom2(Room* ID);
/**
* Increment the number of persons that used that exit
* @param number
*/
void IncreaseDoorUsage(int number);
/**
* @return the number of pedestrians that used that exit.
*/
int GetDoorUsage() const;
/**
* Set/Get the type of the transition
......
......@@ -10,6 +10,7 @@
<!-- traectories file and format -->
<trajectories format="xml-plain" embed_mesh="false" fps="8">
<file location="trajectorie.xml" />
<!-- <socket hostname="127.0.0.1" port="8989"/> -->
</trajectories>
<!-- where to store the logs -->
<!--logfile>log</logfile-->
......@@ -122,10 +123,8 @@
<agents_distribution>
<group group_id="1" room_id="6" subroom_id="7" number="8" goal_id="-1" router_id="2" route_id=""/>
<group group_id="1" room_id="6" subroom_id="9" number="20" goal_id="" router_id="2" route_id=""/>
<!--
<group group_id="1" room_id="0" subroom_id="1" number="10" goal_id="0" router_id="1" route_id=""/>
......@@ -244,7 +243,7 @@
<parameters>
<solver>euler</solver>
<stepsize>0.01</stepsize>
<exitCrossingStrategy>3</exitCrossingStrategy>
<exitCrossingStrategy>4</exitCrossingStrategy>
<linkedcells enabled="true" cell_size="2.2" />
<v0 mu="1.24" sigma="0.001" />
<bmax mu="0.25" sigma="0.001" />
......@@ -260,15 +259,15 @@
</operational_models>
<route_choice_models>
<router router_id="1" description="global_safest">
<routerq router_id="1" description="global_safest">
<parameters>
<navigation_lines file="routing.xml" />
<navigation_lines file="routing-mall.xml" />
</parameters>
</router>
</routerq>
<router router_id="2" description="global_shortest">
<router router_id="2" description="global_safest">
<parameters>
<navigation_lines file="routing.xml" />
<navigation_lines file="routing-mall.xml" />
</parameters>
</router>
......
<?xml version="1.0" encoding="UTF-8" ?>
<JuPedSim project="JPS-Project" version="0.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ini.xsd">
<!-- seed used for initialising random generator -->
<seed>12542</seed>
<!-- geometry file -->
<geometry>geometry.xml</geometry>
<max_sim_time>900</max_sim_time>
<!-- traectories file and format -->
<trajectories format="xml-plain" embed_mesh="false" fps="16">
<file location="trajectorie.xml" />
</trajectories>
<!-- where to store the logs -->
<!--logfile>log</logfile-->
<!-- traffic information: e.g closed doors or smoked rooms -->
<traffic_constraints>
<!-- <\!-- room states are: good or smoked -\-> -->
<rooms>
<room room_id="0" state="good" />
<room room_id="1" state="good" />
</rooms>
<!-- doors states are: close or open -->
<doors>
<door trans_id="0" caption="" state="open" />
<door trans_id="1" caption="" state="close" />
<door trans_id="2" caption="" state="close" />
<door trans_id="3" caption="" state="open" />
<door trans_id="4" caption="" state="close" />
<door trans_id="5" caption="" state="close" />
<door trans_id="6" caption="" state="close" />
<door trans_id="7" caption="" state="close" />
<door trans_id="8" caption="" state="close" />
<door trans_id="9" caption="" state="close" />
<door trans_id="10" caption="" state="close" />
<door trans_id="11" caption="" state="close" />
<door trans_id="12" caption="" state="close" />
<door trans_id="13" caption="" state="close" />
<door trans_id="14" caption="" state="close" />
<door trans_id="15" caption="" state="close" />
<door trans_id="16" caption="" state="close" />
<door trans_id="17" caption="" state="close" />
<door trans_id="18" caption="" state="close" />
<door trans_id="19" caption="" state="close" />
</doors>
</traffic_constraints>
<routing>
<goals>
<goal id="0" final="true" caption="goal 0">
<polygon>
<vertex px="5.0" py="10.0" />
<vertex px="7.0" py="10.0" />
<vertex px="7.0" py="12.0" />
<vertex px="5.0" py="12.0" />
<vertex px="5.0" py="10.0" />
</polygon>
</goal>
<goal id="1" final="true" caption="goal 1">
<polygon>
<vertex px="10.0" py="31.0" />
<vertex px="12.0" py="31.0" />
<vertex px="12.0" py="33.0" />
<vertex px="10.0" py="33.0" />
<vertex px="10.0" py="31.0" />
</polygon>
</goal>
<goal id="2" final="true" caption="goal 2">
<polygon>
<vertex px="26.0" py="31.0" />
<vertex px="28.0" py="31.0" />
<vertex px="28.0" py="33.0" />
<vertex px="26.0" py="33.0" />
<vertex px="26.0" py="31.0" />
</polygon>
</goal>
<goal id="3" final="true" caption="goal 3">
<polygon>
<vertex px="31.0" py="10.0" />
<vertex px="33.0" py="10.0" />
<vertex px="33.0" py="12.0" />
<vertex px="31.0" py="12.0" />
<vertex px="31.0" py="10.0" />
</polygon>
</goal>
</goals>
</routing>
<!--persons information and distribution -->
<agents>
<agents_distribution>
<group group_id="0" room_id="0" subroom_id="11" number="30" goal_id="" router_id="1" route_id=""/>
<!--<group group_id="0" room_id="1" subroom_id="3" number="15" goal_id="1" router_id="1" route_id=""/>
<group group_id="1" room_id="1" subroom_id="7" number="15" goal_id="1" router_id="1" route_id=""/>
<group group_id="2" room_id="1" subroom_id="2" number="50" goal_id="1" router_id="1" route_id=""/>
<group group_id="3" room_id="1" subroom_id="6" number="50" goal_id="1" router_id="1" route_id=""/>
<group group_id="4" room_id="1" subroom_id="0" number="15" goal_id="2" router_id="1" route_id=""/>
<group group_id="5" room_id="1" subroom_id="4" number="15" goal_id="2" router_id="1" route_id=""/>
<group group_id="6" room_id="1" subroom_id="1" number="50" goal_id="2" router_id="1" route_id=""/>
<group group_id="7" room_id="1" subroom_id="5" number="50" goal_id="2" router_id="1" route_id=""/>-->
</agents_distribution>
<!-- frequency in persons/minute -->
<agents_sources/>
</agents>
<!-- These parameters may be overwritten -->
<operational_models>
<model id="1" description="gcfm">
<parameters>
<solver>euler</solver>
<stepsize>0.01</stepsize>
<exitCrossingStrategy>3</exitCrossingStrategy>
<linkedcells enabled="true" cell_size="2.2" />
<v0 mu="1.24" sigma="0.001" />
<bmax mu="0.25" sigma="0.001" />
<bmin mu="0.20" sigma="0.001" />
<amin mu="0.18" sigma="0.001" />
<tau mu="0.5" sigma="0.001" />
<atau mu="0.5" sigma="0.001" />
<force_ped nu="0.3" dist_max="3" disteff_max="2" interpolation_width="0.1" />
<force_wall nu="0.2" dist_max="3" disteff_max="2" interpolation_width="0.1" />
</parameters>
</model>
</operational_models>
<route_choice_models>
<router router_id="1" description="global_safest">
<parameters>
<navigation_lines file="routing.xml" />
</parameters>
</router>
</route_choice_models>
</JuPedSim>
<JuPedSim project="JPS-Project" version="0.5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ini.xsd">
<!-- seed used for initialising random generator -->
<seed>12542</seed>
<!-- geometry file -->
<geometry>geometry.xml</geometry>
<max_sim_time>900</max_sim_time>
<!-- traectories file and format -->
<trajectories format="xml-plain" embed_mesh="false" fps="16">
<file location="trajectorie.xml" />
</trajectories>
<!-- where to store the logs -->
<!--logfile>log</logfile -->
<!-- traffic information: e.g closed doors or smoked rooms -->
<traffic_constraints>
<!-- <\!-- room states are: good or smoked -\-> -->
<rooms>
<room room_id="0" state="good" />
<room room_id="1" state="good" />
</rooms>
<!-- doors states are: close or open -->
<doors>
<door trans_id="0" caption="" state="open" />
<door trans_id="1" caption="" state="close" />
<door trans_id="2" caption="" state="close" />
<door trans_id="3" caption="" state="open" />
<door trans_id="4" caption="" state="close" />
<door trans_id="5" caption="" state="close" />
<door trans_id="6" caption="" state="close" />
<door trans_id="7" caption="" state="close" />
<door trans_id="8" caption="" state="close" />
<door trans_id="9" caption="" state="close" />
<door trans_id="10" caption="" state="close" />
<door trans_id="11" caption="" state="close" />
<door trans_id="12" caption="" state="close" />
<door trans_id="13" caption="" state="close" />
<door trans_id="14" caption="" state="close" />
<door trans_id="15" caption="" state="close" />
<door trans_id="16" caption="" state="close" />
<door trans_id="17" caption="" state="close" />
<door trans_id="18" caption="" state="close" />
<door trans_id="19" caption="" state="close" />
</doors>
</traffic_constraints>
<routing>
<goals>
<goal id="0" final="true" caption="goal 0">
<polygon>
<vertex px="5.0" py="10.0" />
<vertex px="7.0" py="10.0" />
<vertex px="7.0" py="12.0" />
<vertex px="5.0" py="12.0" />
<vertex px="5.0" py="10.0" />
</polygon>
</goal>
<goal id="1" final="true" caption="goal 1">
<polygon>
<vertex px="10.0" py="31.0" />
<vertex px="12.0" py="31.0" />
<vertex px="12.0" py="33.0" />
<vertex px="10.0" py="33.0" />
<vertex px="10.0" py="31.0" />
</polygon>
</goal>
<goal id="2" final="true" caption="goal 2">
<polygon>
<vertex px="26.0" py="31.0" />
<vertex px="28.0" py="31.0" />
<vertex px="28.0" py="33.0" />
<vertex px="26.0" py="33.0" />
<vertex px="26.0" py="31.0" />
</polygon>
</goal>
<goal id="3" final="true" caption="goal 3">
<polygon>
<vertex px="31.0" py="10.0" />
<vertex px="33.0" py="10.0" />
<vertex px="33.0" py="12.0" />
<vertex px="31.0" py="12.0" />
<vertex px="31.0" py="10.0" />
</polygon>
</goal>
</goals>
</routing>
<!--persons information and distribution -->
<agents>
<agents_distribution>
<group group_id="0" room_id="0" subroom_id="11" number="30"
goal_id="" router_id="0" route_id="" />
<!--<group group_id="0" room_id="1" subroom_id="3" number="15" goal_id="1"
router_id="1" route_id=""/> <group group_id="1" room_id="1" subroom_id="7"
number="15" goal_id="1" router_id="1" route_id=""/> <group group_id="2" room_id="1"
subroom_id="2" number="50" goal_id="1" router_id="1" route_id=""/> <group
group_id="3" room_id="1" subroom_id="6" number="50" goal_id="1" router_id="1"
route_id=""/> <group group_id="4" room_id="1" subroom_id="0" number="15"
goal_id="2" router_id="1" route_id=""/> <group group_id="5" room_id="1" subroom_id="4"
number="15" goal_id="2" router_id="1" route_id=""/> <group group_id="6" room_id="1"
subroom_id="1" number="50" goal_id="2" router_id="1" route_id=""/> <group
group_id="7" room_id="1" subroom_id="5" number="50" goal_id="2" router_id="1"
route_id=""/> -->
</agents_distribution>
<!-- frequency in persons/minute -->
<agents_sources />
</agents>
<!-- These parameters may be overwritten -->
<operational_models>
<model id="1" description="gcfm">
<parameters>
<solver>euler</solver>
<stepsize>0.01</stepsize>
<exitCrossingStrategy>3</exitCrossingStrategy>
<linkedcells enabled="true" cell_size="2.2" />
<v0 mu="1.24" sigma="0.001" />
<bmax mu="0.25" sigma="0.001" />
<bmin mu="0.20" sigma="0.001" />
<amin mu="0.18" sigma="0.001" />
<tau mu="0.5" sigma="0.001" />
<atau mu="0.5" sigma="0.001" />
<force_ped nu="0.3" dist_max="3" disteff_max="2"
interpolation_width="0.1" />
<force_wall nu="0.2" dist_max="3" disteff_max="2"
interpolation_width="0.1" />
</parameters>
</model>
</operational_models>
<route_choice_models>
<router router_id="0" description="global_shortest">
<parameters>
<navigation_lines file="routing.xml" />
</parameters>
</router>
<router router_id="1" description="global_safest">
<parameters>
<navigation_lines file="routing.xml" />
</parameters>
</router>
</route_choice_models>
</JuPedSim>
......@@ -156,6 +156,10 @@
<Hline id="29" room_id="0" subroom_id="1">
<vertex px="18.36" py="71.28"/>
<vertex px="23.22" py="77.22"/>
</Hline>
<Hline id="30" room_id="6" subroom_id="2">
<vertex px="56.70" py="64.80"/>
<vertex px="50.0" py="56.7"/>
</Hline>
......
......@@ -83,7 +83,9 @@ int main(int argc, char **argv) {
Log->Write("\nExec Time [s] : %.2f", execTime);
Log->Write("Evac Time [s] : %d", evacTime);
Log->Write("Real Time Factor : %.2f X\n", evacTime / execTime);
Log->Write("Real Time Factor : %.2f X", evacTime / execTime);
//sim.PrintStatistics();
if (NULL == dynamic_cast<STDIOHandler*>(Log)){
printf("\nExec Time [s] : %.2f\n", execTime);
......
......@@ -228,28 +228,28 @@ inline Point GCFMModel::ForceRepRoom(Pedestrian* ped, SubRoom* subroom) const {
}
}
// //eventually crossings
// const vector<Crossing*>& crossings = subroom->GetAllCrossings();
// for (unsigned int i = 0; i < crossings.size(); i++) {
// Crossing* goal=crossings[i];
// int uid1= goal->GetUniqueID();
// int uid2=ped->GetExitLine()->GetUniqueID();
// // ignore my transition
// if (uid1 != uid2) {
// f = f + ForceRepWall(ped,*((Wall*)goal));
// }
// }
//
// and finally the closed doors
//eventually crossings
const vector<Crossing*>& crossings = subroom->GetAllCrossings();
for (unsigned int i = 0; i < crossings.size(); i++) {
//Crossing* goal=crossings[i];
//int uid1= goal->GetUniqueID();
//int uid2=ped->GetExitIndex();
// ignore my transition
//if (uid1 != uid2) {
// f = f + ForceRepWall(ped,*((Wall*)goal));
//}
}
// and finally the closed doors or doors that are not my destination
const vector<Transition*>& transitions = subroom->GetAllTransitions();
for (unsigned int i = 0; i < transitions.size(); i++) {
Transition* goal=transitions[i];
//int uid1= goal->GetUniqueID();
//int uid2=ped->GetExitLine()->GetUniqueID();
int uid1= goal->GetUniqueID();
int uid2=ped->GetExitIndex();
// ignore my transition consider closed doors
//closed doors are considered as wall
if( goal->IsOpen()==false ) {
if((uid1 != uid2) || (goal->IsOpen()==false )) {
f = f + ForceRepWall(ped,*((Wall*)goal));