Construct version 5.4.4
An agent based modeling framework
KnowledgeTransactiveMemory Class Reference

A variation on the Standard Interaction Model utilizing transactive memory for knowledge. More...

Inheritance diagram for KnowledgeTransactiveMemory:
Collaboration diagram for KnowledgeTransactiveMemory:

Public Member Functions

 KnowledgeTransactiveMemory (const dynet::ParameterMap &parameters, Construct &construct)
 
void initialize (void) override
 Checks for model exclusivity requirements and calls StandardInteraction::initialize More...
 
void communicate (const InteractionMessage &msg) override
 Parses knowledge transactive memory items similar to KnowledgeParsing::communicate, but uses the alter index in the item rather than InteractionMessage::sender. More...
 
void cleanup () override
 Calls update_group_knowledge. More...
 
std::vector< InteractionItemget_interaction_items (unsigned int sndr, unsigned int recv, const CommunicationMedium *comm) override
 Calls StandardInteraction::get_interaction_items and then adds to it knowledge transactive memory items. More...
 
float get_k_sim (unsigned int agent_i, unsigned int agent_j) override
 Replaces StandardInteraction::get_k_sim by using the initiating agent's transactive memory. More...
 
float get_k_exp (unsigned int agent_i, unsigned int agent_j) override
 Replaces StandardInteraction::get_k_exp by using the initiating agent's transactive memory. More...
 
virtual void update_group_knowledge (void)
 Updates generalized_other_beliefs after each agent's beliefs are updated.
 
- Public Member Functions inherited from StandardInteraction
 StandardInteraction (const dynet::ParameterMap &parameters, Construct &construct)
 Sets the optional rejection limit, initializes the CommunicationMedium vector, and checks for the agent attributes "can send knowledge" and "can receive knowledge".
 
virtual void initialize (void) override
 Adds the KnowledgeParsing Model to the model manager. More...
 
virtual void think (void) override
 Updates StandardInteraction::send_msg_queue using StandardInteraction::update_send_msg_queue, uses StandardInteraction::set_probabilities to update StandardInteraction::interaction_prob, and creates messages using StandardInteraction::add_messages. More...
 
void initialize_communication_mediums ()
 Fills in StandardInteraction with information from the medium nodeset.
 
virtual void set_probabilities (void)
 An agent's probabilities in StandardInteraction::interaction_prob are only calculated if their corresponding entry in StandardInteraction::agent_active is true and their corresponding entry in StandardInteraction::agent_initiation_count is greater than zero. Each receiving agent in interaction_prob is only calculated if they are in the initiating agent's sphere of influence (StandardInteraction::soi), the corresponding entry for the receving agent in StandardInteraction::agent_reception_count is greater than zero, the receiving agent is also active (StandardInteraction::agent_active), and the initiating and receiving agent have a shared communication medium they have access to. Once these conditions are met, StandardInteraction::set_interaction_probability is called on the index pair.
 
virtual void add_messages (void)
 Creates a list of possible initiators and receivers of interactions using StandardInteraction::initialize_interaction_lists. StandardInteraction::get_interaction_pair_index is then used to select an interaction pair which depends on StandardInteraction::interaction_prob and has the limit that any pair can only interact once each time period. The interaction pair is then rejected if they do not share any common communication medium or neither can exchange knowledge with the other. If the number of rejections equals StandardInteraction::interaction_rejection_limit, no more messages are created and the function ends. If the interaction pair is accepted, StandardInteraction::get_interaction_items is called for both combinations of sender and receiver. Each item is then passed through Construct::intercept and removed if the function returns true.
 
virtual void set_interaction_probability (unsigned int agent_i, unsigned int agent_j)
 Sets the corresponding element in StandardInteraction::interaction_prob based on StandardInteraction::get_k_sim weighted by agent_i's row in StandardInteraction::knowledge_sim_weight, StandardInteraction::get_k_exp weighted by agent_i's row in StandardInteraction::knowledge_exp_weight, StandardInteraction::get_prox, and StandardInteraction::get_additions. An assertion is raised if the calculated probability weight is negative.
 
virtual void update_send_msg_queue ()
 Decrements each message's time_to_send in StandardInteraction::send_msg_queue. If a message has a time_to_send value of zero, it is removed from StandardInteraction::send_msg_queue and added to Construct::interaction_message_queue.
 
void initialize_interaction_lists (std::vector< std::pair< unsigned int, unsigned int > > &initiators, std::vector< std::pair< unsigned int, unsigned int > > &receivers)
 Builds an initiators and receivers list of agents. The first index contains the agent's index, while the second index contains the corresponding entry in StandardInteraction::agent_initiation_count for initiators and StandardInteraction::agent_reception_count for receivers. Agents are only added to the lists if they are active in StandardInteraction::agent_active_time.
 
std::pair< unsigned int, unsigned int > get_interaction_pair_index (std::vector< std::pair< unsigned int, unsigned int > > &initiators, std::vector< std::pair< unsigned int, unsigned int > > &receivers)
 Using the initiator and receivers list an interaction pair is selected. An initiator is selected at random, and a receiver is selected based on StandardInteraction::interaction_prob and only if the initiator, receiver pair has not yet interacted via StandardInteraction::interaction. If the initiator has no possible receivers, it is removed from the initiators list. If the initiator list is empty the pair (0,0) is returned.
 
const CommunicationMediumget_comm_medium (unsigned int sender_index, unsigned int receiver_index)
 Returns a pointer to a communication medium that both agent's have access to via StandardInteraction::comm_access. The medium chosen is randomly selected with a probability distribution from StandardInteraction::comm_medium_pref.
 
virtual float get_prox (unsigned int sender_index, unsigned int receiver_index)
 Combines the proximity networks with the sender_index's entry in the proximity weight networks. The three types of proximity are physical, social, and demographic.
 
virtual float get_k_sim (unsigned int sender_index, unsigned int receiver_index)
 Obtains the set of knowledge that intersects both agent's respective rows in StandardInteraction::knowledge_net. Each index in the set is weighted by the sender_index's row in StandardInteraction::knowledge_importance and summed. More...
 
virtual float get_k_exp (unsigned int sender_index, unsigned int receiver_index)
 Obtains the set of knowledge that intersects both the sender_index's complement row in StandardInteraction::knowledge_net and the receiver_index's row in the same. Each index in the set is weighted by the sender_index's row in StandardInteraction::knowledge_importance and summed. More...
 
virtual float get_additions (unsigned int sender_index, unsigned int receiver_index)
 Virtual function that allows inherited models to add values to probability weights independent of knowledge or proximity. More...
 
virtual std::vector< InteractionItemget_interaction_items (unsigned int sender, unsigned int receiver, const CommunicationMedium *comm)
 Compiles InteractionItems that can be added to an InteractionMessage from the sender agent to the receiving agent using the comm medium. Knowledge items are only added if the sender has the node attribute "can send knowledge" set to true and the receiver has the node attribute "can receive knowledge" set to true. The number of knowledge items that can be added is limited by the sender's row in StandardInteraction::knowledge_message_complexity. Knowledge is randomly selected using the probability weights from the sender's row in StandardInteraction::knowledge_priority_network with the probability weights for the knowledge the sender does not know in StandardInteraction::knowledge_net being set to zero. Additionally the corresponding knowledge indexes that are false in StandardInteraction::medium_knowledge_access for comm's index and StandardInteraction::learnable_knowledge_net for receiver also have their probability weights set to zero. More...
 
- Public Member Functions inherited from Model
 Model (Construct &_construct)
 Constructor for all models in Construct. More...
 
virtual ~Model (void)
 Virtual Deconstructor. More...
 
virtual void initialize (void)
 Function called once before any simulation cycles begin. More...
 
virtual void think (void)
 First function called in a simulation cycle. More...
 
virtual void update (void)
 Function called after the think functions in a simulation cycle. More...
 
virtual bool intercept (InteractionItem &item, unsigned int sender, unsigned int receiver, const CommunicationMedium *medium)
 Allows for models to effect change to items created by other models. More...
 
virtual void communicate (const InteractionMessage &msg)
 Function called after the update functions in a simulation cycle. More...
 
virtual void cleanup (void)
 Function called after the Model::communicate functions in a simulation cycle. More...
 
void add_base_model_to_model_manager (const std::string &base_model_name)
 Adds a derived model under the name of the base model and disables the model manager from calling its functions.
 

Public Attributes

const Graph< unsigned int > & tmk_message_complexity = graph_manager.load_optional(graph_names::ktm_msg_complex, 1u, agents, sparse, time, sparse)
 
const Graph< bool > * group_membership
 
Graph< float > * group_knowledge
 
Graph< std::vector< bool > > & tmk = graph_manager.load_optional(graph_names::ktm, std::vector<bool>(agents.size(), false), agents, dense, knowledge, sparse)
 
unsigned int group_count
 
std::vector< unsigned int > group_size
 Precaluclates how many agents are in each group. Does not change over time.
 
std::vector< float > generalized_other
 Precalulates the percentage of agents that know a knowledge index. When an agent examines another agent outside their interaction sphere, the corresponding value is used as the probability the agent knows the knowledge index. More...
 
- Public Attributes inherited from StandardInteraction
const Nodesetagents = ns_manager.get_nodeset(nodeset_names::agents)
 
const Nodesetknowledge = ns_manager.get_nodeset(nodeset_names::knowledge)
 
const Nodesetcomm = ns_manager.get_nodeset(nodeset_names::comm)
 
const Nodesettime = ns_manager.get_nodeset(nodeset_names::time)
 
Graph< bool > & knowledge_net = graph_manager.load_required(graph_names::knowledge, agents, knowledge)
 
Graph< bool > & soi = graph_manager.load_optional(graph_names::soi, true, agents, sparse, agents, sparse)
 
const Graph< bool > & agent_active = graph_manager.load_optional(graph_names::active, true, agents, sparse, time, sparse)
 
const Graph< unsigned int > & agent_initiation_count = graph_manager.load_optional(graph_names::init_count, 1u, agents, sparse, time, sparse)
 
const Graph< unsigned int > & agent_reception_count = graph_manager.load_optional(graph_names::recep_count, 1u, agents, sparse, time, sparse)
 
Graph< float > & interaction_prob = graph_manager.load_optional(graph_names::interact_prob, 0.0f, agents, dense, agents, dense)
 
Graph< bool > & interactions = graph_manager.load_optional(graph_names::interact, false, agents, sparse, agents, sparse)
 
const Graph< unsigned int > & knowledge_message_complexity = graph_manager.load_optional(graph_names::k_msg_complex, 1u, agents, sparse, time, sparse)
 
const Graph< float > & knowledge_priority_network = graph_manager.load_optional(graph_names::k_priority, 1.0f, agents, sparse, knowledge, sparse)
 
const Graph< bool > & learnable_knowledge_net = graph_manager.load_optional(graph_names::learnable_k, true, agents, sparse, knowledge, sparse)
 
const Graph< float > & comm_medium_pref = graph_manager.load_optional(graph_names::comm_pref, 1.0f, agents, sparse, comm, sparse)
 
const Graph< bool > & medium_knowledge_access = graph_manager.load_optional(graph_names::medium_k_access, true, comm, sparse, knowledge, sparse)
 
const Graph< bool > & comm_access = graph_manager.load_optional(graph_names::comm_access, true, agents, sparse, comm, sparse)
 
const Graph< float > & physical_prox = graph_manager.load_optional(graph_names::phys_prox, 1.0f, agents, sparse, agents, sparse)
 
const Graph< float > & physical_prox_weight = graph_manager.load_optional(graph_names::phys_prox_wgt, 1.0f, agents, sparse, time, sparse)
 
const Graph< float > & social_prox = graph_manager.load_optional(graph_names::soc_prox, 1.0f, agents, sparse, agents, sparse)
 
const Graph< float > & social_prox_weight = graph_manager.load_optional(graph_names::soc_prox_wgt, 1.0f, agents, sparse, time, sparse)
 
const Graph< float > & socdem_prox = graph_manager.load_optional(graph_names::dem_prox, 1.0f, agents, sparse, agents, sparse)
 
const Graph< float > & socdem_prox_weight = graph_manager.load_optional(graph_names::dem_prox_wgt, 1.0f, agents, sparse, time, sparse)
 
const Graph< float > & knowledge_importance = graph_manager.load_optional(graph_names::interact_k_wgt, 1.0f, agents, sparse, knowledge, sparse)
 
const Graph< float > & knowledge_sim_weight = graph_manager.load_optional(graph_names::k_sim_wgt, 1.0f, agents, sparse, time, sparse)
 
const Graph< float > & knowledge_exp_weight = graph_manager.load_optional(graph_names::k_exp_wgt, 1.0f, agents, sparse, time, sparse)
 
std::list< InteractionMessagesend_msg_queue
 
std::vector< CommunicationMediumcommunication_mediums
 
unsigned int agent_count
 
unsigned int knowledge_count
 
unsigned int interaction_rejection_limit
 
- Public Attributes inherited from Model
Constructconstruct
 
GraphManagergraph_manager
 
NodesetManagerns_manager
 
Randomrandom
 
bool valid
 If member is false, the model's functions are not called.
 

Detailed Description

A variation on the Standard Interaction Model utilizing transactive memory for knowledge.

Member Function Documentation

◆ cleanup()

void KnowledgeTransactiveMemory::cleanup ( void  )
overridevirtual

Calls update_group_knowledge.

Reimplemented from Model.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ communicate()

void KnowledgeTransactiveMemory::communicate ( const InteractionMessage msg)
overridevirtual

Parses knowledge transactive memory items similar to KnowledgeParsing::communicate, but uses the alter index in the item rather than InteractionMessage::sender.

Reimplemented from Model.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_interaction_items()

std::vector< InteractionItem > KnowledgeTransactiveMemory::get_interaction_items ( unsigned int  sndr,
unsigned int  recv,
const CommunicationMedium comm 
)
overridevirtual

Calls StandardInteraction::get_interaction_items and then adds to it knowledge transactive memory items.

Reimplemented from StandardInteraction.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_k_exp()

float KnowledgeTransactiveMemory::get_k_exp ( unsigned int  agent_i,
unsigned int  agent_j 
)
overridevirtual

Replaces StandardInteraction::get_k_exp by using the initiating agent's transactive memory.

Parameters
agent_iInitiating agent whose transactive memory is being used.
agent_jThe agent that would be on the receiving end of a possible interaction.
Returns
The relative expertise using agent_i's transactive memory of agent_j. If agent_j is in agent_i's interaction sphere but is apart of a group, KnowledgeTransactiveMemory::group_knowledge is used for the probability an agent knows a knowledge index. If the agent is not apart of a group, KnowledgeTransactiveMemory::generalized_other is instead used.

Reimplemented from StandardInteraction.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_k_sim()

float KnowledgeTransactiveMemory::get_k_sim ( unsigned int  agent_i,
unsigned int  agent_j 
)
overridevirtual

Replaces StandardInteraction::get_k_sim by using the initiating agent's transactive memory.

Parameters
agent_iInitiating agent whose transactive memory is being used.
agent_jThe agent that would be on the receiving end of a possible interaction.
Returns
The relative similarity using agent_i's transactive memory of agent_j. If agent_j is in agent_i's interaction sphere but is apart of a group, KnowledgeTransactiveMemory::group_knowledge is used for the probability an agent knows a knowledge index. If the agent is not apart of a group, KnowledgeTransactiveMemory::generalized_other is instead used.

Reimplemented from StandardInteraction.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize()

void KnowledgeTransactiveMemory::initialize ( void  )
overridevirtual

Checks for model exclusivity requirements and calls StandardInteraction::initialize

Reimplemented from StandardInteraction.

Here is the call graph for this function:

Member Data Documentation

◆ generalized_other

std::vector<float> KnowledgeTransactiveMemory::generalized_other

Precalulates the percentage of agents that know a knowledge index. When an agent examines another agent outside their interaction sphere, the corresponding value is used as the probability the agent knows the knowledge index.

summary>

◆ group_knowledge

Graph<float>* KnowledgeTransactiveMemory::group_knowledge

summary>

◆ group_membership

const Graph<bool>* KnowledgeTransactiveMemory::group_membership

summary>

◆ tmk

Graph<std::vector<bool> >& KnowledgeTransactiveMemory::tmk = graph_manager.load_optional(graph_names::ktm, std::vector<bool>(agents.size(), false), agents, dense, knowledge, sparse)

summary>

◆ tmk_message_complexity

const Graph<unsigned int>& KnowledgeTransactiveMemory::tmk_message_complexity = graph_manager.load_optional(graph_names::ktm_msg_complex, 1u, agents, sparse, time, sparse)

summary>