|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<T>
repast.simphony.context.AbstractContext<T>
repast.simphony.context.SmallDefaultContext<T>
repast.simphony.context.DefaultContext
crowdmodel.agents.Memory
public class Memory
Memory is a main part of the model structure. The main types of the model
structure consists out of a sensor, motor, memory and physiology part.
All there is to describe (behaviour, influences factors, processes,
characteristics etc.) need to be described in either one of the (derived)
main parts of the model structure
Memory: describes the functional part of the model structure This is
where behaviour is chosen and (mainly) is influenced. Memory consists out
of memoryElements that represent the knowledge (goals, facts & rules)
TODO (check: does the term knowledge capture all the content of the
memory?)
The memory exists only in an agent, this is why it is not an CObject and not
a part of the overall context. Memory is a context on its own, in which the memory
elements are the members of the context and a projection describes their
underlying relationship (in an association network)
The elements stored in memory are stored in a Map. Which makes them callable by name.
This is different from the usual context in which this is stored in a Collection.
To be able to work with this I overloaded some functions:
Fields inherited from class repast.simphony.context.SmallDefaultContext |
---|
allObjs, objectMap |
Fields inherited from class repast.simphony.context.AbstractContext |
---|
subContexts |
Fields inherited from interface repast.simphony.context.Context |
---|
SYN_CONTEXT_PREFIX |
Constructor Summary | |
---|---|
Memory()
The memory constructor initialises memory by creating goals, other memory elements, and their associations |
Method Summary | |
---|---|
boolean |
add(MemoryElement element)
This function overloads the general add function that is specified in Collection and (overridden by Context) The elements of Memory are collected within a Map instead of a Collection. |
boolean |
contains(MemoryElement me)
Function that checks whether a MemoryElement is stored in Memory This overloads the contains function of AbstractContext, which isn't suitable here as an abstractContext stores its objects in a Collections, whereas we do so in a Map. |
java.lang.Boolean |
contains(java.lang.String eName)
Returns whether memory has this element This is an overloading function. |
void |
createBehaviours()
Creates the internal representation of a behaviour (= a behaviourRule) There are 3 general types of behaviour: locomotion, manipulation and communication |
void |
createFacts()
Creates the facts an individual has in its memory There are 3 types of facts: behaviour, person, (event) facts |
private void |
createGoals()
Creates the goals an individual has in its memory. |
BehaviourRule |
getBehaviour(java.lang.String name)
Returns the behaviourRule given a name |
BehaviourFact |
getBehaviourFact(java.lang.String bName)
Returns the behaviourFact corresponding to a behaviour name. |
Goal |
getDomGoal()
Returns the dominant goal that is currently dominant and influencing behaviour in the cognitive system. |
MemoryElement |
getElement(java.lang.String eName)
Returns an element from memory based on its name In naming elements we distinct betwee |
java.util.ArrayList<PersonFact> |
getFriends()
Returns the friends an individual has. |
Goal |
getIdentity()
Returns the identity goal |
double |
getIDPref()
|
java.util.Iterator |
getIterator()
Function that returns an iterator of all MemoryElements in Memory. |
java.util.ArrayList<PersonFact> |
getLeaders()
Returns the agent this agent perceives as a leader |
java.util.HashMap<java.lang.String,MemoryElement> |
getMemoryElements()
Returns the HashMap in which all the memoryElements are stored |
java.lang.String |
getNamesMemoryElements()
|
BehaviourRule |
getNextActiveB()
Returns the next most active behaviour. |
double |
getSafePref()
|
Goal |
getSafety()
Returns the safety goal |
Goal |
getSocial()
Returns the social goal |
double |
getSocialPref()
|
Goal |
getSubsistence()
Returns the subsistence goal |
double |
getSubsPref()
|
double |
getTime()
Returns the internal time an agent has to select a behaviour |
boolean |
hasNextB()
Returns whether there is a next active behaviour in memory left |
void |
initSubs(double initVal)
|
boolean |
remove(MemoryElement element)
This function overloads the general remove function that is specified in Collection and (overridden by Context) The elements of Memory are collected within a Map instead of a Collection. |
void |
setBehaviourIterator()
Sets the iterator that returns behaviours in order of their current activation level As this is a class variable, it needs to be set before starting to compare behaviours as during comparing the iterator while first return the highest activation, then the second highest, etc. |
void |
setDomGoal()
Sets d_domGoal with the most dominant goal for the given time There is a order of importance when the dominance values are identical then the goals become dominant in the order of: safety, subsistence, social (i doubt about the order of the last two in our setting) |
void |
setElementsWithAgentAndMemory()
Sets for all memoryElements that they belong to which memory and corresponding agent. |
void |
setMyLeaders(java.util.HashSet<CrowdAgent> leaders)
Sets in memory which agents this agent perceives as a leader NOTE: need to change this structure, PersonFacts need to be in one set, not separate for friends and leaders |
void |
setSocialScenario(repast.simphony.space.graph.Network socNetwork)
Function sets the scenario in the memory of an agent This incorporates an individual having friends by having a personFact for each one of them |
void |
setThisAgent(CrowdAgent thisAgent)
Sets the Agent to whom this memory belongs This allows for the 'direct' access of methods/vars concerning memory by the functions in Memory; The function checks whether this has already been assigned, at this is only done once while initialising. |
protected void |
setTime(double time)
Sets the internal time an agent has, to select a behaviour |
void |
setupAssociations()
Creates the links between the memory element with a certain initial association value Now I directly connected behaviourRules with behaviourFacts. |
void |
step()
The step function defines what an agent does internally every simulation step/tick. |
void |
updateBehaviourOrdering(BehaviourRule b)
This function is called when one of the behaviourRules activation has been changed. |
Methods inherited from class repast.simphony.context.DefaultContext |
---|
addInternal, containsInternal, iteratorInternal, removeInternal, sizeInternal |
Methods inherited from class repast.simphony.context.SmallDefaultContext |
---|
getObjects, getRandomObject, getRandomObjects |
Methods inherited from class repast.simphony.context.AbstractContext |
---|
add, addContextListener, addProjection, addSubContext, addValueLayer, clear, contains, eventOccured, findContext, findParent, fireAddContextEvent, fireRemoveEvent, fireSubContextAdded, fireSubContextRemoved, getAgentLayer, getAgentTypes, getContextListeners, getId, getProjection, getProjection, getProjections, getProjections, getSubContext, getSubContexts, getTypeID, getValueLayer, getValueLayers, handleRemove, iterator, query, remove, removeContextListener, removeProjection, removeSubContext, removeValueLayer, setId, setTypeID, size |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
addAll, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray |
Field Detail |
---|
private CrowdAgent d_thisAgent
private boolean d_thisAgentFlag
private repast.simphony.space.graph.Network<MemoryElement> d_associations
private java.util.HashMap<java.lang.String,MemoryElement> d_memoryMap
private java.util.HashMap<java.lang.String,BehaviourFact> d_behaviourFacts
private java.util.HashMap<java.lang.String,PersonFact> d_hashFriends
private java.util.LinkedList<BehaviourRule> d_orderedBehaviours
private java.util.ArrayList<PersonFact> d_friends
private java.util.ArrayList<PersonFact> d_leaders
private java.util.ArrayList<PersonFact> d_persons
private java.util.Iterator<BehaviourRule> d_behaviours
private double d_time
private Goal d_domGoal
private java.util.Random d_rng
private Goal d_identity
private Goal d_social
private Goal d_safety
private Goal d_subsistence
private Goal d_empty
protected LocomotionRule d_walk
protected LocomotionRule d_run
protected LocomotionRule d_dance
protected LocomotionRule d_sitDown
protected LocomotionRule d_standUp
protected LocomotionRule d_kneel
protected LocomotionRule d_lieDown
private BehaviourRule d_other
private BehaviourRule d_nothing
private BehaviourFact d_otherExp
private BehaviourFact d_nothingExp
private BehaviourFact d_walkExp
private BehaviourFact d_runExp
private BehaviourFact d_danceExp
private BehaviourFact d_sitExp
private BehaviourFact d_standExp
private BehaviourFact d_kneelExp
private BehaviourFact d_lieExp
private PersonFact d_self
private PersonFact d_ingroup
private PersonFact d_outgroup
private PersonFact d_unknown
Constructor Detail |
---|
public Memory()
Method Detail |
---|
public boolean add(MemoryElement element)
name
- element
-
public boolean remove(MemoryElement element)
name
- element
-
public boolean contains(MemoryElement me)
me
-
public java.util.Iterator getIterator()
public void step()
public void setThisAgent(CrowdAgent thisAgent)
thisAgent
- public void setElementsWithAgentAndMemory()
thisAgent
- public void setSocialScenario(repast.simphony.space.graph.Network socNetwork)
public void setMyLeaders(java.util.HashSet<CrowdAgent> leaders)
private void createGoals()
public void initSubs(double initVal)
public void createFacts()
public void createBehaviours()
public void setDomGoal()
public void setupAssociations()
public double getTime()
protected void setTime(double time)
time
- public Goal getDomGoal()
public Goal getIdentity()
public Goal getSocial()
public Goal getSafety()
public Goal getSubsistence()
public java.util.HashMap<java.lang.String,MemoryElement> getMemoryElements()
public java.lang.String getNamesMemoryElements()
public BehaviourFact getBehaviourFact(java.lang.String bName)
public java.util.ArrayList<PersonFact> getFriends()
public java.util.ArrayList<PersonFact> getLeaders()
public void setBehaviourIterator()
public BehaviourRule getNextActiveB()
public boolean hasNextB()
public BehaviourRule getBehaviour(java.lang.String name)
name
-
public MemoryElement getElement(java.lang.String eName)
eName
-
public java.lang.Boolean contains(java.lang.String eName)
eName
-
public void updateBehaviourOrdering(BehaviourRule b)
b
- public double getIDPref()
public double getSocialPref()
public double getSafePref()
public double getSubsPref()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |