Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
f4e67a7e
Commit
f4e67a7e
authored
Jan 18, 2020
by
Benedikt Kleinmeier
Browse files
Implemented "SimpleCognitionModel" and documented existing cognition models
parent
ffeeb4f3
Changes
4
Hide whitespace changes
Inline
Side-by-side
VadereSimulator/src/org/vadere/simulator/control/psychology/cognition/CooperativeCognitionModel.java
View file @
f4e67a7e
...
...
@@ -7,6 +7,15 @@ import org.vadere.state.simulation.FootstepHistory;
import
java.util.Collection
;
/**
* The {@link CooperativeCognitionModel} makes a pedestrian cooperative if its
* average speed falls below a certain threshold. I.e., usually the agent
* could not move for some time steps. For example, in case of other
* counter-flowing agents.
*
* {@link SelfCategory#COOPERATIVE} should motivate pedestrians to swap places
* instead of blindly walking to a target and colliding with other pedestrians.
*/
public
class
CooperativeCognitionModel
implements
ICognitionModel
{
private
Topography
topography
;
...
...
@@ -19,7 +28,7 @@ public class CooperativeCognitionModel implements ICognitionModel {
@Override
public
void
update
(
Collection
<
Pedestrian
>
pedestrians
)
{
for
(
Pedestrian
pedestrian
:
pedestrians
)
{
// TODO: Maybe, add following variables as attribute to new class "AttributesCognition".
// TODO: Maybe, add following variables as attribute
s
to new class "AttributesCognition".
int
requiredFootSteps
=
2
;
double
requiredSpeedInMetersPerSecondToBeCooperative
=
0.05
;
...
...
VadereSimulator/src/org/vadere/simulator/control/psychology/cognition/ICognitionModel.java
View file @
f4e67a7e
...
...
@@ -20,7 +20,7 @@ import java.util.Collection;
* different scenarios (by specifying in the JSON file).
*
* The <code>initialize</code> method must be called before usage!
* This interface defines
a
callbacks for the simulation loop.
* This interface defines callbacks for the simulation loop.
* It's implementations define the major part of the simulation model's logic.
*
* This approach is similar to the {@link Model} interface for locomotion models.
...
...
@@ -28,8 +28,8 @@ import java.util.Collection;
* Watch out: The perception phase should be finished before using
* methods in this class because, usually, first a stimulus is processed and
* then pedestrians decide which behavior to follow. E.g., first a {@link Threat}
*
occurs
and then a pedestrian decides to follow a
{@link SelfCategory#TARGET_ORIENTED}
* behavior.
*
is recognized
and then a pedestrian decides to follow a
*
{@link SelfCategory#INSIDE_THREAT_AREA}
behavior.
*/
public
interface
ICognitionModel
{
...
...
VadereSimulator/src/org/vadere/simulator/control/psychology/cognition/SimpleCognitionModel.java
0 → 100644
View file @
f4e67a7e
package
org.vadere.simulator.control.psychology.cognition
;
import
org.vadere.state.psychology.cognition.SelfCategory
;
import
org.vadere.state.psychology.perception.types.*
;
import
org.vadere.state.scenario.Pedestrian
;
import
org.vadere.state.scenario.Topography
;
import
java.util.Collection
;
/**
* The {@link SimpleCognitionModel} just passes the perceived stimulus to the
* behavioral/locomotion layer without further processing.
*/
public
class
SimpleCognitionModel
implements
ICognitionModel
{
private
Topography
topography
;
@Override
public
void
initialize
(
Topography
topography
)
{
this
.
topography
=
topography
;
}
@Override
public
void
update
(
Collection
<
Pedestrian
>
pedestrians
)
{
for
(
Pedestrian
pedestrian
:
pedestrians
)
{
Stimulus
stimulus
=
pedestrian
.
getMostImportantStimulus
();
SelfCategory
nextSelfCategory
;
if
(
stimulus
instanceof
ChangeTarget
)
{
nextSelfCategory
=
SelfCategory
.
CHANGE_TARGET
;
}
else
if
(
stimulus
instanceof
Threat
)
{
nextSelfCategory
=
SelfCategory
.
INSIDE_THREAT_AREA
;
}
else
if
(
stimulus
instanceof
Wait
||
stimulus
instanceof
WaitInArea
)
{
nextSelfCategory
=
SelfCategory
.
WAIT
;
}
else
if
(
stimulus
instanceof
ElapsedTime
)
{
nextSelfCategory
=
SelfCategory
.
TARGET_ORIENTED
;
}
else
{
throw
new
IllegalArgumentException
(
String
.
format
(
"Stimulus \"%s\" not supported by \"%s\""
,
stimulus
.
getClass
().
getSimpleName
(),
this
.
getClass
().
getSimpleName
()));
}
pedestrian
.
setSelfCategory
(
nextSelfCategory
);
}
}
}
VadereSimulator/src/org/vadere/simulator/control/psychology/cognition/ThreatCognitionModel.java
View file @
f4e67a7e
...
...
@@ -2,9 +2,9 @@ package org.vadere.simulator.control.psychology.cognition;
import
org.vadere.state.psychology.cognition.GroupMembership
;
import
org.vadere.state.psychology.cognition.SelfCategory
;
import
org.vadere.state.psychology.perception.types.Threat
;
import
org.vadere.state.psychology.perception.types.ElapsedTime
;
import
org.vadere.state.psychology.perception.types.Stimulus
;
import
org.vadere.state.psychology.perception.types.Threat
;
import
org.vadere.state.scenario.Pedestrian
;
import
org.vadere.state.scenario.Topography
;
import
org.vadere.util.geometry.shapes.VPoint
;
...
...
@@ -20,7 +20,7 @@ import java.util.stream.Collectors;
* <ol>
* <li>Is pedestrian inside threat area.</li>
* <li>Is pedestrian outside threat area.</li>
* <li>If pedestrian outside threat area, test if other pedestrians are nearby
* <li>If pedestrian
is
outside threat area, test if other pedestrians are nearby
* who have perceived the threat. If so, imitate their behavior if they are in-group members.</li>
* </ol>
*/
...
...
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