Construct version 5.3.9
An agent based modeling framework
|
An interaction model which recreates a social media feed to dictate interactions. More...
Classes | |
struct | default_media_user |
Class that implements the behavior of a user on the social media. More... | |
class | event_container |
Container for media_events with various restrictions More... | |
struct | media_event |
A data structure to represent a tweet, facebook post, or any other social media event. More... | |
struct | media_user |
Base class for the behavior of users on the social media. More... | |
Public Member Functions | |
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 (const std::string &_media_name, 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 void | load_users () |
Loads the media_users into users. More... | |
void | think (void) |
Agents read events in their feed and create messages based on the read events. More... | |
void | initialize (void) |
checks for Knowledge Trust Model (opitional), and Knowledge Parsing Model (required). More... | |
void | communicate (InteractionMessageQueue::iterator msg) |
Parses messages that contain the Social_Media_no_followers::event key in their attributes. More... | |
void | cleanup (void) |
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 void | update_feeds (void) |
Updates each user's feeds. More... | |
Public Member Functions inherited from Model | |
Model (Construct *_construct, const std::string &name) | |
Constructor for all models in Construct. More... | |
Model (const std::string &name) | |
Constructor for the PlaceHolder model. 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 (InteractionMessageQueue::iterator 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... | |
Public Attributes | |
const Nodeset * | agents = ns_manager->get_nodeset(nodeset_names::agents) |
Pointer to the "agent" nodeset. | |
const Nodeset * | knowledge = 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. | |
InteractionItem::item_keys | event_key = InteractionItem::item_keys::twitter_event |
The item key added to all messages created by this model. | |
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. | |
std::vector< std::vector< media_event * > > | users_feed |
Each user's feed of events with the first dimension corresponding to each user. | |
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. | |
unsigned int & | time |
The current time period. | |
std::string | media_name |
The prefix for some of the node attributes names parsed by the media_user class. | |
const 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 = 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. | |
Public Attributes inherited from Model | |
Construct *const | construct |
GraphManager *const | graph_manager |
NodesetManager *const | ns_manager |
Random *const | random |
const std::string | name |
Name of the model. Set by the Model constructor. | |
bool | valid |
If member is false, the model's functions are not called. | |
An interaction model which recreates a social media feed to dictate interactions.
This model uses the media_event data structure to represent and track the event tree/cascade. Agents create events which are stored in Social_Media_no_followers::list_of_events. These events can be created sponateously or in response to reading an event. What actions are taken depends on how classes derived from media_user implement the virtual functions. Future developers may wish to modify the underlying structure of this model. For that reason, a set of virtual functions have been implemented for modifying how feeds are updated, and how InteractionMessagess are created based on read events.
Updating feeds is handled by Social_Media_no_followers::update_feeds and dictate how the feeds are ordered. New events are added to the feed and old/read event are removed. An event is old when Social_Media_no_followers::time * Social_Media_no_followers::dt - media_event::last_used > Social_Media_no_followers::age. New events are grouped by user by events that mention that user or responds to them. The other group contains all other events. Both groups are sorted by their score which is equal to media_event::time_stamp * media_event::child_size(). The groups are then combined for each user with mentions and responses first. Finally 10% of the entire feed is stochastically swapped to sprinkle new content into the front of a users feed.
All information that is to be conveyed in messages is handled by Social_Media_no_followers::append_message. Because additional information may added to events than what is currently developed, this will allow developers to add the additional information in the messages being passed around based on the event being read. This function only appends the message items and does not create the message that will be added to the message queue. The message sender is the author of the event being read, and is not always the case that the event submitted to the function is the same event being read. In the case where the events differ, the author of that event should be added as an alter in the InteractionItem.
Social_Media_no_followers::media_user represents the agents operating on this social media. The base class provides a template for how the Social_Media asks how a user should respond to information. Classes derived from Social_Media_no_followers::media_user such as Social_Media_no_followers::default_media_user details the behavior of agents. Agents can be asked how many events they wish to read via Social_Media_no_followers::media_user::get_read_count(). Similarily an agent can be asked by Social_Media_no_followers whether they wish to reply to an event they're reading via Social_Media_no_followers::media_user::reply(). Customs users can be created via the API. Social_Media_no_followers::load_users will call the API function create_custom_media_user_no_followers if it is present in the library to fill pointers in Social_Media_no_followers::users.
Social_Media_no_followers::Social_Media_no_followers | ( | const std::string & | _media_name, |
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 #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 |
Appends the array of InteractionItems based on the submitted event and the intended receiver of the message.
Reimplemented in SM_nf_emotions.
void Social_Media_no_followers::check_list_order | ( | ) | const |
Checks the list of events to make sure the time stamps are sorted in descending order.
To avoid floating point percision conflicts an event's time stamp is compared with the next event's time stamp - dt*.5.
|
virtual |
Feeds are updated, list_of_events::removed_events are cleared, and events are erased from list_of_events that have have become inactive.
Reimplemented from Model.
Reimplemented in Social_Media_with_followers.
|
virtual |
Parses messages that contain the Social_Media_no_followers::event key in their attributes.
Reimplemented from Model.
Reimplemented in Social_Media_with_followers.
|
virtual |
checks for Knowledge Trust Model (opitional), and Knowledge Parsing Model (required).
Reimplemented from Model.
|
inlinevirtual |
Loads the media_users into users.
Reimplemented in SM_nf_emotions, SM_wf_emotions, and Social_Media_with_followers.
|
virtual |
Agents read events in their feed and create messages based on the read events.
Reimplemented from Model.
|
virtual |
Updates each user's feeds.
New events created during the time step are added to each user's feeds while discarding read events. New events and unread events in each user's feed are grouped into two categories, those that reply to or mention the user and all other events. Within each category, events are sorted based on media_event::score which is set to media_event::child_size * media_event::time_stamp. The first category is placed first in a user's feed followed by the second group. After the events have been organized, stochastic shuffling is done on 10% of the feed to avoid a fully deterministic feed.
Reimplemented in Social_Media_with_followers.