Construct version 5.4.4
An agent based modeling framework
Tasks Struct Reference

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

Inheritance diagram for Tasks:
Collaboration diagram for Tasks:

Public Member Functions

 Tasks (const dynet::ParameterMap &parameters, Construct &construct)
 
void initialize (void) override
 
void cleanup (void) override
 Function called after the Model::communicate functions in a simulation cycle. More...
 
float get_k_exp (unsigned int agent_i, unsigned int agent_j) override
 Replaces StandardInteraction::get_k_exp by only using the knowledge required for completing assigned tasks. 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

const Nodesettasks = ns_manager.get_nodeset(nodeset_names::task)
 
const Graph< bool > & task_assignment = graph_manager.load_optional(graph_names::task_assignment, true, agents, sparse, tasks, sparse)
 
const Graph< bool > & tk_req = graph_manager.load_required(graph_names::task_k_req, tasks, knowledge)
 
const Graph< float > & tk_import = graph_manager.load_optional(graph_names::task_k_importance, 1.0f, tasks, sparse, knowledge, sparse)
 
const Graph< float > & tk_prob = graph_manager.load_optional(graph_names::task_guess_prob, 0.0f, tasks, sparse, knowledge, sparse)
 
Graph< unsigned int > & task_completion = graph_manager.load_optional(graph_names::task_completion, 0u, agents, sparse, tasks, sparse)
 
const Graph< bool > & availablity = graph_manager.load_optional(graph_names::task_availability, true, tasks, 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 tasks.

Constructor & Destructor Documentation

◆ Tasks()

Tasks::Tasks ( const dynet::ParameterMap parameters,
Construct construct 
)

summary>

Here is the call graph for this function:

Member Function Documentation

◆ cleanup()

void Tasks::cleanup ( void  )
overridevirtual

Function called after the Model::communicate functions in a simulation cycle.

End of cycle calculations are done during this function. Model::cleanup is called after GraphManager::push_deltas is called.

Reimplemented from Model.

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

◆ get_k_exp()

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

Replaces StandardInteraction::get_k_exp by only using the knowledge required for completing assigned tasks.

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:

◆ initialize()

void Tasks::initialize ( void  )
overridevirtual

summary>

Reimplemented from StandardInteraction.

Here is the call graph for this function:

Member Data Documentation

◆ availablity

const Graph<bool>& Tasks::availablity = graph_manager.load_optional(graph_names::task_availability, true, tasks, sparse, time, sparse)

summary>

◆ task_assignment

const Graph<bool>& Tasks::task_assignment = graph_manager.load_optional(graph_names::task_assignment, true, agents, sparse, tasks, sparse)

summary>

◆ task_completion

Graph<unsigned int>& Tasks::task_completion = graph_manager.load_optional(graph_names::task_completion, 0u, agents, sparse, tasks, sparse)

summary>

◆ tasks

const Nodeset& Tasks::tasks = ns_manager.get_nodeset(nodeset_names::task)

summary>

◆ tk_import

const Graph<float>& Tasks::tk_import = graph_manager.load_optional(graph_names::task_k_importance, 1.0f, tasks, sparse, knowledge, sparse)

summary>

◆ tk_prob

const Graph<float>& Tasks::tk_prob = graph_manager.load_optional(graph_names::task_guess_prob, 0.0f, tasks, sparse, knowledge, sparse)

summary>

◆ tk_req

const Graph<bool>& Tasks::tk_req = graph_manager.load_required(graph_names::task_k_req, tasks, knowledge)

summary>