Construct version 5.4.4
An agent based modeling framework
|
Enriches Social_Media_no_followers with a follower network to better influence one's feed. More...
Classes | |
struct | default_media_user |
Implements the virtual functions in Social_Media_with_followers::media_user. More... | |
struct | media_user |
Class that adds functions based around the follower network to Social_Media_no_followers::media_user. More... | |
Public Member Functions | |
Social_Media_with_followers::media_user & | user (unsigned int index) |
Social_Media_no_followers::media_user * | get_default_media_user (const Node &node) override |
Gets the default media user for a social media class. More... | |
Social_Media_with_followers (const std::string &_media_name, InteractionItem::item_keys event_key, const dynet::ParameterMap ¶meters, Construct &_construct) | |
Base constructor for any social media model. More... | |
void | communicate (const InteractionMessage &msg) override |
Calls Social_Media_no_followers::communicate and for each read event, the receiving agent can follow the sending agent. More... | |
void | cleanup (void) override |
Feeds are updated, the social media will recommend users to follow, and users can decide to unfollow other users. More... | |
float | follower_jaccard_similarity (unsigned int agent_i, unsigned int agent_j) const |
Computes the Jaccard Similarity in the follower network between the two agent indexes. | |
virtual void | add_followees (void) |
Gives each user recommended users to follow. More... | |
virtual void | remove_followees (void) |
Each users decides whether to unfollow any other user. More... | |
virtual int | get_feed_priority (const media_event &_event, unsigned int user) override |
If Social_Media_no_followers::get_feed_priority returns a value greater than 50 and the user is following the event's author, 50 is returned. Otherwise, the result from Social_Media_no_followers::get_feed_priority is returned. More... | |
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_event * | create_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_event * | create_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_event * | create_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_event * | create_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_event * | create_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_user & | user (unsigned int index) |
Social_Media_no_followers (const std::string &_media_name, InteractionItem::item_keys event_key, const dynet::ParameterMap ¶meters, 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_user * | get_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 | |
std::vector< std::vector< unsigned int > > | responses |
Holds the number of responses between agents. More... | |
Graph< bool > * | follower_net = nullptr |
The follower network for the social media with name dependent on the media. | |
Graph< float > * | ktrust_net = nullptr |
Pointer to the graph with name "knowledge trust network". | |
Graph< std::map< unsigned int, float > > * | kttm = nullptr |
Pointer to the graph with name "knowledge trust transactive memory network". More... | |
bool | disable_follower_recommendations = false |
std::function< void(Social_Media_with_followers *, unsigned int)> | add_followees_output |
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 Nodeset & | agents = ns_manager.get_nodeset(nodeset_names::agents) |
const Nodeset & | knowledge = 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 | |
Construct & | construct |
GraphManager & | graph_manager |
NodesetManager & | ns_manager |
Random & | random |
bool | valid |
If member is false, the model's functions are not called. | |
Enriches Social_Media_no_followers with a follower network to better influence one's feed.
This model adds a follower network that influences how an agent's feeds are structured. Agents can decide to follow other agents when reading their events or when they are recommended to them during cleanup. Agents can also decide to unfollow agents they currently follow during cleanup. Similar to Social_Media_no_followers, this model has an abstract user class Social_Media_with_followers::media_user as well as an implementation derived from this class Social_Media_with_followers::default_media_user. Both of these classes inheriet from their counterparts in Social_Media_no_followers allowing the base user mechanics to be augmented with descision capabilities on following.
Follower recommendations are handled by Social_Media_with_followers::add_followees follows the methodology of recommending users based on the similarity of follower bases. If two agents have similar followers and the ego agent is following one of them, the other is recommended to the ego agent to follow. Stronger similarity causes agents to be first in line to be asked whether the ego agent wants to follow them. The number of agents recommended is represented by media_user::pdaf. Unfollowing users is handled by Social_Media_with_followers::remove_followees where an agent will unfollow an alter agent they currently follow based on reciprocity of the following relationship, the alter agent respondind to the ego agent's events, and a Jaccard Similarity of the ego and alter agent's follower base. The probability to unfollow is weighted by Social_Media_no_followers::dt / Social_Media_with_followers::default_media_user::rf to ensure consistent behaviour independence of Social_Media_no_followers::dt.
Social_Media_with_followers::get_feed_priority adds an additional category that goes after replies and mentions, but before all other events. This category contains events authored by alter agents that the ego agent is following. The same methodology seen in Social_Media_no_followers is continued with this additional category.
Social_Media_with_followers::Social_Media_with_followers | ( | const std::string & | _media_name, |
InteractionItem::item_keys | event_key, | ||
const dynet::ParameterMap & | parameters, | ||
Construct & | _construct | ||
) |
Base constructor for any social media model.
This class does not define the model's name. Instead derived classes must do so when initializing the Model constructor.
_media_name | The name of the social media and is stored in Social_Media_with_followers::media_name. This affects the node attributes that are searched for in defining a Social_Media_with_followers::default_media_user. |
parameters | A parameter map that should contain the keys "interval time duration" and "maximum post inactivity" as floats. |
_construct | The construct pointer that is passed to the Model constructor. |
|
virtual |
Gives each user recommended users to follow.
Only agents who are active in the active time network will decide whether to follow any agents they currently aren't following. Changes to follower network only occur after both this function and Social_Media_with_followers::remove_followees are called. This ensures that there is no impact from the order in which users decide to follow. The descision for whether an agent follows another is contained in media_user::follower_user.
|
overridevirtual |
Feeds are updated, the social media will recommend users to follow, and users can decide to unfollow other users.
Reimplemented from Social_Media_no_followers.
|
overridevirtual |
Calls Social_Media_no_followers::communicate and for each read event, the receiving agent can follow the sending agent.
Reimplemented from Social_Media_no_followers.
|
inlineoverridevirtual |
Gets the default media user for a social media class.
Reimplemented from Social_Media_no_followers.
|
overridevirtual |
If Social_Media_no_followers::get_feed_priority returns a value greater than 50 and the user is following the event's author, 50 is returned. Otherwise, the result from Social_Media_no_followers::get_feed_priority is returned.
Reimplemented from Social_Media_no_followers.
Reimplemented in SM_wf_emotions.
|
virtual |
Each users decides whether to unfollow any other user.
Only agents who are active in the active time network will decide whether to unfollow any followees. Changes to follower network only occur after both this function and Social_Media_with_followers::add_followees are called. This ensures that there is no impact from the order in which users decide to unfollow. The descision for whether an agent is unfollowed is contained in media_user::unfollower_user.
Graph<std::map<unsigned int, float> >* Social_Media_with_followers::kttm = nullptr |
Pointer to the graph with name "knowledge trust transactive memory network".
summary>
std::vector< std::vector<unsigned int> > Social_Media_with_followers::responses |
Holds the number of responses between agents.
responses[i][j] is the number of times that agent j has replied, quoted, reposted agent i's events. The structure is empty except during the remove_followees function. It is populated during the function and promplty cleared upon moving out of scope of the function. This structure is used by Social_Media_with_followers::default_media_user::unfollow_user.