Construct version 5.4.4
An agent based modeling framework
|
A variation on the Standard Interaction Model . More...
Public Member Functions | |
GrandInteraction (const dynet::ParameterMap ¶meters, Construct &construct) | |
void | initialize (void) override |
Checks for mutually exclusive models and then calls StandardInteraction::intialize. More... | |
void | communicate (const InteractionMessage &msg) override |
If knowledge transactive memory is enabled, TMK->communicate is called. If belief transactive memory is enabled, beliefs and belief transactive memory items are parsed. More... | |
void | cleanup (void) override |
Calls the cleanup functions of models if they're enabled. If belief transactive memory is enabled, beliefs calculations are modified to include belief transactive memory. More... | |
float | get_k_sim (unsigned int initiator, unsigned int receiver) override |
Uses TMK->get_k_sim, TASK->get_k_sim, a combination if both are enabled, or StandardInteraction::get_k_exp otherwise. More... | |
float | get_k_exp (unsigned int initiator, unsigned int receiver) override |
Uses TMK->get_k_exp, TASK->get_k_exp, a combination if both are enabled, or StandardInteraction::get_k_exp otherwise. More... | |
float | get_belief_sim (unsigned int initiator, unsigned int receiver) |
If belief transactive memory is enabled, that is used to calculate the similarity. Otherwise BM->get_belief_sim is used. | |
float | get_additions (unsigned int agent_i, unsigned int agent_j) override |
If beliefs are enabled get_belief_sim is multiplied by agent_i's row in belief_sim_weight. More... | |
std::vector< InteractionItem > | get_interaction_items (unsigned int initiator, unsigned int receiver, const CommunicationMedium *comm) override |
If knowledge transactive memory is enabled, TMK->get_interaction_items is used otherwise StandardInteraction::get_interaction_items is used. If belief transactive memory is enabled, belief and belief transactive memory items are added. More... | |
virtual void | update_group_belief (void) |
Updates generalized_other_beliefs after each agent's beliefs are updated. | |
Public Member Functions inherited from StandardInteraction | |
StandardInteraction (const dynet::ParameterMap ¶meters, 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 CommunicationMedium * | get_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< InteractionItem > | get_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 | |
KnowledgeTransactiveMemory * | TMK = 0 |
Pointer to a Knowledge Transactive Memory Interaction Model. Model isn't held in ModelManager. If pointer is NULL, knowledge transactive memory has been disabled for this model. | |
Beliefs * | BM = 0 |
Pointer to a Belief Interaction Model. Model isn't held in ModelManager. If pointer is NULL, beliefs have been disabled for this model. | |
Tasks * | TASK = 0 |
Pointer to a Task Interaction Model. Model isn't held in ModelManager. If pointer is NULL, tasks have been disabled for this model. More... | |
bool | btm_enabled = false |
const Graph< unsigned int > * | belief_message_complexity = 0 |
const Graph< unsigned int > * | btm_message_complexity = 0 |
Graph< std::map< unsigned int, float > > * | btm = 0 |
Graph< float > * | _group_beliefs = 0 |
float | alpha = 0 |
Used for updating beliefs when using belief transactive memory | |
std::vector< float > | generalized_other_beliefs |
Precalulates the average beliefs for all agents. When an agent examines another agent outside their interaction sphere, the corresponding belief value from this vector is used. | |
std::vector< unsigned int > | group_sizes |
Precaluclates how many agents are in each group. Does not change over time. More... | |
Graph< bool > * | group_membership = 0 |
Public Attributes inherited from StandardInteraction | |
const Nodeset & | agents = ns_manager.get_nodeset(nodeset_names::agents) |
const Nodeset & | knowledge = ns_manager.get_nodeset(nodeset_names::knowledge) |
const Nodeset & | comm = ns_manager.get_nodeset(nodeset_names::comm) |
const Nodeset & | time = 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< InteractionMessage > | send_msg_queue |
std::vector< CommunicationMedium > | communication_mediums |
unsigned int | agent_count |
unsigned int | knowledge_count |
unsigned int | interaction_rejection_limit |
Public Attributes inherited from Model | |
Construct & | construct |
GraphManager & | graph_manager |
NodesetManager & | ns_manager |
Random & | random |
bool | valid |
If member is false, the model's functions are not called. | |
A variation on the Standard Interaction Model .
Combines components of the Knowledge Transactive Memory Interaction Model , Task Interaction Model , and the Belief Interaction Model .
|
overridevirtual |
Calls the cleanup functions of models if they're enabled. If belief transactive memory is enabled, beliefs calculations are modified to include belief transactive memory.
Reimplemented from Model.
|
overridevirtual |
If knowledge transactive memory is enabled, TMK->communicate is called. If belief transactive memory is enabled, beliefs and belief transactive memory items are parsed.
Reimplemented from Model.
|
overridevirtual |
If beliefs are enabled get_belief_sim is multiplied by agent_i's row in belief_sim_weight.
Reimplemented from StandardInteraction.
|
overridevirtual |
If knowledge transactive memory is enabled, TMK->get_interaction_items is used otherwise StandardInteraction::get_interaction_items is used. If belief transactive memory is enabled, belief and belief transactive memory items are added.
Reimplemented from StandardInteraction.
|
overridevirtual |
Uses TMK->get_k_exp, TASK->get_k_exp, a combination if both are enabled, or StandardInteraction::get_k_exp otherwise.
Reimplemented from StandardInteraction.
|
overridevirtual |
Uses TMK->get_k_sim, TASK->get_k_sim, a combination if both are enabled, or StandardInteraction::get_k_exp otherwise.
Reimplemented from StandardInteraction.
|
overridevirtual |
Checks for mutually exclusive models and then calls StandardInteraction::intialize.
Reimplemented from StandardInteraction.
const Graph<unsigned int>* GrandInteraction::belief_message_complexity = 0 |
summary>
Graph<std::map<unsigned int, float> >* GrandInteraction::btm = 0 |
summary>
bool GrandInteraction::btm_enabled = false |
summary>
const Graph<unsigned int>* GrandInteraction::btm_message_complexity = 0 |
summary>
Graph<bool>* GrandInteraction::group_membership = 0 |
summary>
std::vector<unsigned int> GrandInteraction::group_sizes |
Precaluclates how many agents are in each group. Does not change over time.
summary>
Tasks* GrandInteraction::TASK = 0 |
Pointer to a Task Interaction Model. Model isn't held in ModelManager. If pointer is NULL, tasks have been disabled for this model.
summary>