Construct version 5.4.4
An agent based modeling framework
Trust Struct Reference

Model that updates the trust in peices of knowledge. More...

Inheritance diagram for Trust:
Collaboration diagram for Trust:

Public Member Functions

 Trust (const dynet::ParameterMap &parameters, Construct &construct)
 Requires the knowledge network be already loaded, and requires various agent node attributes. More...
 
void initialize (void) override
 Moves the model to the front of the model list to ensure this model's communicate function is called first. More...
 
void update (void) override
 Add knowledge trust to knowledge items in messages if they do not already include them. More...
 
bool intercept (InteractionItem &item, unsigned int sender, unsigned int receiver, const CommunicationMedium *medium) override
 Allows for models to effect change to items created by other models. More...
 
void communicate (const InteractionMessage &msg) override
 Parses a message for knowledge trust and adds them to the relevant agent's transactive memory and updates the reader's trust in the sender. More...
 
void cleanup (void) override
 Updates each agent's knowledge trust based on the agent's transactive memory and their trust of their alters. More...
 
- 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 Graph< bool > & knowledge_net = graph_manager.load_required(graph_names::knowledge, nodeset_names::agents, nodeset_names::knowledge)
 Graph with name "knowledge network" that contains the knowledge bits that each agent knows.
 
Graph< float > & knowledge_trust_net
 Graph with name "knowledge trust network" that contains the true trust an agent has for a peice of knowledge being true. More...
 
Graph< std::map< unsigned int, float > > & kttm
 Graph with name "knowledge trust transactive memory network" that contains what each agent thinks another's knowledge trust is. More...
 
Graph< float > & agent_trust_net
 Graph with name "agent trust network" that contains how much each agents trusts each other agent. More...
 
const Graph< float > & knowledge_trust_resistance
 Graph with name "knowledge trust resistance network" that contains how quickly agents change their trust on a knowledge bit. More...
 
std::vector< float > agent_trust_resistance
 Converted float values from the agent node attribute "agent trust resistance".
 
std::vector< float > alter_trust_weight
 Converted float values from the agent node attribute "agent trust weight"
 
- 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

Model that updates the trust in peices of knowledge.

Constructor & Destructor Documentation

◆ Trust()

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

Requires the knowledge network be already loaded, and requires various agent node attributes.

If the trust and/or kttm networks were already loaded, for every element in the knowledge network that is false, the associated elements in the knowledge trust network are set to 0.5 and in the knowledge trust transactive memory network are removed.

Additionally, this model checks for the following agent node attributes and that their values fall in the required range.

  • "can send knowledge trust" ∈ {true,false}
  • "can receive knowledge trust" ∈ {true,false}
  • "agent trust resistance" ∈ [0,∞)
  • "alter trust weight" ∈ [0,∞)
Here is the call graph for this function:

Member Function Documentation

◆ cleanup()

void Trust::cleanup ( void  )
overridevirtual

Updates each agent's knowledge trust based on the agent's transactive memory and their trust of their alters.

Reimplemented from Model.

Here is the call graph for this function:

◆ communicate()

void Trust::communicate ( const InteractionMessage msg)
overridevirtual

Parses a message for knowledge trust and adds them to the relevant agent's transactive memory and updates the reader's trust in the sender.

Reimplemented from Model.

Here is the call graph for this function:

◆ initialize()

void Trust::initialize ( void  )
overridevirtual

Moves the model to the front of the model list to ensure this model's communicate function is called first.

Reimplemented from Model.

Here is the call graph for this function:

◆ intercept()

bool Trust::intercept ( InteractionItem item,
unsigned int  sender,
unsigned int  receiver,
const CommunicationMedium medium 
)
overridevirtual

Allows for models to effect change to items created by other models.

A model change add, modify, or remove information from an item based other submitted information. Also allows for models to control what InteractionItems get created. Senders and receiver indexes can include values from 0 to and including the size of the agent nodeset. Always check if the index is equal to the agent nodeset size before accessing a node or network value. The medium can be a node in the medium nodeset, a medium for a specific model, or a null pointer. Always check that a node is not a null pointer before derefrencing it. Complexity and exceptions depend entirely on each models specific implementation. By default, models allow items to be created without modifying them.

Parameters
itemThe InteractionItem that is being created. This item can modified as each model sees fit.
senderThe index for the agent that is the source of the InteractionItem.
receiverThe index for the agent that is receiving the item. If the item does not have an intended recipient, its value will equal the agent nodeset size.
mediumThe communication medium intended for the item. If the medium is not yet chosen, it will be a null pointer. The medium may or may not be in the medium nodeset and there are no restraints on what index the medium could have.
Returns
Whether the item should be allowed to continue to exist (false) or if item should be discarded (true).

Example

item.set_knowledge(5);
knowledge_trust_net.at(4, 5) = 0.2;
auto [k, trust] = item.get_knowledge_trust();
std::cout << trust << std::endl;
virtual link_type & at(unsigned int row, unsigned int col)=0
Gets a reference to the specified link value.
const std::string TRUST
Definition: Model.h:306
ModelManager model_manager
The manager that holds all the models and executes all of their various functions.
Definition: Construct.h:111
Interaction Items is a container of three maps. Each map corresponds to a different datatype.
Definition: InteractionMessage.h:33
std::tuple< unsigned int, float > get_knowledge_trust() const
Parses an item for knowledge trust.
Definition: InteractionMessage.cpp:148
Construct & construct
Definition: Model.h:75
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.
Definition: Model.h:177
Model * get_model(const std::string &name)
Definition: ModelManager.h:38
Graph< float > & knowledge_trust_net
Graph with name "knowledge trust network" that contains the true trust an agent has for a peice of kn...
Definition: KnowledgeTrust.h:48

Output:

0.2

Reimplemented from Model.

Here is the call graph for this function:

◆ update()

void Trust::update ( void  )
overridevirtual

Add knowledge trust to knowledge items in messages if they do not already include them.

Reimplemented from Model.

Here is the call graph for this function:

Member Data Documentation

◆ agent_trust_net

Graph<float>& Trust::agent_trust_net
Initial value:
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 agent_trust
Definition: GraphManager.h:45
const std::string agents
Definition: NodesetManager.h:14
GraphManager & graph_manager
Definition: Model.h:77

Graph with name "agent trust network" that contains how much each agents trusts each other agent.

◆ knowledge_trust_net

Graph<float>& Trust::knowledge_trust_net
Initial value:
const bool col_dense
Definition: Graph.h:111
const bool row_dense
True if the row representation is dense, false if the representation is sparse.
Definition: Graph.h:117
const std::string k_trust
Definition: GraphManager.h:109
const std::string knowledge
Definition: NodesetManager.h:16
const Graph< bool > & knowledge_net
Graph with name "knowledge network" that contains the knowledge bits that each agent knows.
Definition: KnowledgeTrust.h:43

Graph with name "knowledge trust network" that contains the true trust an agent has for a peice of knowledge being true.

◆ knowledge_trust_resistance

const Graph<float>& Trust::knowledge_trust_resistance
Initial value:
const std::string ktrust_resist
Definition: GraphManager.h:111

Graph with name "knowledge trust resistance network" that contains how quickly agents change their trust on a knowledge bit.

◆ kttm

Graph<std::map<unsigned int, float> >& Trust::kttm
Initial value:
= graph_manager.load_optional(graph_names::kttm, std::map<unsigned int, float>(),
const std::string kttm
Definition: GraphManager.h:127

Graph with name "knowledge trust transactive memory network" that contains what each agent thinks another's knowledge trust is.