model.interactionmemory module¶
Module that holds classes that represent an agent’s memory of interactions.
-
class
model.interactionmemory.HomeostaticInteractionMemory(agent, boredom_handler=<class 'model.boredomhandler.RepetitiveBoredomHandler'>)¶ Bases:
model.interactionmemory.InteractionMemoryA homeostatic interaction’s valence is a function of the agent’s internal energy level. Thus, this interaction memory keeps track of the agent to be able to compute the valence.
-
get_valence(interaction_, process_boredom=False)¶ Get the valence of an interaction. If the interaction is a primative, get its valence. If the interaction is composite, sum the valences of its primitives.
The valences are functions of the agent’s internal energy levels.
Parameters: interaction – The interaction to get the valence of.
-
to_json()¶
-
-
class
model.interactionmemory.InteractionMemory(boredom_handler=<class 'model.boredomhandler.RepetitiveBoredomHandler'>)¶ Bases:
objectClass to represent the interaction memory of an agent.
-
INTERACTION_ENACTION_HISTORY_SIZE= 50¶
-
add_alternative_interaction(interaction_, alternative_interaction)¶ Add an alternative interaction to an interaction in the interaction memory.
Parameters: - interaction – The interaction to add an alternative to.
- alternative_interaction – The alternative interaction to add to the interaction.
Returns: True if the alternative was added, false if it was already registered to the interaction
-
add_interaction(interaction_, weight=1, valence=0)¶ Add an interaction to the interaction memory.
Parameters: - interaction – The interaction to add.
- weight – The weight of the interaction.
- valence – The valence of the interaction, only used for primitive interactions.
-
add_interaction_to_history(interaction_)¶ Add an interaction to the interaction history.
Parameters: interaction – The interaction to add
-
find_interaction_by_name_and_result(name, result='Succeed')¶
-
get_all_interactions()¶
-
get_alternative_interactions(interaction_)¶ Get the alternative interactions for an interaction.
Parameters: interaction – The interaction to get the alternatives for. Returns: A list of alternative interactions registered to an interaction.
-
get_composite_interactions()¶
-
get_interaction_history()¶ Get the interaction history.
Returns: The interaction history
-
get_primitive_interactions()¶
-
get_proclivity(interaction)¶ Get the proclivity of an interaction. Proclivity is defined as the valence multiplied by the weight.
Parameters: interaction – The interaction to get the proclivity of.
-
get_total_weight()¶ Get the sum of weights of all known interactions.
Returns: The sum of weights of all known interactions.
-
get_valence(interaction_, process_boredom=False)¶ Get the valence of an interaction. If the interaction is a primative, get its valence. If the interaction is composite, sum the valences of its primitives.
Parameters: interaction – The interaction to get the valence of.
-
get_weight(interaction)¶ Get the weight of an interaction.
Parameters: interaction – The interaction to get the weight of.
-
increment_weight(interaction)¶ Increment the weight of an interaction.
Parameters: interaction – The interaction to increment the weight of.
-
set_valence(interaction_, valence)¶ Set the valence of an interaction to a specific value.
Parameters: - interaction – The interaction to set the valence of.
- valence – The value to set the interaction’s valence to.
-
set_weight(interaction, weight)¶ Set the weight of an interaction to a specific value.
Parameters: - interaction – The interaction to set the weight of.
- weight – The value to set the interaction’s weight to.
-
to_json()¶
-