Construct version 5.4.4
An agent based modeling framework
Reddit Struct Reference

Specializes the Social_Media_no_followers model for Reddit. More...

Inheritance diagram for Reddit:
Collaboration diagram for Reddit:

Classes

struct  default_media_user
 Adds the contents of the event to the message as an InteractionItem if the message is empty. More...
 
struct  reddit_moderator
 Class for the behavior of moderators on Reddit. More...
 

Public Member Functions

 Reddit (const dynet::ParameterMap &parameters, Construct &_construct)
 Parameters are passed directly to the base class constructor.
 
media_eventcreate_post (unsigned int knowledge_index, unsigned int id, unsigned int subreddit)
 Creates a post in a specified subreddit.
 
media_eventcreate_response (unsigned int id, media_event *parent) override
 Creates a reply to the parent event in the same subreddit as the parent. More...
 
void initialize (void) override
 Loads the Social Media Moderation Model and all users. More...
 
int get_feed_priority (const media_event &_event, unsigned int user) override
 Rerturns a -1 if the event is banned (indexes[InteractionItem::item_keys::banned] != 0) or if the event's subreddit is not among the subreddits the agent is subscribed to in the subreddit membership network. Returns 10 if it is a comment on a user's post/comment. Returns 50 if it is a post made in one of the user's subreddits. Returns -1 otherwise. More...
 
void random_event_swapping (unsigned int) override
 This model disables all random event swapping in each users' feeds. More...
 
void update_event_scores () override
 Updates the scores of each event based on the log difference in the event's upvotes and downvotes and the age of the post. Larger values of Social_Media_no_followers::dt will weight the time dependence more. More...
 
Social_Media_no_followers::media_userget_default_media_user (const Node &node) override
 Gets the default media user for a social media class. 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_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 Nodesetsubreddits = ns_manager.get_nodeset(nodeset_names::subreddits)
 
const Graph< bool > & subreddit_network = graph_manager.load_required(graph_names::subreddit_mem, agents, subreddits)
 
Graph< unsigned int > & banned_agent_network = graph_manager.load_optional(graph_names::banned_user, 0u, agents, sparse, subreddits, sparse)
 
Social_Media_Moderationmoderation_model = nullptr
 
std::vector< unsigned int > subreddit_banned_threshold = std::vector<unsigned int>(subreddits.size())
 Contains the corresponding value of each subreddit's node_attributes::banned_threshold attribute value.
 
- 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

Specializes the Social_Media_no_followers model for Reddit.

Sets Social_Media_no_followers::media_name to "Reddit", Social_Media_no_followers::event_key to event_key::reddit_event.

Member Function Documentation

◆ create_response()

media_event * Reddit::create_response ( unsigned int  id,
media_event parent 
)
inlineoverridevirtual

Creates a reply to the parent event in the same subreddit as the parent.

Reimplemented from Social_Media_no_followers.

Here is the call graph for this function:

◆ get_default_media_user()

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

Gets the default media user for a social media class.

Reimplemented from Social_Media_no_followers.

◆ get_feed_priority()

int Reddit::get_feed_priority ( const media_event _event,
unsigned int  user 
)
overridevirtual

Rerturns a -1 if the event is banned (indexes[InteractionItem::item_keys::banned] != 0) or if the event's subreddit is not among the subreddits the agent is subscribed to in the subreddit membership network. Returns 10 if it is a comment on a user's post/comment. Returns 50 if it is a post made in one of the user's subreddits. Returns -1 otherwise.

Reimplemented from Social_Media_no_followers.

Here is the call graph for this function:

◆ initialize()

void Reddit::initialize ( void  )
overridevirtual

Loads the Social Media Moderation Model and all users.

Reimplemented from Model.

Here is the call graph for this function:

◆ random_event_swapping()

void Reddit::random_event_swapping ( unsigned int  )
inlineoverridevirtual

This model disables all random event swapping in each users' feeds.

Reimplemented from Social_Media_no_followers.

◆ update_event_scores()

void Reddit::update_event_scores ( )
overridevirtual

Updates the scores of each event based on the log difference in the event's upvotes and downvotes and the age of the post. Larger values of Social_Media_no_followers::dt will weight the time dependence more.

Reimplemented from Social_Media_no_followers.