Commit 73d51314 authored by Ulrich Kemloh's avatar Ulrich Kemloh

Switch for the hybrid simulation: <hybrid_simulation server="localhost"

port="9999" /> in the ini file 
parent 079b7777
......@@ -34,6 +34,7 @@
#include "math/GompertzModel.h"
#include "pedestrian/AgentsSourcesManager.h"
#include "pedestrian/AgentsQueue.h"
#include "matsim/HybridSimulationManager.h"
#ifdef _OPENMP
#include <omp.h>
......@@ -60,8 +61,6 @@ Simulation::Simulation(const ArgumentParser& args)
_iod = new IODispatcher();
_fps = 1;
_em = nullptr;
_hpc = -1;
_profiling = false;
_argsParser = args;
}
......@@ -228,6 +227,12 @@ bool Simulation::InitArgs(const ArgumentParser& args)
//src->Dump();
}
//iniitalize the hybridmode if defined
if(nullptr!=(_hybridSimManager=args.GetHybridSimManager()))
{
_hybridSimManager->Init(_building.get());
};
//perform customs initialisation, like computing the phi for the gcfm
//this should be called after the routing engine has been initialised
// because a direction is needed for this initialisation.
......@@ -261,13 +266,6 @@ bool Simulation::InitArgs(const ArgumentParser& args)
}
_em->ListEvents();
//which hpc-architecture?
_hpc = args.GetHPCFlag();
//if programming model = ocl create buffers and make the setup
//if(_hpc==1){
//((GPU_ocl_GCFMModel*) _model)->CreateBuffer(_building->GetNumberOfPedestrians());
//((GPU_ocl_GCFMModel*) _model)->initCL(_building->GetNumberOfPedestrians());
//}
//_building->SaveGeometry("test.sav.xml");
//if(_building->SanityCheck()==false)
......@@ -469,9 +467,19 @@ void Simulation::UpdateRoutesAndLocations()
}
}
// remove the pedestrians that have left the building
for (unsigned int p = 0; p < pedsToRemove.size(); p++) {
_building->DeletePedestrian(pedsToRemove[p]);
if (_hybridSimManager)
{
AgentsQueueOut::Add(pedsToRemove);
}
else
{
// remove the pedestrians that have left the building
for (unsigned int p = 0; p < pedsToRemove.size(); p++)
{
_building->DeletePedestrian(pedsToRemove[p]);
}
}
// temporary fix for the safest path router
......
......@@ -56,6 +56,7 @@
//Forward declarations TO DO
//class AgentsSourcesManager;
class EventManager;
class HybridSimulationManager;
class Simulation
{
......@@ -85,10 +86,9 @@ private:
ArgumentParser _argsParser;
/// Agents sources manager
AgentsSourcesManager _agentSrcManager;
/// profiling flag
bool _profiling;
/// architecture flag
int _hpc;
/// hybrid simulation manager
//HybridSimulationManager
std::shared_ptr<HybridSimulationManager>_hybridSimManager=nullptr;
public:
......
......@@ -57,6 +57,7 @@
#include "../routing/CognitiveMapRouter.h"
#include "../math/GompertzModel.h"
#include "../math/GCFMModel.h"
#include "../matsim/HybridSimulationManager.h"
using namespace std;
......@@ -302,8 +303,8 @@ bool ArgumentParser::ParseIniFile(string inifile)
if (xMainNode->FirstChild("show_statistics"))
{
string value = xMainNode->FirstChild("show_statistics")->FirstChild()->Value();
if(value=="true")
_showStatistics=true;
if(value=="true")
_showStatistics=true;
Log->Write("INFO: \tShow statistics: %s",value.c_str());
}
//trajectories
......@@ -362,6 +363,17 @@ bool ArgumentParser::ParseIniFile(string inifile)
}
}
//check the simulation mode
//trajectories
TiXmlNode* xSimMode = xMainNode->FirstChild("hybrid_simulation");
if (xSimMode)
{
int port=std::stoi(xMainNode->FirstChildElement("hybrid_simulation")->Attribute("port"));
string server=xMainNode->FirstChildElement("hybrid_simulation")->Attribute("server");
_hybridSimManager=std::shared_ptr<HybridSimulationManager>(new HybridSimulationManager(server,port));
Log->Write(_hybridSimManager->ToString());
}
//pick up which model to use
//get the wanted ped model id
pModel=xmltoi(xMainNode->FirstChildElement("agents")->Attribute("operational_model_id"),-1);
......@@ -779,7 +791,7 @@ bool ArgumentParser::ParseRoutingStrategies(TiXmlNode *routingNode)
Log->Write("\nINFO: \tUsing CognitiveMapRouter");
///Parsing additional options
if (!ParseCogMapOpts(e))
return false;
return false;
}
else {
Log->Write("ERROR: \twrong value for routing strategy [%s]!!!\n",
......@@ -793,56 +805,56 @@ bool ArgumentParser::ParseRoutingStrategies(TiXmlNode *routingNode)
bool ArgumentParser::ParseCogMapOpts(TiXmlNode *routerNode)
{
TiXmlNode* sensorNode=routerNode->FirstChild();
TiXmlNode* sensorNode=routerNode->FirstChild();
if (!sensorNode)
{
Log->Write("ERROR:\tNo sensors found.\n");
return false;
}
if (!sensorNode)
{
Log->Write("ERROR:\tNo sensors found.\n");
return false;
}
/// static_cast to get access to the method 'addOption' of the CognitiveMapRouter
CognitiveMapRouter* r = static_cast<CognitiveMapRouter*>(_routingengine->GetAvailableRouters().back());
/// static_cast to get access to the method 'addOption' of the CognitiveMapRouter
CognitiveMapRouter* r = static_cast<CognitiveMapRouter*>(_routingengine->GetAvailableRouters().back());
std::vector<std::string> sensorVec;
for (TiXmlElement* e = sensorNode->FirstChildElement("sensor"); e;
e = e->NextSiblingElement("sensor"))
{
string sensor = e->Attribute("description");
///adding Smoke Sensor specific parameters
if (sensor=="Smoke")
{
std::vector<std::string> smokeOptVec;
std::vector<std::string> sensorVec;
for (TiXmlElement* e = sensorNode->FirstChildElement("sensor"); e;
e = e->NextSiblingElement("sensor"))
{
string sensor = e->Attribute("description");
///adding Smoke Sensor specific parameters
if (sensor=="Smoke")
{
std::vector<std::string> smokeOptVec;
smokeOptVec.push_back(e->Attribute("p_field_path"));
smokeOptVec.push_back(e->Attribute("update_time"));
smokeOptVec.push_back(e->Attribute("final_time"));
r->addOption("smokeOptions",smokeOptVec);
smokeOptVec.push_back(e->Attribute("p_field_path"));
smokeOptVec.push_back(e->Attribute("update_time"));
smokeOptVec.push_back(e->Attribute("final_time"));
r->addOption("smokeOptions",smokeOptVec);
}
sensorVec.push_back(sensor);
}
sensorVec.push_back(sensor);
Log->Write("INFO: \tSensor "+ sensor + " added");
}
Log->Write("INFO: \tSensor "+ sensor + " added");
}
r->addOption("Sensors",sensorVec);
r->addOption("Sensors",sensorVec);
TiXmlElement* cogMap=routerNode->FirstChildElement("cognitive_map");
TiXmlElement* cogMap=routerNode->FirstChildElement("cognitive_map");
if (!cogMap)
{
Log->Write("ERROR:\tCognitive Map not specified.\n");
return false;
}
if (!cogMap)
{
Log->Write("ERROR:\tCognitive Map not specified.\n");
return false;
}
std::vector<std::string> cogMapStatus;
cogMapStatus.push_back(cogMap->Attribute("status"));
Log->Write("INFO: \tAll pedestrian starting with a(n) "+cogMapStatus[0]+" cognitive map\n");
r->addOption("CognitiveMap",cogMapStatus);
std::vector<std::string> cogMapStatus;
cogMapStatus.push_back(cogMap->Attribute("status"));
Log->Write("INFO: \tAll pedestrian starting with a(n) "+cogMapStatus[0]+" cognitive map\n");
r->addOption("CognitiveMap",cogMapStatus);
return true;
return true;
}
......@@ -991,6 +1003,10 @@ vector<pair<int, RoutingStrategy> > ArgumentParser::GetRoutingStrategy() const
{
return pRoutingStrategies;
}
std::shared_ptr<HybridSimulationManager> ArgumentParser::GetHybridSimManager() const
{
return _hybridSimManager;
}
double ArgumentParser::GetV0Mu() const
{
......
......@@ -47,6 +47,8 @@ class OutputHandler;
class TiXmlElement;
class TiXmlNode;
class AgentsParameters;
class HybridSimulationManager;
extern OutputHandler* Log;
class ArgumentParser
......@@ -111,6 +113,8 @@ private:
std::shared_ptr<DirectionStrategy> p_exit_strategy;
std::shared_ptr<OperationalModel> p_op_model;
std::shared_ptr<RoutingEngine> _routingengine;
std::shared_ptr<HybridSimulationManager> _hybridSimManager=nullptr;
private:
bool ParseGCFMModel(TiXmlElement* xGCFM);
......@@ -217,6 +221,8 @@ public:
int GetHPCFlag() const;
bool ShowStatistics()const;
std::shared_ptr<HybridSimulationManager> GetHybridSimManager() const;
vector<pair<int, RoutingStrategy> > GetRoutingStrategy() const;
const FileFormat& GetFileFormat() const;
......
......@@ -1144,7 +1144,8 @@ void Building::DeletePedestrian(Pedestrian* &ped)
}
//update the stats before deleting
Transition* trans =GetTransitionByUID(ped->GetExitIndex());
if(trans) {
if(trans)
{
trans->IncreaseDoorUsage(1, ped->GetGlobalTime());
}
delete ped;
......
<?xml version="1.0" encoding="UTF-8" ?>
<JuPedSim project="JPS-Project" version="0.6"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd">
<JuPedSim project="JPS-Project" version="0.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd">
<!-- seed used for initialising random generator -->
<seed>12542</seed>
<!-- geometry file -->
<geometry>big_room_geo.xml</geometry>
<events_files>big_room_events.xml</events_files>
<!-- <max_sim_time>15</max_sim_time> -->
<max_sim_time>300</max_sim_time>
<!-- trajectories file and format -->
<trajectories format="xml-plain" fps="8">
<file location="big_room_trrajectories.xml" />
<socket hostname="127.0.0.1" port="8989"/>
<socket hostname="127.0.0.1" port="8989" />
</trajectories>
<!-- Parameters for the hybrid mode -->
<hybrid_simulation server="localhost" port="9999" />
<!-- where to store the logs -->
<!--<logfile>outputfiles/log.txt</logfile> -->
......@@ -71,17 +74,17 @@ xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd">
<!--persons information and distribution -->
<agents operational_model_id="2">
<agents_distribution>
<group group_id="0" room_id="0" subroom_id="0" number="1" router_id="1" agent_parameter_id="1"
risk_tolerance_mean="0.8" risk_tolerance_sigma="0.01" x_min="14" x_max="16" y_min="14" y_max="16"/>
<group group_id="0" room_id="0" subroom_id="0" number="1" router_id="1" agent_parameter_id="1" risk_tolerance_mean="0.8"
risk_tolerance_sigma="0.01" x_min="14" x_max="16" y_min="14" y_max="16" />
<group group_id="1" room_id="0" subroom_id="0" number="0" router_id="1" agent_parameter_id="1" />
</agents_distribution>
<agents_sources><!-- frequency in persons/seconds -->
<source id="1" frequency="5" agents_max="15" group_id="0" caption="source 1"/>
<sources id="1" frequency="5" agents_max="15" group_id="0" caption="source 1"/>
<agents_sources><!-- frequency in persons/seconds -->
<source id="1" frequency="5" agents_max="15" group_id="0" caption="source 1" />
<sources id="1" frequency="5" agents_max="15" group_id="0" caption="source 1" />
</agents_sources>
</agents>
<operational_models>
......
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