Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
JPScore
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
92
Issues
92
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
JuPedSim
JPScore
Commits
9f4cd6cf
Commit
9f4cd6cf
authored
Jul 23, 2015
by
Ulrich Kemloh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update events
parent
461656a1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
96 additions
and
30 deletions
+96
-30
Simulation.cpp
Simulation.cpp
+1
-0
events/EventManager.cpp
events/EventManager.cpp
+73
-26
events/EventManager.h
events/EventManager.h
+17
-2
pedestrian/Knowledge.cpp
pedestrian/Knowledge.cpp
+1
-1
pedestrian/Knowledge.h
pedestrian/Knowledge.h
+2
-0
pedestrian/Pedestrian.cpp
pedestrian/Pedestrian.cpp
+1
-0
pedestrian/Pedestrian.h
pedestrian/Pedestrian.h
+1
-1
No files found.
Simulation.cpp
View file @
9f4cd6cf
...
...
@@ -355,6 +355,7 @@ void Simulation::UpdateRoutesAndLocations()
//actualize the egress time for that iroom
old_room
->
SetEgressTime
(
ped
->
GetGlobalTime
());
//todo: also statistic for internal doors
//if(_argsParser.ShowStatistics())
//{
// Transition* trans =_building->GetTransitionByUID(ped->GetExitIndex());
...
...
events/EventManager.cpp
View file @
9f4cd6cf
...
...
@@ -55,27 +55,22 @@
#include "EventManager.h"
#include "Event.h"
using
namespace
std
;
using
std
::
map
;
using
std
::
cout
;
using
std
::
endl
;
/*******************
constructors
******************/
EventManager
::
EventManager
(
Building
*
_b
)
{
// _event_times = vector<double>();
// _event_types = vector<string>();
// _event_states = vector<string>();
// _event_ids = vector<int>();
_building
=
_b
;
_eventCounter
=
0
;
_dynamic
=
false
;
_lastUpdateTime
=
0
;
//_deltaT = 0;
_projectFilename
=
_building
->
GetProjectFilename
();
_projectRootDir
=
_building
->
GetProjectRootDir
();
_updateFrequency
=
1
;
//seconds
_updateRadius
=
2
;
//meters
_file
=
fopen
(
"../events/events.txt"
,
"r"
);
if
(
!
_file
)
{
Log
->
Write
(
"INFO:
\t
Files 'events.txt' missing. "
...
...
@@ -85,6 +80,11 @@ EventManager::EventManager(Building *_b)
_dynamic
=
true
;
}
//generate random number between 0 and 1 uniformly distributed
_rdDistribution
=
std
::
uniform_real_distribution
<
double
>
(
0
,
1
);
std
::
random_device
rd
;
_rdGenerator
=
std
::
mt19937
(
rd
());
//save the first graph
CreateRoutingEngine
(
_b
,
true
);
}
...
...
@@ -151,10 +151,6 @@ bool EventManager::ReadEventsXml()
for
(
TiXmlElement
*
e
=
xEvents
->
FirstChildElement
(
"event"
);
e
;
e
=
e
->
NextSiblingElement
(
"event"
))
{
// _event_times.push_back(atoi(e->Attribute("time")));
// _event_types.push_back(e->Attribute("type"));
// _event_states.push_back(e->Attribute("state"));
// _event_ids.push_back(atoi(e->Attribute("id")));
int
id
=
atoi
(
e
->
Attribute
(
"id"
));
double
zeit
=
atoi
(
e
->
Attribute
(
"time"
));
string
state
(
e
->
Attribute
(
"state"
));
...
...
@@ -165,7 +161,6 @@ bool EventManager::ReadEventsXml()
return
true
;
}
void
EventManager
::
ListEvents
()
{
for
(
const
auto
&
event
:
_events
)
...
...
@@ -195,9 +190,6 @@ void EventManager::ReadEventsTxt(double time)
}
while
(
feof
(
_file
)
==
0
);
}
/***********
Update
**********/
bool
EventManager
::
UpdateAgentKnowledge
(
Building
*
_b
)
{
//#pragma omp parallel
...
...
@@ -205,7 +197,7 @@ bool EventManager::UpdateAgentKnowledge(Building* _b)
{
for
(
auto
&&
door
:
_b
->
GetAllTransitions
())
{
if
(
door
.
second
->
DistTo
(
ped
->
GetPos
())
<
1
)
//distance to door to register its state
if
(
door
.
second
->
DistTo
(
ped
->
GetPos
())
<
0.5
)
//distance to door to register its state
{
//actualize the information about the newly closed door
if
(
door
.
second
->
IsOpen
()
==
false
)
...
...
@@ -239,8 +231,12 @@ bool EventManager::UpdateAgentKnowledge(Building* _b)
vector
<
SubRoom
*>
empty
;
if
(
_b
->
IsVisible
(
ped1
->
GetPos
(),
ped2
->
GetPos
(),
empty
))
{
MergeKnowledge
(
ped1
,
ped2
);
//ped1->SetSpotlight(true);
ped2
->
SetNewEventFlag
(
true
);
//SynchronizeKnowledge(ped1, ped2); //ped1->SetSpotlight(true);
if
(
MergeKnowledge
(
ped1
,
ped2
))
{
//p2 is now an informant
ped2
->
SetNewEventFlag
(
true
);
}
}
}
}
...
...
@@ -315,7 +311,7 @@ bool EventManager::UpdateRoute(Pedestrian* ped)
}
else
{
Log
->
Write
(
"WARNING:
\t
unknown configuration <%s>"
,
key
.
c_str
());
//
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);
...
...
@@ -324,7 +320,7 @@ bool EventManager::UpdateRoute(Pedestrian* ped)
return
status
;
}
void
EventManager
::
Merg
eKnowledge
(
Pedestrian
*
p1
,
Pedestrian
*
p2
)
bool
EventManager
::
Synchroniz
eKnowledge
(
Pedestrian
*
p1
,
Pedestrian
*
p2
)
{
auto
const
&
old_info1
=
p1
->
GetKnownledge
();
auto
const
&
old_info2
=
p2
->
GetKnownledge
();
...
...
@@ -360,6 +356,60 @@ void EventManager::MergeKnowledge(Pedestrian* p1, Pedestrian* p2)
p1
->
AddKnownClosedDoor
(
info
.
first
,
info
.
second
.
GetTime
());
p2
->
AddKnownClosedDoor
(
info
.
first
,
info
.
second
.
GetTime
());
}
return
true
;
}
bool
EventManager
::
MergeKnowledge
(
Pedestrian
*
p1
,
Pedestrian
*
p2
)
{
auto
const
&
old_info1
=
p1
->
GetKnownledge
();
auto
const
&
old_info2
=
p2
->
GetKnownledge
();
map
<
int
,
Knowledge
>
merge_info
;
//collect the most recent knowledge
for
(
auto
&&
info1
:
old_info1
)
{
merge_info
[
info1
.
first
]
=
info1
.
second
;
}
for
(
auto
&&
info2
:
old_info2
)
{
//update infos according to a newest time
if
(
merge_info
.
count
(
info2
.
first
)
>
0
)
{
if
(
info2
.
second
.
GetTime
()
>
merge_info
[
info2
.
first
].
GetTime
())
{
merge_info
[
info2
.
first
]
=
info2
.
second
;
}
}
else
//the info was not present, just add
{
merge_info
[
info2
.
first
]
=
info2
.
second
;
}
}
//synchronize the knowledge
//accept the information with a certain probability
//cout<<_rdDistribution(_rdGenerator)<<endl;
if
(
_rdDistribution
(
_rdGenerator
)
<
(
1
-
p1
->
GetRiskTolerance
()))
{
//p1->ClearKnowledge();
p2
->
ClearKnowledge
();
for
(
auto
&&
info
:
merge_info
)
{
//p1->AddKnownClosedDoor(info.first, info.second.GetTime());
p2
->
AddKnownClosedDoor
(
info
.
first
,
info
.
second
.
GetTime
());
}
//p2->SetSpotlight(false);
return
true
;
}
else
{
cout
<<
"refusing the information:"
<<
p2
->
GetID
()
<<
endl
;
//Pedestrian::SetColorMode(BY_SPOTLIGHT);
//p2->SetSpotlight(true);
//exit(0);
return
false
;
}
}
void
EventManager
::
ProcessEvent
()
...
...
@@ -376,7 +426,7 @@ void EventManager::ProcessEvent()
UpdateAgentKnowledge
(
_building
);
//actualize based on the new knowledge
_lastUpdateTime
=
current_time
;
cout
<<
"updating..."
<<
current_time
<<
endl
<<
endl
;
//
cout<<"updating..."<<current_time<<endl<<endl;
}
//update the building state
...
...
@@ -403,9 +453,6 @@ void EventManager::ProcessEvent()
/***************
Event handling
**************/
//close the door if it was open and relaunch the routing procedure
void
EventManager
::
CloseDoor
(
int
id
)
{
...
...
events/EventManager.h
View file @
9f4cd6cf
...
...
@@ -27,6 +27,7 @@
#include <vector>
#include <string>
#include <random>
class
Building
;
class
Router
;
...
...
@@ -101,13 +102,23 @@ private:
bool
UpdateAgentKnowledge
(
Building
*
_b
);
/**
*
Merg
e the knowledge of the two pedestrians.
*
Synchroniz
e the knowledge of the two pedestrians.
* The information with the newest timestamp
* is always accepted with a probability of one.
* @param p1, first pedestrian
* @param p2, second pedestrian
* @return true if the information could be synchronized
*/
void
MergeKnowledge
(
Pedestrian
*
p1
,
Pedestrian
*
p2
);
bool
SynchronizeKnowledge
(
Pedestrian
*
p1
,
Pedestrian
*
p2
);
/**
* Merge the knowledge of the two pedestrians. Ped1 is informing ped2 who depending
* on his risk awareness probability could accept of refuse the new information.
* @param p1, the informant with the new information
* @param p2, the pedestrian receiving the information
* @return true in the case p2 accepted the new information
*/
bool
MergeKnowledge
(
Pedestrian
*
p1
,
Pedestrian
*
p2
);
/**
* Update the pedestrian route based on the new information
...
...
@@ -136,4 +147,8 @@ private:
//save the available routers defined in the simulation
std
::
vector
<
RoutingStrategy
>
_availableRouters
;
// random number generator
std
::
mt19937
_rdGenerator
;
std
::
uniform_real_distribution
<
double
>
_rdDistribution
;
// std::uniform_real_distribution<double> d(0, 1);
};
pedestrian/Knowledge.cpp
View file @
9f4cd6cf
...
...
@@ -44,7 +44,7 @@ Knowledge::~Knowledge()
void
Knowledge
::
Dump
()
{
Log
->
Write
(
"INFO:
\t
door [%d] state [%d] since [%f]"
,
_id
,
_isClosed
,
_time
);
Log
->
Write
(
"INFO:
\t
door [%d] state [%d] since [%f]
\n
"
,
_id
,
_isClosed
,
_time
);
}
void
Knowledge
::
SetState
(
int
id
,
bool
is_closed
,
double
time
)
...
...
pedestrian/Knowledge.h
View file @
9f4cd6cf
...
...
@@ -58,6 +58,8 @@ private:
bool
_isClosed
;
/// id of the door
int
_id
;
/// whether I already accepted or refused that information
bool
_refusedOnce
;
};
#endif
/* KNOWLEDGE_H_ */
...
...
pedestrian/Pedestrian.cpp
View file @
9f4cd6cf
...
...
@@ -934,6 +934,7 @@ int Pedestrian::GetColor()
case
BY_KNOWLEDGE
:
{
key
=
GetKnowledgeAsString
();
if
(
key
.
empty
())
return
-
1
;
}
break
;
...
...
pedestrian/Pedestrian.h
View file @
9f4cd6cf
...
...
@@ -204,7 +204,7 @@ public:
int
GetFinalDestination
()
const
;
void
ClearMentalMap
();
// erase the peds memory
// functions for known closed Doors
(needed for the Graphrouting and Rerouting)
// functions for known closed Doors
void
AddKnownClosedDoor
(
int
door
,
double
time
);
// needed for information sharing
const
std
::
map
<
int
,
Knowledge
>&
GetKnownledge
()
const
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment