Commit 2edfa86d authored by tobias schroedter's avatar tobias schroedter

Added new Direction Strategy, cleaned up, omid some debug output to speed up simulations (WIP)

parent d535317d
Pipeline #16870 failed with stages
in 13 seconds
......@@ -1613,35 +1613,35 @@ bool IniFileParser::ParseStrategyNodeToObject(const TiXmlNode& strategyNode)
if(!ParseFfOpts(strategyNode)) {
return false;
};
_config->set_dirSubLocal(dynamic_cast<DirectionSubLocalFloorfield*>(_exit_strategy.get()));
_config->set_dirStrategy(dynamic_cast<DirectionSubLocalFloorfield*>(_exit_strategy.get()));
break;
case 8:
_exit_strategy = std::shared_ptr<DirectionStrategy>(new DirectionLocalFloorfield());
if(!ParseFfOpts(strategyNode)) {
return false;
};
_config->set_dirLocal(dynamic_cast<DirectionLocalFloorfield*>(_exit_strategy.get()));
_config->set_dirStrategy(dynamic_cast<DirectionLocalFloorfield*>(_exit_strategy.get()));
break;
case 9:
_exit_strategy = std::shared_ptr<DirectionStrategy>(new DirectionSubLocalFloorfield());
if(!ParseFfOpts(strategyNode)) {
return false;
};
_config->set_dirSubLocal(dynamic_cast<DirectionSubLocalFloorfield*>(_exit_strategy.get()));
_config->set_dirStrategy(dynamic_cast<DirectionSubLocalFloorfield*>(_exit_strategy.get()));
break;
case 10:
_exit_strategy = std::shared_ptr<DirectionStrategy>(new DirectionSubLocalFloorfieldTrips());
if(!ParseFfOpts(strategyNode)) {
return false;
};
_config->set_dirSubLocalTrips(dynamic_cast<DirectionSubLocalFloorfieldTrips*>(_exit_strategy.get()));
_config->set_dirStrategy(dynamic_cast<DirectionSubLocalFloorfieldTrips*>(_exit_strategy.get()));
break;
case 11:
_exit_strategy = std::shared_ptr<DirectionStrategy>(new DirectionSubLocalFloorfieldTripsVoronoi());
if(!ParseFfOpts(strategyNode)) {
return false;
};
_config->set_dirSubLocalTripsVoronoi(dynamic_cast<DirectionSubLocalFloorfieldTripsVoronoi*>(_exit_strategy.get()));
_config->set_dirStrategy(dynamic_cast<DirectionSubLocalFloorfieldTripsVoronoi*>(_exit_strategy.get()));
break;
default:
......
......@@ -44,10 +44,7 @@
//This class provides a data container for all configuration parameters.
class AgentsParameters;
class DirectionSubLocalFloorfield;
class DirectionLocalFloorfield;
class DirectionSubLocalFloorfieldTrips;
class DirectionSubLocalFloorfieldTripsVoronoi;
class DirectionStrategy;
#ifdef _JPS_AS_A_SERVICE
......@@ -125,9 +122,9 @@ public:
_write_VTK_files = false;
_exit_strat = 9;
_write_VTK_files_direction = false;
_dirSubLocal = nullptr;
_dirLocal = nullptr;
// _dirSubLocal = nullptr;
// _dirLocal = nullptr;
_dirStrategy = nullptr;
//for random numbers
_rdGenerator=RandomNumberGenerator();
......@@ -290,19 +287,21 @@ public:
int get_exit_strat() const {return _exit_strat;}
void set_dirSubLocal(DirectionSubLocalFloorfield* dir) {_dirSubLocal = dir;}
void set_dirLocal(DirectionLocalFloorfield* dir) {_dirLocal = dir;}
void set_dirSubLocalTrips(DirectionSubLocalFloorfieldTrips* dir) {_dirSubLocalTrips = dir;}
void set_dirSubLocalTripsVoronoi(DirectionSubLocalFloorfieldTripsVoronoi* dir) {_dirSubLocalTripsVoronoi = dir;}
DirectionSubLocalFloorfield* get_dirSubLocal() const {return _dirSubLocal;}
DirectionLocalFloorfield* get_dirLocal() const {return _dirLocal;}
void set_dirStrategy(DirectionStrategy* dir){_dirStrategy = dir;}
DirectionStrategy* get_dirStrategy(){return _dirStrategy;}
// void set_dirSubLocal(DirectionSubLocalFloorfield* dir) {_dirSubLocal = dir;}
//
// void set_dirLocal(DirectionLocalFloorfield* dir) {_dirLocal = dir;}
//
// void set_dirSubLocalTrips(DirectionSubLocalFloorfieldTrips* dir) {_dirSubLocalTrips = dir;}
//
// void set_dirSubLocalTripsVoronoi(DirectionSubLocalFloorfieldTripsVoronoi* dir) {_dirSubLocalTripsVoronoi = dir;}
DirectionSubLocalFloorfieldTrips* get_dirSubLocalTrips() const {return _dirSubLocalTrips;}
DirectionSubLocalFloorfieldTripsVoronoi* get_dirSubLocalTripsVoronoi() const {return _dirSubLocalTripsVoronoi;}
// DirectionSubLocalFloorfield* get_dirSubLocal() const {return _dirSubLocal;}
// DirectionLocalFloorfield* get_dirLocal() const {return _dirLocal;}
//
// DirectionSubLocalFloorfieldTrips* get_dirSubLocalTrips() const {return _dirSubLocalTrips;}
// DirectionSubLocalFloorfieldTripsVoronoi* get_dirSubLocalTripsVoronoi() const {return _dirSubLocalTripsVoronoi;}
const std::string& GetHostname() const { return _hostname; };
......@@ -423,10 +422,12 @@ private:
int _exit_strat;
DirectionSubLocalFloorfield* _dirSubLocal;
DirectionLocalFloorfield* _dirLocal;
DirectionSubLocalFloorfieldTrips* _dirSubLocalTrips;
DirectionSubLocalFloorfieldTripsVoronoi* _dirSubLocalTripsVoronoi;
// DirectionSubLocalFloorfield* _dirSubLocal;
// DirectionLocalFloorfield* _dirLocal;
// DirectionSubLocalFloorfieldTrips* _dirSubLocalTrips;
// DirectionSubLocalFloorfieldTripsVoronoi* _dirSubLocalTripsVoronoi;
DirectionStrategy* _dirStrategy;
std::string _hostname;
std::string _trajectoriesFile;
......
......@@ -133,7 +133,7 @@ void WaitingArea::removePed(int ped)
void WaitingArea::startTimer(double time)
{
startTime = time;
std::cout << "Timer started at " << startTime << std::endl;
// std::cout << "Timer started at " << startTime << std::endl;
}
bool WaitingArea::isWaiting(double time, const Building* building)
......@@ -152,16 +152,16 @@ bool WaitingArea::isWaiting(double time, const Building* building)
}
if ((startTime > 0. ) && (time > startTime + waitingTime) && (trans->IsOpen())){
std::cout << "Waiting ended" << std::endl;
// std::cout << "Waiting ended" << std::endl;
return false;
}
if ((waitingTime < 0. ) && (trans->IsOpen())){
std::cout << "Waiting ended" << std::endl;
// std::cout << "Waiting ended" << std::endl;
return false;
}
std::cout << "Waiting ..." << std::endl;
// std::cout << "Waiting ..." << std::endl;
return true;
}
......
......@@ -50,6 +50,16 @@ DirectionStrategy::DirectionStrategy()
DirectionStrategy::~DirectionStrategy()
{
}
double DirectionStrategy::GetDistance2Wall(Pedestrian* ped) const
{
return -1.;
}
double DirectionStrategy::GetDistance2Target(Pedestrian* ped, int UID)
{
return -1.;
}
/// 1
Point DirectionMiddlePoint::GetTarget(Room* room, Pedestrian* ped) const
{
......@@ -724,14 +734,12 @@ Point DirectionSubLocalFloorfieldTripsVoronoi::GetTarget(Room* room, Pedestrian*
Point p = p1 + p2 + p3;
// UnivFFviaFM* floorfield = _locffviafm.at(ped->GetSubRoomUID());
// floorfield->getDirectionToUID(ped->GetExitIndex(), ped->GetPos(),p);
// return (p + ped->GetPos());
return p;
} else {
Point p;
UnivFFviaFM* floorfield = _locffviafm.at(ped->GetSubRoomUID());
floorfield->getDirectionToUID(ped->GetExitIndex(), ped->GetPos(),p);
return (p + ped->GetPos());
}
......
......@@ -49,6 +49,9 @@ public:
virtual Point GetTarget(Room* room, Pedestrian* ped) const = 0;
virtual double GetDistance2Wall(Pedestrian* ped) const;
virtual double GetDistance2Target(Pedestrian* ped, int UID);
};
class DirectionMiddlePoint : public DirectionStrategy {
......
......@@ -529,9 +529,9 @@ int FFRouter::FindExit(Pedestrian* p)
//double locDistToDoor = _locffviafm[p->GetRoomID()]->getCostToDestination(doorUID, p->GetPos(), _mode);
double locDistToDoor = 0.;
if (_targetWithinSubroom) {
locDistToDoor = _config->get_dirSubLocal()->GetDistance2Target(p, doorUID);
locDistToDoor = _config->get_dirStrategy()->GetDistance2Target(p, doorUID);
} else {
locDistToDoor = _config->get_dirLocal()->GetDistance2Target(p, doorUID);
locDistToDoor = _config->get_dirStrategy()->GetDistance2Target(p, doorUID);
}
if (locDistToDoor < -J_EPS) { //for old ff: //this can happen, if the point is not reachable and therefore has init val -7
......
......@@ -129,9 +129,9 @@ UnivFFviaFMTrips::UnivFFviaFMTrips(Room* roomArg, Configuration* const confArg,
// }
// }
for (auto& door : tmpDoors){
std::cout << "uid: " << door.first << " door: " << door.second.toString() << std::endl;
}
// for (auto& door : tmpDoors){
// std::cout << "uid: " << door.first << " door: " << door.second.toString() << std::endl;
// }
//find insidePoint and save it, together with UID
Point normalVec = anyDoor.NormalVec();
......
......@@ -105,9 +105,7 @@ bool FFRouterTrips::Init(Building* building)
goalIDs.clear();
//get global field to manage goals (which are not in a subroom)
_globalFF = new FloorfieldViaFMTrips(building, 0.25, 0.25, 0.0, false, true);
std::cout << std::endl;
for (auto &itrGoal : building->GetAllGoals()) {
std::cout << "Goal ID: " << itrGoal.second->GetId() << std::endl;
if(WaitingArea* wa = dynamic_cast<WaitingArea*>(itrGoal.second)) {
_globalFF->createMapEntryInLineToGoalID(itrGoal.first, true);
}else{
......@@ -117,9 +115,6 @@ bool FFRouterTrips::Init(Building* building)
}
_goalToLineUIDmap = _globalFF->getGoalToLineUIDmap();
for (auto& tmp : _goalToLineUIDmap) {
std::cout << "Goal: " << tmp.first << " Crossing: " << tmp.second << std::endl;
}
_goalToLineUIDmap2 = _globalFF->getGoalToLineUIDmap2();
_goalToLineUIDmap3 = _globalFF->getGoalToLineUIDmap3();
......@@ -358,9 +353,9 @@ bool FFRouterTrips::Init(Building* building)
// }
// matrixfile.close();
for (auto dist : _distMatrix){
std::cout << dist.first.first << "->" << dist.first.second << ": " << dist.second << std::endl;
}
// for (auto dist : _distMatrix){
// std::cout << dist.first.first << "->" << dist.first.second << ": " << dist.second << std::endl;
// }
Log->Write("INFO: \tFF Router Init done.");
return true;
......@@ -472,16 +467,10 @@ bool FFRouterTrips::ReInit()
int FFRouterTrips::FindExit(Pedestrian* ped)
{
std::cout << std::endl;
std::cout << "Ped[" << ped->GetID() << "] in (" << ped->GetRoomID() << ", " << ped->GetSubRoomID()
<< "/" << ped->GetSubRoomUID() << "): " << std::endl;
std::cout << "FinalDestination: " << ped->GetFinalDestination() << std::endl;
// std::cout << "ExitLine: " << ped->GetExitLine() << std::endl;
std::cout << "ExitIndex: " << ped->GetExitIndex() << std::endl << std::endl;
for (auto& goal : _goalToLineUIDmap){
std::cout << goal.first << " -> " << goal.second << std::endl;
}
// for (auto& goal : _goalToLineUIDmap){
// std::cout << goal.first << " -> " << goal.second << std::endl;
// }
SubRoom* subroom = _building->GetSubRoomByUID(ped->GetSubRoomUID());
Goal* goal = _building->GetFinalGoal(ped->GetFinalDestination());
......@@ -491,8 +480,6 @@ int FFRouterTrips::FindExit(Pedestrian* ped)
// Check if current position is already waiting area
// yes: set next goal and return findExit(p)
if (goal->IsInsideGoal(ped->GetPos())){
std::cout << "Ped and Goal in same subroom: " << subroom->IsInSubRoom(goal->GetCentroid()) << std::endl;
std::cout << "Ped Final Destination before: " << ped->GetFinalDestination() << std::endl;
if(WaitingArea* wa = dynamic_cast<WaitingArea*>(goal)) {
//take the current time from the pedestrian
double t = Pedestrian::GetGlobalTime();
......@@ -503,27 +490,14 @@ int FFRouterTrips::FindExit(Pedestrian* ped)
ped->SetFinalDestination(wa->GetNextGoal());
}
}
std::cout << "Ped Final Destination after: " << ped->GetFinalDestination() << std::endl;
ret = FindExit1(ped);
}else{
ret = FindExit1(ped);
}
std::cout << "Ped[" << ped->GetID() << "] in (" << ped->GetRoomID() << ", " << ped->GetSubRoomID()
<< "/" << ped->GetSubRoomUID() << "): " << std::endl;
std::cout << "FinalDestination: " << ped->GetFinalDestination() << std::endl;
// std::cout << "ExitLine: " << ped->GetExitLine() << std::endl;
std::cout << "ExitIndex: " << ped->GetExitIndex() << std::endl;
std::cout << "====================================================" << std::endl;
return ret;
return FindExit1(ped);
}
int FFRouterTrips::FindExit1(Pedestrian* p)
{
std::cout << "------ FindExit1 ------" << std::endl;
if (_mode == quickest) {
if (p->GetGlobalTime() > _recalc_interval
&& _building->GetRoom(p->GetRoomID())->GetSubRoom(p->GetSubRoomID())->IsInSubRoom(p)
......@@ -631,7 +605,7 @@ int FFRouterTrips::FindExit1(Pedestrian* p)
// locDistToDoor = _config->get_dirLocal()->GetDistance2Target(p, doorUID);
// }
//
locDistToDoor = _config->get_dirSubLocalTrips()->GetDistance2Target(p, doorUID);
locDistToDoor = _config->get_dirStrategy()->GetDistance2Target(p, doorUID);
if (locDistToDoor < -J_EPS) { //for old ff: //this can happen, if the point is not reachable and therefore has init val -7
......@@ -678,7 +652,6 @@ int FFRouterTrips::FindExit1(Pedestrian* p)
p->SetExitLine(_CroTrByUID.at(bestDoor));
}
std::cout << "-----------------------" << std::endl << std::endl;
return bestDoor; //-1 if no way was found, doorUID of best, if path found
}
......
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