Construct version 5.4.3
An agent based modeling framework
StandardInteraction Class Reference

An interaction model that stochastically matches agents based on similarities, knowledge expertise, and proximities. More...

Inheritance diagram for StandardInteraction:
Collaboration diagram for StandardInteraction:

Public Member Functions

 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.
 
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 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 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)
 
InteractionMessageQueue send_msg_queue
 
std::vector< CommunicationMediumcommunication_mediums
 
unsigned int agent_count
 
unsigned int knowledge_count
 
unsigned int interaction_rejection_limit
 
const unsigned int & t
 
- 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

An interaction model that stochastically matches agents based on similarities, knowledge expertise, and proximities.

Member Function Documentation

◆ get_additions()

virtual float StandardInteraction::get_additions ( unsigned int  sender_index,
unsigned int  receiver_index 
)
inlinevirtual

Virtual function that allows inherited models to add values to probability weights independent of knowledge or proximity.

Reimplemented in Beliefs, and GrandInteraction.

Here is the caller graph for this function:

◆ get_interaction_items()

std::vector< InteractionItem > StandardInteraction::get_interaction_items ( unsigned int  sender,
unsigned int  receiver,
const CommunicationMedium comm 
)
virtual

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.

summary>

Reimplemented in GrandInteraction, and KnowledgeTransactiveMemory.

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

◆ get_k_exp()

float StandardInteraction::get_k_exp ( unsigned int  sender_index,
unsigned int  receiver_index 
)
virtual

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.

Reimplemented in KnowledgeTransactiveMemory, Tasks, and GrandInteraction.

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

◆ get_k_sim()

float StandardInteraction::get_k_sim ( unsigned int  sender_index,
unsigned int  receiver_index 
)
virtual

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.

Reimplemented in KnowledgeTransactiveMemory, and GrandInteraction.

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

◆ initialize()

void StandardInteraction::initialize ( void  )
overridevirtual

Adds the KnowledgeParsing Model to the model manager.

Reimplemented from Model.

Reimplemented in Beliefs, GrandInteraction, KnowledgeTransactiveMemory, and Tasks.

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

◆ think()

void StandardInteraction::think ( void  )
overridevirtual

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.

Reimplemented from Model.

Here is the call graph for this function:

Member Data Documentation

◆ agent_active

const Graph<bool>& StandardInteraction::agent_active = graph_manager.load_optional(graph_names::active, true, agents, sparse, time, sparse)

summary>

◆ agent_count

unsigned int StandardInteraction::agent_count

summary>

◆ agent_initiation_count

const Graph<unsigned int>& StandardInteraction::agent_initiation_count = graph_manager.load_optional(graph_names::init_count, 1u, agents, sparse, time, sparse)

summary>

◆ agents

const Nodeset& StandardInteraction::agents = ns_manager.get_nodeset(nodeset_names::agents)

summary>

◆ comm

const Nodeset& StandardInteraction::comm = ns_manager.get_nodeset(nodeset_names::comm)

summary>

◆ comm_medium_pref

const Graph<float>& StandardInteraction::comm_medium_pref = graph_manager.load_optional(graph_names::comm_pref, 1.0f, agents, sparse, comm, sparse)

summary>

◆ communication_mediums

std::vector<CommunicationMedium> StandardInteraction::communication_mediums

summary>

◆ interaction_prob

Graph<float>& StandardInteraction::interaction_prob = graph_manager.load_optional(graph_names::interact_prob, 0.0f, agents, dense, agents, dense)

summary>

◆ interaction_rejection_limit

unsigned int StandardInteraction::interaction_rejection_limit

summary>

◆ knowledge

const Nodeset& StandardInteraction::knowledge = ns_manager.get_nodeset(nodeset_names::knowledge)

summary>

◆ knowledge_count

unsigned int StandardInteraction::knowledge_count

summary>

◆ knowledge_exp_weight

const Graph<float>& StandardInteraction::knowledge_exp_weight = graph_manager.load_optional(graph_names::k_exp_wgt, 1.0f, agents, sparse, time, sparse)

summary>

◆ knowledge_importance

const Graph<float>& StandardInteraction::knowledge_importance = graph_manager.load_optional(graph_names::interact_k_wgt, 1.0f, agents, sparse, knowledge, sparse)

summary>

◆ knowledge_message_complexity

const Graph<unsigned int>& StandardInteraction::knowledge_message_complexity = graph_manager.load_optional(graph_names::k_msg_complex, 1u, agents, sparse, time, sparse)

summary>

◆ knowledge_priority_network

const Graph<float>& StandardInteraction::knowledge_priority_network = graph_manager.load_optional(graph_names::k_priority, 1.0f, agents, sparse, knowledge, sparse)

summary>

◆ knowledge_sim_weight

const Graph<float>& StandardInteraction::knowledge_sim_weight = graph_manager.load_optional(graph_names::k_sim_wgt, 1.0f, agents, sparse, time, sparse)

summary>

◆ learnable_knowledge_net

const Graph<bool>& StandardInteraction::learnable_knowledge_net = graph_manager.load_optional(graph_names::learnable_k, true, agents, sparse, knowledge, sparse)

summary>

◆ medium_knowledge_access

const Graph<bool>& StandardInteraction::medium_knowledge_access = graph_manager.load_optional(graph_names::medium_k_access, true, comm, sparse, knowledge, sparse)

summary>

◆ physical_prox

const Graph<float>& StandardInteraction::physical_prox = graph_manager.load_optional(graph_names::phys_prox, 1.0f, agents, sparse, agents, sparse)

summary>

◆ physical_prox_weight

const Graph<float>& StandardInteraction::physical_prox_weight = graph_manager.load_optional(graph_names::phys_prox_wgt, 1.0f, agents, sparse, time, sparse)

summary>

◆ send_msg_queue

InteractionMessageQueue StandardInteraction::send_msg_queue

summary>

◆ socdem_prox

const Graph<float>& StandardInteraction::socdem_prox = graph_manager.load_optional(graph_names::dem_prox, 1.0f, agents, sparse, agents, sparse)

summary>

◆ social_prox

const Graph<float>& StandardInteraction::social_prox = graph_manager.load_optional(graph_names::soc_prox, 1.0f, agents, sparse, agents, sparse)

summary>

◆ social_prox_weight

const Graph<float>& StandardInteraction::social_prox_weight = graph_manager.load_optional(graph_names::soc_prox_wgt, 1.0f, agents, sparse, time, sparse)

summary>

◆ soi

Graph<bool>& StandardInteraction::soi = graph_manager.load_optional(graph_names::soi, true, agents, sparse, agents, sparse)

summary>