Commit 93e5a95d authored by Ulrich Kemloh's avatar Ulrich Kemloh

get the host name now working properly.

parent 504b98b7
...@@ -54,9 +54,9 @@ HybridSimulationManager::HybridSimulationManager(const std::string& server, ...@@ -54,9 +54,9 @@ HybridSimulationManager::HybridSimulationManager(const std::string& server,
_externalServerPort = port; _externalServerPort = port;
//get the canonical hostname //get the canonical hostname
//char hostname[1024]; char hostname[1024];
//gethostname(hostname, 1024); gethostname(hostname, 1024);
//_internalServerName=std::string(hostname); _internalServerName=std::string(hostname);
//GOOGLE_PROTOBUF_VERIFY_VERSION; //GOOGLE_PROTOBUF_VERIFY_VERSION;
//grpc_init(); //grpc_init();
...@@ -98,8 +98,10 @@ bool HybridSimulationManager::Run(Simulation& sim) ...@@ -98,8 +98,10 @@ bool HybridSimulationManager::Run(Simulation& sim)
//string extern_service_address("zam597:9999"); //string extern_service_address("zam597:9999");
string extern_service_address(_externalServerName + ":" + std::to_string(_externalServerPort)); string extern_service_address(_externalServerName + ":" + std::to_string(_externalServerPort));
string jupedsim_service_address(_internalServerName + ":" + std::to_string(_internalServerPort)); ///0.0.0.0 means to listen on all devices
//string jupedsim_service_address("0.0.0.0:9999")/*_serverName + ":" + std::to_string(_port)*/; string jupedsim_service_address("0.0.0.0:" + std::to_string(_internalServerPort));
//string jupedsim_service_address(_internalServerName + ":" + std::to_string(_internalServerPort));
//string jupedsim_service_address("0.0.0.0:9998")/*_serverName + ":" + std::to_string(_port)*/;
//create the client that will be running on its own thread //create the client that will be running on its own thread
...@@ -124,7 +126,7 @@ bool HybridSimulationManager::Run(Simulation& sim) ...@@ -124,7 +126,7 @@ bool HybridSimulationManager::Run(Simulation& sim)
Log->Write("INFO:\tNotifying Matsim at " + extern_service_address); Log->Write("INFO:\tNotifying Matsim at " + extern_service_address);
//if(false==_rpcClient->NotifyExternalService(_exinternalServerName,_internalServerPort)) //if(false==_rpcClient->NotifyExternalService(_exinternalServerName,_internalServerPort))
if(false==_rpcClient->NotifyExternalService("zam763",_internalServerPort)) if(false==_rpcClient->NotifyExternalService(_internalServerName,_internalServerPort))
{ {
Log->Write("ERROR:\tNotification failed"); Log->Write("ERROR:\tNotification failed");
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "../voronoi/VoronoiDiagramGenerator.h" #include "../voronoi/VoronoiDiagramGenerator.h"
#include "../geometry/Building.h" #include "../geometry/Building.h"
#include "../mpi/LCGrid.h"
#include <iostream> #include <iostream>
#include <thread> #include <thread>
#include <chrono> #include <chrono>
...@@ -284,11 +285,13 @@ void AgentsSourcesManager::ComputeBestPositionRandom(AgentsSource* src, ...@@ -284,11 +285,13 @@ void AgentsSourcesManager::ComputeBestPositionRandom(AgentsSource* src,
//int subroomID = dist->GetSubroomID(); //int subroomID = dist->GetSubroomID();
// first default Position // first default Position
for (const auto& ped : peds) for (auto& ped : peds)
{ {
//ped->Dump(ped->GetID()); continue; //ped->Dump(ped->GetID()); continue;
int index = -1; int index = -1;
AdjustVelocityUsingWeidmann(ped);
//in the case a range was specified //in the case a range was specified
for (unsigned int a = 0; a < positions.size(); a++) for (unsigned int a = 0; a < positions.size(); a++)
{ {
...@@ -337,6 +340,32 @@ void AgentsSourcesManager::ComputeBestPositionRandom(AgentsSource* src, ...@@ -337,6 +340,32 @@ void AgentsSourcesManager::ComputeBestPositionRandom(AgentsSource* src,
} }
} }
void AgentsSourcesManager::AdjustVelocityUsingWeidmann(Pedestrian* ped) const
{
//get the density
vector<Pedestrian*> neighbours;
_building->GetGrid()->GetNeighbourhood(ped,neighbours);
//pers per m2
double density = 1.0;
//radius corresponding to a surface of 1m2
double radius_square=0.564*0.564;
for(const auto& p: neighbours)
{
if( (ped->GetPos()-p->GetPos()).NormSquare()<radius_square)
density+=1.0;
}
//get the velocity
double density_max=5.4;
double speed=1.34*(1 - exp(-1.913*(1.0/density-1.0/density_max)));
//set the velocity vector
if(ped->FindRoute()!=-1)
{
}
}
void AgentsSourcesManager::GenerateAgents() void AgentsSourcesManager::GenerateAgents()
......
...@@ -93,6 +93,11 @@ private: ...@@ -93,6 +93,11 @@ private:
private: private:
void ComputeBestPositionVoronoi(AgentsSource* src, Pedestrian* agent); void ComputeBestPositionVoronoi(AgentsSource* src, Pedestrian* agent);
void ComputeBestPositionRandom(AgentsSource* src, std::vector<Pedestrian*>& peds) const; void ComputeBestPositionRandom(AgentsSource* src, std::vector<Pedestrian*>& peds) const;
/**
* Adjust the velocity of the pedestrian using the weidmann fundamental diagram
*/
void AdjustVelocityUsingWeidmann(Pedestrian* ped) const;
}; };
#endif /* AGENTSSOURCESMANAGER_H_ */ #endif /* AGENTSSOURCESMANAGER_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