Construct version 5.4.4
An agent based modeling framework
Beliefs Class Reference

A variation on the Standard Interaction Model utilizing beliefs. More...

Inheritance diagram for Beliefs:
Collaboration diagram for Beliefs:

Public Member Functions

 Beliefs (const dynet::ParameterMap &parameters, Construct &construct)
 
void initialize (void) override
 In addition to calling StandardInteration::intialize, the base model is added to the model manager using Inheritence_Wrapper. More...
 
void cleanup (void) override
 Recalculates belief value value using belief_weights and knowledge_net. More...
 
float get_additions (unsigned int agent_i, unsigned int agent_j) override
 Replaces StandardInteraction::get_additions in StandardInteraction::set_interaction_probability to include belief dependence. More...
 
virtual float get_belief_sim (unsigned int agent_i, unsigned int agent_j)
 Calcuates the cosine similarity between two agents' beliefs. More...
 
virtual float get_belief_value (unsigned int agent_i, unsigned int belief)
 Calculates a belief value based on an agent's knowledge state More...
 
- 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

Graph< float > & beliefs = graph_manager.load_required(graph_names::beliefs, nodeset_names::agents, nodeset_names::belief)
 
const Graph< float > & belief_weights = graph_manager.load_optional(graph_names::b_k_wgt, 1.0f, nodeset_names::belief, dense, nodeset_names::knowledge, sparse)
 
const Graph< float > & belief_sim_weight = graph_manager.load_optional(graph_names::b_sim_wgt, 1.0f, agents, sparse, time, sparse)
 
- 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 beliefs.

Constructor & Destructor Documentation

◆ Beliefs()

Beliefs::Beliefs ( const dynet::ParameterMap parameters,
Construct construct 
)
inline

summary>

Member Function Documentation

◆ cleanup()

void Beliefs::cleanup ( void  )
overridevirtual

Recalculates belief value value using belief_weights and knowledge_net.

Reimplemented from Model.

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

◆ get_additions()

float Beliefs::get_additions ( unsigned int  agent_i,
unsigned int  agent_j 
)
overridevirtual

Replaces StandardInteraction::get_additions in StandardInteraction::set_interaction_probability to include belief dependence.

Parameters
agent_iSource agent, belief similarity weights for this agent are used.
agent_jTarget agent that the source agent is calculating probabilities for.
Returns
The belief cosine similarity between the two agents weighted by agent_i's belief similarity weight.

Reimplemented from StandardInteraction.

Here is the call graph for this function:

◆ get_belief_sim()

float Beliefs::get_belief_sim ( unsigned int  agent_i,
unsigned int  agent_j 
)
virtual

Calcuates the cosine similarity between two agents' beliefs.

Parameters
agent_iSource agent.
agent_jTarget agent that the source agent is calculating similarity against.
Returns
The cosine similarity between agent_i and agent_j's respective rows in Beliefs::beliefs.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_belief_value()

float Beliefs::get_belief_value ( unsigned int  agent_i,
unsigned int  belief 
)
virtual

Calculates a belief value based on an agent's knowledge state

Parameters
agent_iThe agent whose belief is being calculated.
beliefThe belief that is being calculated.
Returns
The updated belief value of for that agent's belief.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize()

void Beliefs::initialize ( void  )
overridevirtual

In addition to calling StandardInteration::intialize, the base model is added to the model manager using Inheritence_Wrapper.

Reimplemented from StandardInteraction.

Here is the call graph for this function:

Member Data Documentation

◆ belief_weights

const Graph<float>& Beliefs::belief_weights = graph_manager.load_optional(graph_names::b_k_wgt, 1.0f, nodeset_names::belief, dense, nodeset_names::knowledge, sparse)

summary>

◆ beliefs

Graph<float>& Beliefs::beliefs = graph_manager.load_required(graph_names::beliefs, nodeset_names::agents, nodeset_names::belief)

summary>