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>
......
This diff is collapsed.
......@@ -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));
}
}
......
......@@ -576,6 +576,7 @@ void Pedestrian::Dump(int ID, int pa) {
break;
}
fflush(stdout);
getc(stdin);
}
......
......@@ -262,12 +262,20 @@ void AccessPoint::Dump(){
cout<<endl<<endl;
cout<<" transit to final goals:"<<endl;
for(std::map<int, int>::iterator p = _mapDestToAp.begin(); p != _mapDestToAp.end(); p++) {
cout<<"\t ---> [ "<<p->first<<" via " << p->second<<" ]";
}
if(_mapDestToAp.size()==0){
cout<<"\t ---> [ Nothing ]";
}
// for(std::map<int, int>::iterator p = _navigationGraphTo.begin(); p != _navigationGraphTo.end(); p++) {
// cout<<"\t ---> [ "<<p->first<<" via " << p->second<<" ]";
// }
// if(_navigationGraphTo.size()==0){
// cout<<"\t ---> [ Nothing ]";
// }
// cout<<" transit to final goals:"<<endl;
// for(std::map<int, int>::iterator p = _mapDestToAp.begin(); p != _mapDestToAp.end(); p++) {
// cout<<"\t ---> [ "<<p->first<<" via " << p->second<<" ]";
// }
// if(_mapDestToAp.size()==0){
// cout<<"\t ---> [ Nothing ]";
// }
cout<<endl<<endl;
cout<<" connected to aps : " ;
......
......@@ -40,7 +40,7 @@
#include <iomanip>
//penalty factors for distances outdoor
#define PENALTY_FACTOR 30
#define PENALTY_FACTOR 1
using namespace std;
......@@ -446,7 +446,8 @@ void GlobalRouter::Init(Building* building) {
}
//dumping the complete system
//DumpAccessPoints(-1);
//DumpAccessPoints(3-1);
//DumpAccessPoints(381);
//vector<string> rooms;
//rooms.push_back("hall");
//rooms.push_back("0");
......@@ -554,7 +555,10 @@ void GlobalRouter::DumpAccessPoints(int p) {
int GlobalRouter::FindExit(Pedestrian* ped) {
int nextDestination = ped->GetNextDestination();
//ped->Dump(1);
if(ped->GetGlobalTime()>400){
//ped->Dump(143);
//exit(0);
}
if (nextDestination == -1) {
return GetBestDefaultRandomExit(ped);
......
......@@ -530,7 +530,7 @@ void QuickestPathRouter::SelectReferencePedestrian(Pedestrian* myself, Pedestria
*flag=FREE_EXIT; // assume free exit
Crossing* crossing=_building->GetTransOrCrossByID(exitID);
Crossing* crossing=_building->GetTransOrCrossByUID(exitID);
double jamThreshold=0.5;
double radius=3.0;//start radius for looking at the reference in metres
......@@ -687,7 +687,7 @@ bool QuickestPathRouter::IsDirectVisibilityBetween(Pedestrian* ped, Pedestrian*
int ignore_ped1=ped->GetID();
int ignore_ped2=ref->GetID();
Crossing* ignore_crossing=_building->GetTransOrCrossByID(ref->GetExitIndex());
Crossing* ignore_crossing=_building->GetTransOrCrossByUID(ref->GetExitIndex());
int obstacles=GetObstaclesCountBetween(ped->GetPos(),ref->GetPos(),ignore_crossing,ignore_ped1,ignore_ped2);
......
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