Commit 7a0ded26 authored by Ulrich Kemloh's avatar Ulrich Kemloh

more stable information propagation process

parent e7985c06
......@@ -72,7 +72,7 @@ void OutputHandler::ProgressBar(double TotalPeds, double NowPeds, double simTime
// create the "meter"
int ii=0;
printf(" Time: %6.2f s | Evacuation: %5d (%3.0f%%) [", simTime, (int)NowPeds, fraction*100);
printf(" Time: %6.2f s | Evacuation: %5d (%3.0f%% ) [", simTime, (int)NowPeds, fraction*100);
// part that's full already
for ( ; ii < dotz; ii++) {
printf("=");
......
......@@ -261,7 +261,7 @@ bool Simulation::InitArgs(const ArgumentParser& args)
}
//read and initialize events
_em = new EventManager(_building.get());
_em = new EventManager(_building.get(),args.GetSeed());
if(_em->ReadEventsXml()==false)
{
Log->Write("ERROR: \tCould not initialize events handling");
......
......@@ -60,7 +60,7 @@ using std::cout;
using std::endl;
EventManager::EventManager(Building *_b)
EventManager::EventManager(Building *_b, unsigned int seed)
{
_building = _b;
_eventCounter = 0;
......@@ -84,8 +84,7 @@ EventManager::EventManager(Building *_b)
_rdDistribution = std::uniform_real_distribution<double> (0,1);
//std::random_device rd;
//_rdGenerator=std::mt19937(rd());
_rdGenerator=std::mt19937(23);
_rdGenerator=std::mt19937(seed);
//save the first graph
CreateRoutingEngine(_b, true);
......@@ -165,7 +164,7 @@ bool EventManager::ReadEventsXml()
Log->Write("INFO: \tEvents were initialized");
//create some events
CreateSomeEngine();
CreateSomeEngines();
return true;
}
......@@ -198,7 +197,7 @@ void EventManager::ReadEventsTxt(double time)
} while (feof(_file) == 0);
}
bool EventManager::UpdateAgentKnowledge(Building* _b)
bool EventManager::CollectNewKnowledge(Building* _b)
{
//#pragma omp parallel for
for(auto&& ped:_b->GetAllPedestrians())
......@@ -212,9 +211,19 @@ bool EventManager::UpdateAgentKnowledge(Building* _b)
{
//1.0 because the information is sure
ped->AddKnownClosedDoor(door.first, Pedestrian::GetGlobalTime(), !door.second->IsOpen(),_updateFrequency,1.0);
UpdateRoute(ped);
}
}
}
}
return true;
}
bool EventManager::DisseminateKnowledge(Building* _b)
{
for(auto&& ped:_b->GetAllPedestrians())
{
//update the latency for new and old information
for(auto&& info: ped->GetKnownledge())
{
......@@ -222,7 +231,6 @@ bool EventManager::UpdateAgentKnowledge(Building* _b)
}
}
for(auto&& ped1:_b->GetAllPedestrians())
{
vector<Pedestrian*> neighbourhood;
......@@ -240,7 +248,9 @@ bool EventManager::UpdateAgentKnowledge(Building* _b)
if(!MergeKnowledge(ped1, ped2))
{
//p2 is now an informant
Log->Write("INFO:\t the information was refused by ped %d",ped2->GetID());
//Log->Write("INFO:\tthe information was refused by ped %d",ped2->GetID());
//ped2->SetSpotlight(true);
//Pedestrian::SetColorMode(AgentColorMode::BY_SPOTLIGHT);
}
}
}
......@@ -408,13 +418,14 @@ bool EventManager::MergeKnowledge(Pedestrian* p1, Pedestrian* p2)
{
auto const & old_info1 = p1->GetKnownledge();
auto & old_info2 = p2->GetKnownledge();
bool status=true;
//accept the new information
if(_rdDistribution(_rdGenerator)< (1-p1->GetRiskTolerance()))
{
for (const auto& info1 : old_info1)
{
//I dont forward information that I refused already
if(info1.second.HasBeenRefused()) continue;
//if(info1.second.HasBeenRefused()) continue;
// Is the latency ok ?
if(!info1.second.CanBeForwarded()) continue;
......@@ -444,7 +455,7 @@ bool EventManager::MergeKnowledge(Pedestrian* p1, Pedestrian* p2)
old_info2[info1.first].SetLatency(_updateFrequency);
}
}
return true;
status= true;
}
//refuse the new information
else
......@@ -466,13 +477,14 @@ bool EventManager::MergeKnowledge(Pedestrian* p1, Pedestrian* p2)
old_info2[info1.first].SetLatency(_updateFrequency);
//cout<<"refusing: "<<p2->GetID()<<endl;
}
//es gibt mindestens eine info zum ablehnen
status=false;
}
//p2->SetSpotlight(true);
//Pedestrian::SetColorMode(BY_SPOTLIGHT);
//cout<<"refusing..."<<p2->GetID()<<endl;
return false;
}
return status;
}
void EventManager::ProcessEvent()
......@@ -481,12 +493,15 @@ void EventManager::ProcessEvent()
int current_time = Pedestrian::GetGlobalTime();
//update knowledge about closed doors
CollectNewKnowledge(_building);
if ( (current_time != _lastUpdateTime) &&
((current_time % _updateFrequency) == 0))
{
//update knowledge about closed doors
//share the information between the pedestrians
UpdateAgentKnowledge(_building);
DisseminateKnowledge(_building);
//actualize based on the new knowledge
_lastUpdateTime = current_time;
//cout<<"update: "<<current_time<<endl;
......@@ -689,7 +704,7 @@ Router * EventManager::CreateRouter(const RoutingStrategy& strategy)
return rout;
}
void EventManager::CreateSomeEngine()
void EventManager::CreateSomeEngines()
{
Log->Write("INFO: \tpopulating routers");
std::map<int, bool> doors_states;
......
......@@ -44,7 +44,7 @@ public:
/**
* Constructor
*/
EventManager(Building *_b);
EventManager(Building *_b, unsigned int seed);
/**
* destructor
......@@ -99,7 +99,15 @@ private:
* will save that information
* @param _b, the building object
*/
bool UpdateAgentKnowledge(Building* _b);
bool DisseminateKnowledge(Building* _b);
/**
* Gather knowledge about the state of the doors.
* Which is going to be disseminated afterwards.
* @param _b
* @return
*/
bool CollectNewKnowledge(Building* _b);
/**
* Synchronize the knowledge of the two pedestrians.
......@@ -130,7 +138,7 @@ private:
*/
bool UpdateRoute(Pedestrian* p1);
void CreateSomeEngine();
void CreateSomeEngines();
private:
......
......@@ -2,7 +2,7 @@
<JPScore project="JPS-Project" version="0.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_events.xsd">
<events update_frequency="1" update_radius="0.5" agents_color_by_knowledge="true">
<events update_frequency="4" update_radius="1" agents_color_by_knowledge="true">
<event time="10" type="door" state="close" id="2" caption="exit" />
<event time="30" type="door" state="close" id="3" caption="exit" />
</events>
......
......@@ -89,8 +89,8 @@
<model operational_model_id="1" description="gcfm">
<model_parameters>
<solver>euler</solver>
<stepsize>0.001</stepsize>
<exit_crossing_strategy>4</exit_crossing_strategy>
<stepsize>0.01</stepsize>
<exit_crossing_strategy>3</exit_crossing_strategy>
<linkedcells enabled="true" cell_size="2.2" />
<force_ped nu="0.3" dist_max="3" disteff_max="2" interpolation_width="0.1" />
<force_wall nu="0.2" dist_max="3" disteff_max="2" interpolation_width="0.1" />
......@@ -149,7 +149,7 @@
<!-- <router router_id="1" description="global_shortest"> -->
<!-- <parameters></parameters> -->
<!-- </router> -->
<router router_id="1" description="quickest">
<router router_id="1" description="global_shortest">
<parameters></parameters>
</router>
</route_choice_models>
......
......@@ -211,7 +211,7 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
Point pos_neu = ped->GetPos() + v_neu * deltaT;
if( (v_neu.Norm() > 1.2*ped->GetV0Norm() )) { // Stop pedestrians if the velocity is too high
// Log->Write("WARNING: \tped %d is stopped because v=%f (v0=%f)\n", ped->GetID(), v_neu.Norm(), ped->GetV0Norm());
//Log->Write("WARNING: \tped %d is stopped because v=%f (v0=%f)\n", ped->GetID(), v_neu.Norm(), ped->GetV0Norm());
v_neu = v_neu*0.01;
pos_neu = ped->GetPos();
}
......
......@@ -285,7 +285,7 @@ bool QuickestPathRouter::Init(Building* building)
return false;
// activate the spotlight for tracking some pedestrians
Pedestrian::SetColorMode(AgentColorMode::BY_SPOTLIGHT);
//Pedestrian::SetColorMode(AgentColorMode::BY_SPOTLIGHT);
//vector<string> rooms;
//rooms.push_back("150");
......
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