Commit d6611b95 authored by tobias schroedter's avatar tobias schroedter

Possible fix of opening temp_close doors in every time step

parent 32858daa
Pipeline #17650 passed with stages
in 18 minutes and 51 seconds
......@@ -579,20 +579,23 @@ double Simulation::RunBody(double maxSimTime)
#endif
// here open transition that should be closed
// TODO fix, opens door everytime...
// for (auto& itr: _building->GetAllTransitions())
// {
// Transition* Trans = itr.second;
// if(Trans->IsTempClose())
// {
// Trans->UpdateClosingTime( _deltaT);
// if(Trans->GetClosingTime() <= _deltaT)
// {
// Trans->changeTemporaryState();
// Log-> Write("INFO:\tReset state of door %d, Time=%.2f", Trans->GetID(), Pedestrian::GetGlobalTime());
// }
// }
// }
// TODO fix, opens door everytime...
for (auto& itr: _building->GetAllTransitions())
{
Transition* Trans = itr.second;
if(Trans->IsTempClose())
{
if ((Trans->GetMaxDoorUsage() != std::numeric_limits<int>::max()) ||
(Trans->GetOutflowRate() != std::numeric_limits<double>::max()) ){
// || (Trans->GetOutflowRate() != std::numeric_limits<double>::max)){
Trans->UpdateClosingTime( _deltaT);
if(Trans->GetClosingTime() <= _deltaT){
Trans->changeTemporaryState();
}
Log-> Write("INFO:\tReset state of door %d, Time=%.2f", Trans->GetID(), Pedestrian::GetGlobalTime());
}
}
}
}// while time
return t;
}
......
......@@ -261,8 +261,8 @@ bool EventManager::DisseminateKnowledge(Building* _b)
//TODO Was passiert hier?
//update the routers based on the configurations
//#pragma omp parallel
for(auto&& ped:_b->GetAllPedestrians())
{
// for(auto&& ped:_b->GetAllPedestrians())
// {
// if(UpdateRoute(ped)==false)
// {
// //Clear the memory and attempt to reroute
......@@ -277,7 +277,7 @@ bool EventManager::DisseminateKnowledge(Building* _b)
// exit(EXIT_FAILURE);
// }
// }
}
// }
return true;
}
......@@ -286,8 +286,17 @@ bool EventManager::UpdateRoute(Pedestrian* ped)
//create the key as string.
//map are sorted by default
string key= ped->GetKnowledgeAsString();
// std::cout << "key: <" << key << ">" << std::endl;
//get the router engine corresponding to the actual configuration
bool status=true;
// for (auto event : _eventEngineStorage){
// std::cout << "_eventEngineStorage " << event.first << ": " << std::endl;
// for (auto router : event.second->GetAvailableRouters()){
// std::cout << router->GetStrategy() << std::endl;
// }
// }
if (_eventEngineStorage.count(key)>0)
{
RoutingEngine* engine=_eventEngineStorage[key];
......@@ -309,9 +318,9 @@ bool EventManager::UpdateRoute(Pedestrian* ped)
}
else
{
//Log->Write("WARNING: \t unknown configuration <%s>", key.c_str());
//Log->Write("WARNING: \t [%d] router available", _eventEngineStorage.size());
//Log->Write(" : \t trying to create");
// Log->Write("WARNING: \t unknown configuration <%s>", key.c_str());
// Log->Write("WARNING: \t [%d] router available", _eventEngineStorage.size());
// Log->Write(" : \t trying to create");
//CreateRoutingEngine(_building);
status= false;
}
......@@ -527,7 +536,6 @@ void EventManager::ProcessEvent()
case DoorState::TEMP_CLOSE:
TempCloseDoor(event.GetId());
break;
}
}
......@@ -632,7 +640,7 @@ bool EventManager::CreateRoutingEngine(Building* _b, int first_engine)
for(auto&& t:_b->GetAllTransitions())
{
if(t.second->IsOpen()==false)
if(!t.second->IsClose())
closed_doors.push_back(t.second->GetID());
}
std::sort(closed_doors.begin(), closed_doors.end());
......
......@@ -46,8 +46,9 @@ AccessPoint::AccessPoint(int id, double center[2],double radius)
pCentre=Point(center[0],center[1]);
_transitPedestrians = vector<Pedestrian*>();
_connectingAPs = vector<AccessPoint*>();
_isClosed=0;
// _isClosed=0
_navLine=nullptr;
_state = DoorState::OPEN;
}
AccessPoint::~AccessPoint()
......@@ -60,15 +61,16 @@ int AccessPoint::GetID()
return _id;
}
int AccessPoint::IsClosed()
bool AccessPoint::IsClosed()
{
return _isClosed;
return _state == DoorState::CLOSE;
}
void AccessPoint::SetClosed(int isClosed)
{
_isClosed=isClosed;
}
//void AccessPoint::SetClosed(int isClosed)
//{
// _isClosed=isClosed;
//}
void AccessPoint::SetFinalExitToOutside(bool isFinal)
{
_finaExitToOutside=isFinal;
......@@ -260,6 +262,16 @@ const std::string AccessPoint::GetFriendlyName()
return _friendlyName;
}
void AccessPoint::SetState(DoorState state)
{
_state = state;
}
DoorState AccessPoint::GetState() const
{
return _state;
}
void AccessPoint::Dump()
{
......
......@@ -143,13 +143,13 @@ public:
/**
* @return true if the door is closed
*/
int IsClosed();
/**
* Close the door
* @param isClosed
*/
void SetClosed(int isClosed);
bool IsClosed();
//
// /**
// * Close the door
// * @param isClosed
// */
// void SetClosed(int isClosed);
/**
* Set/Get the navigation line.
......@@ -192,6 +192,9 @@ public:
int GetNearestTransitAPTO(int UID=FINAL_DEST_OUT);
void AddTransitAPsTo(int UID,AccessPoint* ap);
void SetState(DoorState state);
DoorState GetState() const;
private:
int _id;
double _center[2];
......@@ -205,7 +208,7 @@ private:
Point pCentre;
NavLine* _navLine;
std::vector<Pedestrian*> _transitPedestrians;
int _isClosed;
// int _isClosed;
std::string _friendlyName;
// stores the connecting APs
......@@ -223,6 +226,7 @@ private:
//store the navigation graph
std::map<int,std::vector<AccessPoint*> > _navigationGraphTo;
DoorState _state;
};
#endif /* ACCESSPOINT_H_ */
......@@ -185,7 +185,8 @@ bool GlobalRouter::Init(Building* building)
cross->GetSubRoom1()->GetSubRoomID());
ap->SetFriendlyName(friendlyName);
ap->SetClosed(cross->IsClose());
// ap->SetClosed(cross->IsClose());
ap->SetState(cross->GetState());
// save the connecting sub/rooms IDs
int id1 = -1;
if (cross->GetSubRoom1()) {
......@@ -222,7 +223,8 @@ bool GlobalRouter::Init(Building* building)
cross->GetSubRoom1()->GetSubRoomID());
ap->SetFriendlyName(friendlyName);
ap->SetClosed(cross->IsClose());
// ap->SetClosed(cross->IsClose());
ap->SetState(cross->GetState());
// save the connecting sub/rooms IDs
int id1 = -1;
if (cross->GetSubRoom1()) {
......@@ -389,6 +391,7 @@ bool GlobalRouter::Init(Building* building)
//run the floyd warshall algorithm
FloydWarshall();
// set the configuration for reaching the outside
// set the distances to all final APs
......@@ -399,7 +402,8 @@ bool GlobalRouter::Init(Building* building)
if(from_AP->GetFinalGoalOutside()) continue;
//maybe put the distance to FLT_MAX
if(from_AP->IsClosed()) continue;
if(from_AP->IsClosed())
continue;
double tmpMinDist = FLT_MAX;
int tmpFinalGlobalNearestID = from_door;
......@@ -687,13 +691,29 @@ bool GlobalRouter::GetPath(Pedestrian*ped, int goalID, std::vector<SubRoom*>& pa
void GlobalRouter::FloydWarshall()
{
const int n = (const int) (_building->GetNumberOfGoals() + _building->GetAllGoals().size());
for (int k = 0; k < n; k++)
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (_distMatrix[i][k] + _distMatrix[k][j] < _distMatrix[i][j]) {
_distMatrix[i][j] = _distMatrix[i][k] + _distMatrix[k][j];
std::cout << "FloydWarshall ------------------" << std::endl;
for (int k = 0; k < n; k++) {
for (int i = 0; i<n; i++) {
for (int j = 0; j<n; j++) {
if (_distMatrix[i][k]+_distMatrix[k][j]<_distMatrix[i][j]) {
_distMatrix[i][j] = _distMatrix[i][k]+_distMatrix[k][j];
_pathsMatrix[i][j] = _pathsMatrix[k][j];
}
}
}
}
for (int i = 0; i<n; i++) {
for (int j = 0; j<n; j++) {
std::cout << _distMatrix[i][j] << "\t";
}
std::cout << std::endl;
}
std::cout << "FloydWarshall Ende----------------" << std::endl;
}
//void GlobalRouter::DumpAccessPoints(int p)
......@@ -921,7 +941,7 @@ void GlobalRouter::GetRelevantRoutesTofinalDestination(Pedestrian *ped, vector<A
}
if(relevant) {
//only if not closed
if(ap->IsClosed()==0)
if(!ap->IsClosed())
relevantAPS.push_back(ap);
}
}
......@@ -976,7 +996,7 @@ void GlobalRouter::GetRelevantRoutesTofinalDestination(Pedestrian *ped, vector<A
}
if(relevant)
{
if(ap->IsClosed()==0)
if(!ap->IsClosed())
relevantAPS.push_back(ap);
}
}
......
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