Construct version 5.4.3
An agent based modeling framework
Twitter_wf Struct Reference

Specializes the Social_Media_with_followers model for Twitter. More...

Inheritance diagram for Twitter_wf:
Collaboration diagram for Twitter_wf:

Public Member Functions

 Twitter_wf (const dynet::ParameterMap &parameters, Construct &construct)
 Parameters are passed directly to the base class constructor. More...
 
void initialize () override
 checks for Knowledge Trust Model (opitional), and add the Knowledge_Parser to Construct::message_parsers if one is not present. More...
 
- Public Member Functions inherited from Social_Media_with_followers
Social_Media_with_followers::media_useruser (unsigned int index)
 
 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. More...
 
virtual void load_users (const std::string &version) override
 Loads the media_users into Social_Media_no_followers::users. 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...
 
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...
 
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...
 
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...
 
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...
 
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...
 
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 void load_users (const std::string &version)
 Loads the media_users into users. More...
 
void think (void) override
 Agents read events in their feed and create messages based on the read events. More...
 
void initialize (void) override
 checks for Knowledge Trust Model (opitional), and add the 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 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.
 

Additional Inherited Members

- Public Attributes inherited from Social_Media_with_followers
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. More...
 
bool disable_follower_recommendations = false
 
- Public Attributes inherited from Social_Media_no_followers
const std::string interval_time_duration = "interval time duration"
 
const std::string maximum_post_inactivity = "maximum post inactivity"
 
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)
 
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".
 
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; }
 
- 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_with_followers model for Twitter.

Sets Social_Media_with_followers::media_name to "Twitter", Social_Media_with_followers::event_key to event_key::twitter_event, and the follower network to "twitter follower network" graph.

Constructor & Destructor Documentation

◆ Twitter_wf()

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

Parameters are passed directly to the base class constructor.

summary>

Here is the call graph for this function:

Member Function Documentation

◆ initialize()

void Twitter_wf::initialize ( void  )
inlineoverridevirtual

checks for Knowledge Trust Model (opitional), and add the Knowledge_Parser to Construct::message_parsers if one is not present.

Reimplemented from Social_Media_no_followers.

Here is the call graph for this function: