Construct version 5.4.4
An agent based modeling framework
SM_nf_emotions Struct Reference

Social Media model that modifies user behavior based on their emotional state. More...

Inheritance diagram for SM_nf_emotions:
Collaboration diagram for SM_nf_emotions:

Public Member Functions

 SM_nf_emotions (const std::string &_media_name, InteractionItem::item_keys event_key, const dynet::ParameterMap &params, Construct &construct)
 
Social_Media_no_followers::media_userget_default_media_user (const Node &node) override
 
InteractionItem convert_to_InteractionItem (media_event *_event, unsigned int sender_index, unsigned int receiver_index) const override
 
- Public Member Functions inherited from Social_Media_no_followers
void load_events (const std::string &fname, const dynet::datetime &start_time, float time_conversion, const std::map< std::string, unsigned int > &agent_mask=std::map< std::string, unsigned int >())
 Parses the content of a json file and loads the information into Social_Media_no_followers::list_of_events. More...
 
virtual media_eventcreate_post (unsigned int knowledge_index, unsigned int id)
 Creates a post event and adds it to Social_Media_no_followers::list_of_events. More...
 
virtual media_eventcreate_response (unsigned int id, media_event *parent)
 Creates a response event based on the parent event and adds it to Social_Media_no_followers::list_of_events. More...
 
virtual media_eventcreate_quote (unsigned int id, media_event *parent)
 Creates a quote event based on the parent event and adds it to Social_Media_no_followers::list_of_events. More...
 
virtual media_eventcreate_reply (unsigned int id, media_event *parent)
 Creates a reply event based on the parent event and adds it to Social_Media_no_followers::list_of_events. More...
 
virtual media_eventcreate_repost (unsigned int id, media_event *parent)
 Creates a quote event based on the parent event and adds it to Social_Media_no_followers::list_of_events. More...
 
virtual void finalize_event (media_event *_event)
 Allows each model to intercept the created event. More...
 
void check_list_order () const
 Checks the list of events to make sure the time stamps are sorted in descending order. More...
 
Social_Media_no_followers::media_useruser (unsigned int index)
 
 Social_Media_no_followers (const std::string &_media_name, InteractionItem::item_keys event_key, const dynet::ParameterMap &parameters, Construct &_construct)
 Base constructor for any social media model. More...
 
virtual ~Social_Media_no_followers ()
 All pointers in Social_Media_with_followers::users are deallocated.
 
virtual media_userget_default_media_user (const Node &node)
 Gets the default media user for a social media class. More...
 
void think (void) override
 Agents read events in their feed and create messages based on the read events. More...
 
void initialize (void) override
 Loads users using Social_Media_no_followers::load_user and adds Knowledge_Parser to Construct::message_parsers if one is not present. More...
 
void communicate (const InteractionMessage &msg) override
 Parses messages that contain the Social_Media_no_followers::event key in their attributes. If the event contains the attribute, media_user::(read, reply, quote, and repost) are called from the receiver's index in Social_Media_no_followers::users More...
 
void cleanup (void) override
 Feeds are updated, list_of_events::removed_events are cleared, and events are erased from list_of_events that have have become inactive. More...
 
virtual void append_message (media_event *_event, InteractionMessage &msg)
 Appends the array of InteractionItems based on the submitted event and the intended receiver of the message. More...
 
virtual InteractionItem convert_to_InteractionItem (media_event *_event, unsigned int sender_index, unsigned int receiver_index) const
 Copies some or all information from the submitted event based on the sender's and receiver's node attributes. More...
 
virtual int get_feed_priority (const media_event &_event, unsigned int user)
 Returns 10 if the user is mentioned by the event or if the event is a reply to an event authored by the user. Returns 100 otherwise. More...
 
virtual void update_event_scores ()
 Goes through all events and updates media_event::score to media_event::child_size * media_event::time_stamp. More...
 
virtual void random_event_swapping (unsigned int user_index)
 Randomly swaps 10% of events in the user's feed. More...
 
virtual void update_feeds (float new_events_timestamp)
 Updates each user's feeds. More...
 
template<typename function >
auto get_events (function filter)
 
- 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 Nodesetemotions = ns_manager.get_nodeset(nodeset_names::emotions)
 
const Graph< float > & emotion_net = graph_manager.load_required(graph_names::emotion_net, agents, emotions)
 
const Graph< float > & emot_broadcast_bias = graph_manager.load_optional(graph_names::emot_broad_bias, 1.0f, agents, false, emotions, false)
 The base probability an agent attaches an emotion. More...
 
const Graph< float > & emot_broadcast_first = graph_manager.load_optional(graph_names::emot_broad_first, 0.0f, emotions, false, emotions, false)
 The first order emotional dependence on the probability an agent attaches an emotion. More...
 
const Graph< std::map< unsigned int, float > > & emot_broadcast_second
 The second order emotional dependence on the probability an agent attaches an emotion. More...
 
const Graph< float > & pd_emotion_first = graph_manager.load_optional("first order post density emotion network", 0.0f, agents, false, emotions, false)
 The first order emotional dependence on the probability density for how many posts an agent creates each timestep. More...
 
const Graph< float > & pd_emotion_second = graph_manager.load_optional("second order post density emotion network", 0.0f, emotions, false, emotions, false)
 The second order emotional dependence on the probability density for how many posts an agent creates each timestep. More...
 
const Graph< float > & pr_emotion_first = graph_manager.load_optional("first order reply probability emotion network", 0.0f, agents, false, emotions, false)
 The first order emotional dependence on the probability that an agent replies to an event when reading it. More...
 
const Graph< float > & pr_emotion_second = graph_manager.load_optional("second order reply probability emotion network", 0.0f, emotions, false, emotions, false)
 The second order emotional dependence on the probability that an agent replies to an event when reading it. More...
 
const Graph< float > & prp_emotion_first = graph_manager.load_optional("first order repost probability emotion network", 0.0f, agents, false, emotions, false)
 The first order emotional dependence on the probability that an agent reposts an event when reading it. More...
 
const Graph< float > & prp_emotion_second = graph_manager.load_optional("second order repost probability emotion network", 0.0f, emotions, false, emotions, false)
 The second order emotional dependence on the probability that an agent reposts an event when reading it. More...
 
const Graph< float > & pq_emotion_first = graph_manager.load_optional("first order quote probability emotion network", 0.0f, agents, false, emotions, false)
 The first order emotional dependence on the probability that an agent quotes an event when reading it. More...
 
const Graph< float > & pq_emotion_second = graph_manager.load_optional("second order quote probability emotion network", 0.0f, emotions, false, emotions, false)
 The second order emotional dependence on the probability that an agent quotes an event when reading it. More...
 
const Graph< float > & pread_emotion_first = graph_manager.load_optional("first order read density emotion network", 0.0f, agents, false, emotions, false)
 The first order emotional dependence on the probability density for how many posts an agent reads each timestep. More...
 
const Graph< float > & pread_emotion_second = graph_manager.load_optional("second order read density emotion network", 0.0f, emotions, false, emotions, false)
 The second order emotional dependence on the probability density for how many posts an agent reads each timestep. More...
 
const Graph< float > & kselect_emotion = graph_manager.load_optional("knowledge select emotion network", 0.0f, knowledge, false, emotions, false)
 The emotional dependence on the probability weight an agent selects a knowledge bit for creating an event. More...
 
const Graph< float > & kselect_trust = graph_manager.load_optional("knowledge select trust network", 0.0f, agents, false, knowledge, false)
 The knowledge trust dependence on the probability weight an agent selects a knowledge bit for creating an event. More...
 
const Graph< float > & kselect = graph_manager.load_optional("knowledge select bias network", 1.0f, agents, false, knowledge, false)
 The base probability weight an agent selects a knowledge bit for creating an event. More...
 
- Public Attributes inherited from Social_Media_no_followers
event_container list_of_events
 The list of all current events in this social media. New events should be added to the front of this list.
 
const Nodesetagents = ns_manager.get_nodeset(nodeset_names::agents)
 
const Nodesetknowledge = ns_manager.get_nodeset(nodeset_names::knowledge)
 
const CommunicationMedium medium
 The medium used for all messages created by this model.
 
const InteractionItem::item_keys event_key
 The item key added to all messages created by this model.
 
std::vector< std::vector< media_event * > > users_feed
 Each user's feed of events with the first dimension corresponding to each user. More...
 
std::vector< unsigned int > read_count
 
float age
 The maximum time a post can exist without its tree being added to.
 
float dt
 The time duration between time steps.
 
float time = 0.0f
 The current time period.
 
std::string media_name
 The prefix for some of the node attributes names parsed by the media_user class.
 
Graph< bool > & knowledge_net = graph_manager.load_required(graph_names::knowledge, agents, knowledge)
 Pointer to the graph with name "knowledge network".
 
const Graph< bool > * active_agents = graph_manager.load_optional(graph_names::active, true, agents, sparse, ns_manager.get_nodeset(nodeset_names::time), sparse)
 Pointer to the graph with name "agent active time network".
 
std::vector< media_user * > users
 The list of users. More...
 
std::function< bool(media_event &)> current_timestep = [this](media_event& _event) { return _event.time_stamp > time - 0.5f * dt; }
 
std::function< bool(media_event &)> previous_timestep = [this](media_event& _event) { return _event.time_stamp > time - 1.5f * dt; }
 
std::function< bool(media_event &)> active = [this](media_event& _event) { return _event.last_used > time - age; }
 
std::function< void(Social_Media_no_followers *, unsigned int)> feed_update_output
 
std::function< void(Social_Media_no_followers *)> cleanup_output
 
- 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

Social Media model that modifies user behavior based on their emotional state.

This model holds the various networks that SM_nf_emotions::default_media_user uses supplement the increased descision making complexity. In addition, this model attaches emotions to messages. As emotions can not be saved directly in an event, so the emotional state of the agent when they create an event is saved in attached_emotions.

Constructor & Destructor Documentation

◆ SM_nf_emotions()

SM_nf_emotions::SM_nf_emotions ( const std::string &  _media_name,
InteractionItem::item_keys  event_key,
const dynet::ParameterMap params,
Construct construct 
)
inline

summary>

Member Function Documentation

◆ convert_to_InteractionItem()

InteractionItem SM_nf_emotions::convert_to_InteractionItem ( media_event _event,
unsigned int  sender_index,
unsigned int  receiver_index 
) const
overridevirtual

summary>

Reimplemented from Social_Media_no_followers.

Reimplemented in SM_wf_emotions.

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

◆ get_default_media_user()

Social_Media_no_followers::media_user * SM_nf_emotions::get_default_media_user ( const Node node)
inlineoverridevirtual

summary>

Reimplemented from Social_Media_no_followers.

Reimplemented in SM_wf_emotions.

Member Data Documentation

◆ emot_broadcast_bias

const Graph<float>& SM_nf_emotions::emot_broadcast_bias = graph_manager.load_optional(graph_names::emot_broad_bias, 1.0f, agents, false, emotions, false)

The base probability an agent attaches an emotion.

Dimensions: agent x emotion
This network is a part of the equation for calculating the probability that an agent attaches an emotion to a message they send. The probability agent \(i\) attaches emotion \(n\) is \(P_{i,n}=A_{i,n}+\sum_mB_{n,m}E_{i,m}+\sum_{m,g}C_{n,m,g}E_{i,m}E_{i,g}\) where \(A_{i,n}\) corresponds to links in this network.

◆ emot_broadcast_first

const Graph<float>& SM_nf_emotions::emot_broadcast_first = graph_manager.load_optional(graph_names::emot_broad_first, 0.0f, emotions, false, emotions, false)

The first order emotional dependence on the probability an agent attaches an emotion.

Dimensions: emotion x emotion
This network is a part of the equation for calculating the probability that an agent attaches an emotion to a message they send. The probability agent \(i\) attaches emotion \(n\) is \(P_{i,n}=A_{i,n}+\sum_mB_{n,m}E_{i,m}+\sum_{m,g}C_{n,m,g}E_{i,m}E_{i,g}\) where \(B_{n,m}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\).

◆ emot_broadcast_second

const Graph<std::map<unsigned int, float> >& SM_nf_emotions::emot_broadcast_second
Initial value:
=
graph_manager.load_optional(graph_names::emot_broad_second, std::map<unsigned int, float>(), emotions, false, emotions, false, emotions)
Graph_Intermediary load_optional(const std::string &name, const Nodeset *src, const Nodeset *trg, const Nodeset *slc=nullptr) const
Finds a Graph if its loaded and returns it via a proxy class.
Definition: GraphManager.cpp:908
const std::string emot_broad_second
Definition: GraphManager.h:69
GraphManager & graph_manager
Definition: Model.h:77
const Nodeset * emotions
Definition: Emotions.h:343

The second order emotional dependence on the probability an agent attaches an emotion.

Dimensions: emotion x emotion x emotion
This network is a part of the equation for calculating the probability that an agent attaches an emotion to a message they send. The probability agent \(i\) attaches emotion \(n\) is \(P_{i,n}=A_{i,n}+\sum_mB_{n,m}E_{i,m}+\sum_{m,g}C_{n,m,g}E_{i,m}E_{i,g}\) where \(C_{n,m,g}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\).

◆ emotions

const Nodeset* SM_nf_emotions::emotions = ns_manager.get_nodeset(nodeset_names::emotions)

summary>

◆ kselect

const Graph<float>& SM_nf_emotions::kselect = graph_manager.load_optional("knowledge select bias network", 1.0f, agents, false, knowledge, false)

The base probability weight an agent selects a knowledge bit for creating an event.

Dimensions: agent x knowledge
This network is a part of the equation for calculating the probability weight for selecting a knowledge bit. The probability weight agent \(i\) selecting knowledge \(k\) is \(P_{i,k}=A_{i,k}+\sum_mB_{i,k}|T_{i,k}-0.5|+\sum_mC_{k,m}E_{i,m}\) where \(A_{i,k}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\) and \(T_{i,k}\) is the agent's trust in that knowledge bit.

◆ kselect_emotion

const Graph<float>& SM_nf_emotions::kselect_emotion = graph_manager.load_optional("knowledge select emotion network", 0.0f, knowledge, false, emotions, false)

The emotional dependence on the probability weight an agent selects a knowledge bit for creating an event.

Dimensions: knowledge x emotion
This network is a part of the equation for calculating the probability weight for selecting a knowledge bit. The probability weight agent \(i\) selecting knowledge \(k\) is \(P_{i,k}=A_{i,k}+\sum_mB_{i,k}|T_{i,k}-0.5|+\sum_mC_{k,m}E_{i,m}\) where \(C_{k,m}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\) and \(T_{i,k}\) is the agent's trust in that knowledge bit.

◆ kselect_trust

const Graph<float>& SM_nf_emotions::kselect_trust = graph_manager.load_optional("knowledge select trust network", 0.0f, agents, false, knowledge, false)

The knowledge trust dependence on the probability weight an agent selects a knowledge bit for creating an event.

Dimensions: agent x knowledge
This network is a part of the equation for calculating the probability weight for selecting a knowledge bit. The probability weight agent \(i\) selecting knowledge \(k\) is \(P_{i,k}=A_{i,k}+\sum_mB_{i,k}|T_{i,k}-0.5|+\sum_mC_{k,m}E_{i,m}\) where \(B_{i,k}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\) and \(T_{i,k}\) is the agent's trust in that knowledge bit.

◆ pd_emotion_first

const Graph<float>& SM_nf_emotions::pd_emotion_first = graph_manager.load_optional("first order post density emotion network", 0.0f, agents, false, emotions, false)

The first order emotional dependence on the probability density for how many posts an agent creates each timestep.

Dimensions: agent x emotion
This network is a part of the equation for calculating the probability density for how many posts an agent creates each timestep. The probability density for how many posts agent \(i\) creates is \(P^{(post)}_i=pdp_i+\sum_mB_{i,m}E_{i,m}+\sum_{n,m}C_{n,m}E_{i,n}E_{i,m}\) where \(B_{i,m}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\) and \(pdp_i\) is the value Social_Media_no_followers::default_media_user::pdp.

◆ pd_emotion_second

const Graph<float>& SM_nf_emotions::pd_emotion_second = graph_manager.load_optional("second order post density emotion network", 0.0f, emotions, false, emotions, false)

The second order emotional dependence on the probability density for how many posts an agent creates each timestep.

Dimensions: emotion x emotion
This network is a part of the equation for calculating the probability density for how many posts an agent creates each timestep. The probability density for how many posts agent \(i\) creates is \(P^{(post)}_i=pdp_i+\sum_mB_{i,m}E_{i,m}+\sum_{n,m}C_{n,m}E_{i,n}E_{i,m}\) where \(C_{n,m}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\) and \(pdp_i\) is the value Social_Media_no_followers::default_media_user::pdp.

◆ pq_emotion_first

const Graph<float>& SM_nf_emotions::pq_emotion_first = graph_manager.load_optional("first order quote probability emotion network", 0.0f, agents, false, emotions, false)

The first order emotional dependence on the probability that an agent quotes an event when reading it.

Dimensions: agent x emotion
This network is a part of the equation for calculating the quote probability. The probability agent \(i\) quotes an event is \(P^{(quote)}_i=pqu_i+\sum_mB_{i,m}E_{i,m}+\sum_{n,m}C_{n,m}E_{i,n}E_{i,m}\) where \(B_{i,m}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\) and \(pqu_i\) is the value Social_Media_no_followers::default_media_user::pqu.

◆ pq_emotion_second

const Graph<float>& SM_nf_emotions::pq_emotion_second = graph_manager.load_optional("second order quote probability emotion network", 0.0f, emotions, false, emotions, false)

The second order emotional dependence on the probability that an agent quotes an event when reading it.

Dimensions: emotion x emotion
This network is a part of the equation for calculating the quote probability. The probability agent \(i\) quotes an event is \(P^{(quote)}_i=pqu_i+\sum_mB_{i,m}E_{i,m}+\sum_{n,m}C_{n,m}E_{i,n}E_{i,m}\) where \(C_{n,m}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\) and \(pqu_i\) is the value Social_Media_no_followers::default_media_user::pqu.

◆ pr_emotion_first

const Graph<float>& SM_nf_emotions::pr_emotion_first = graph_manager.load_optional("first order reply probability emotion network", 0.0f, agents, false, emotions, false)

The first order emotional dependence on the probability that an agent replies to an event when reading it.

Dimensions: agent x emotion
This network is a part of the equation for calculating the reply probability. The probability agent \(i\) replies to an event is \(P^{(reply)}_i=pr_i+\sum_mB_{i,m}E_{i,m}+\sum_{n,m}C_{n,m}E_{i,n}E_{i,m}\) where \(B_{i,m}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\) and \(pr_i\) is the value Social_Media_no_followers::default_media_user::pr.

◆ pr_emotion_second

const Graph<float>& SM_nf_emotions::pr_emotion_second = graph_manager.load_optional("second order reply probability emotion network", 0.0f, emotions, false, emotions, false)

The second order emotional dependence on the probability that an agent replies to an event when reading it.

Dimensions: emotion x emotion
This network is a part of the equation for calculating the reply probability. The probability agent \(i\) replies to an event is \(P^{(reply)}_i=pr_i+\sum_mB_{i,m}E_{i,m}+\sum_{n,m}C_{n,m}E_{i,n}E_{i,m}\) where \(C_{n,m}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\) and \(pr_i\) is the value Social_Media_no_followers::default_media_user::pr.

◆ pread_emotion_first

const Graph<float>& SM_nf_emotions::pread_emotion_first = graph_manager.load_optional("first order read density emotion network", 0.0f, agents, false, emotions, false)

The first order emotional dependence on the probability density for how many posts an agent reads each timestep.

Dimensions: agent x emotion
This network is a part of the equation for calculating the read probability density. The probability density for how many posts agent \(i\) reads is \(P^{(read)}_i=pdread_i+\sum_mB_{i,m}E_{i,m}+\sum_{n,m}C_{n,m}E_{i,n}E_{i,m}\) where \(B_{i,m}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\) and \(pdread_i\) is the value Social_Media_no_followers::default_media_user::pdread.

◆ pread_emotion_second

const Graph<float>& SM_nf_emotions::pread_emotion_second = graph_manager.load_optional("second order read density emotion network", 0.0f, emotions, false, emotions, false)

The second order emotional dependence on the probability density for how many posts an agent reads each timestep.

Dimensions: emotion x emotion
This network is a part of the equation for calculating the read probability density. The probability density for how many posts agent \(i\) reads is \(P^{(read)}_i=pdread_i+\sum_mB_{i,m}E_{i,m}+\sum_{n,m}C_{n,m}E_{i,n}E_{i,m}\) where \(C_{n,m}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\) and \(pdread_i\) is the value Social_Media_no_followers::default_media_user::pdread.

◆ prp_emotion_first

const Graph<float>& SM_nf_emotions::prp_emotion_first = graph_manager.load_optional("first order repost probability emotion network", 0.0f, agents, false, emotions, false)

The first order emotional dependence on the probability that an agent reposts an event when reading it.

Dimensions: agent x emotion
This network is a part of the equation for calculating the repost probability. The probability agent \(i\) reposts an event is \(P^{(repost)}_i=prp_i+\sum_mB_{i,m}E_{i,m}+\sum_{n,m}C_{n,m}E_{i,n}E_{i,m}\) where \(B_{i,m}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\) and \(prp_i\) is the value Social_Media_no_followers::default_media_user::prp.

◆ prp_emotion_second

const Graph<float>& SM_nf_emotions::prp_emotion_second = graph_manager.load_optional("second order repost probability emotion network", 0.0f, emotions, false, emotions, false)

The second order emotional dependence on the probability that an agent reposts an event when reading it.

Dimensions: emotion x emotion
This network is a part of the equation for calculating the repost probability. The probability agent \(i\) reposts an event is \(P^{(repost)}_i=prp_i+\sum_mB_{i,m}E_{i,m}+\sum_{n,m}C_{n,m}E_{i,n}E_{i,m}\) where \(C_{n,m}\) corresponds to links in this network and \(E_{i,m}\) is the agent's emotional value for emotion \(m\) and \(prp_i\) is the value Social_Media_no_followers::default_media_user::prp.