Construct version 5.4.4
An agent based modeling framework
|
An Interaction Message is a container for InteractionItems. In addition a message has a sender, receiver, and medium. More...
Public Types | |
using | iterator = std::list< InteractionItem >::iterator |
using | const_iterator = std::list< InteractionItem >::const_iterator |
Public Member Functions | |
InteractionMessage (unsigned int senderAgentIndex, unsigned int receiverAgentIndex, const CommunicationMedium *_medium, const std::vector< InteractionItem > &interactionItems=std::vector< InteractionItem >()) | |
Creates a message of information to be sent from agent to agent. More... | |
InteractionMessage (unsigned int senderAgentIndex, unsigned int receiverAgentIndex, const CommunicationMedium *_medium, std::vector< InteractionItem > &&interactionItems) | |
InteractionMessage (const InteractionMessage &message) noexcept | |
InteractionMessage & | operator= (const InteractionMessage &message) noexcept |
InteractionMessage (InteractionMessage &&message) noexcept | |
InteractionMessage & | operator= (InteractionMessage &&message) noexcept |
iterator | begin (void) noexcept |
Returns an iterator pointer to the first element in the list of InteractionItems. More... | |
iterator | end (void) noexcept |
Returns an iterator pointer to the last element in the list of InteractionItems. More... | |
const_iterator | begin (void) const noexcept |
Returns a const_iterator pointer to the first element in the list of InteractionItems. More... | |
const_iterator | end (void) const noexcept |
Returns a const_iterator pointer to the beyond the last element in the list of InteractionItems. More... | |
InteractionItem & | front (void) |
InteractionItem & | back (void) |
unsigned int | size () noexcept |
Returns the number of elements of InteractionItems. More... | |
iterator | erase (iterator itr) noexcept |
Removes the InteractionItem at the iterator position. More... | |
bool | add_item (const InteractionItem &item) noexcept |
Adds the item to the list of InteractionItems. More... | |
bool | add_item (InteractionItem &&item) noexcept |
bool | add_knowledge_item (unsigned int knowledge_index) noexcept |
Uses add_item and InteractionItem::set_knowledge_item to add a knowledge item to the message. More... | |
bool | add_knowledgeTM_item (unsigned int knowledge_index, unsigned int alter) noexcept |
Uses add_item and InteractionItem::set_knowledgeTM_item to add a transactive memory knowledge item to the message. More... | |
bool | add_belief_item (unsigned int belief_index, float belief_value) noexcept |
Uses add_item and InteractionItem::set_belief_item to add a belief item to the message. More... | |
bool | add_beliefTM_item (unsigned int belief_index, unsigned int alter, float belief_value) noexcept |
Uses add_item and InteractionItem::set_beliefTM_item to add a transactive memory belief item to the message. More... | |
bool | add_knowledge_trust_item (unsigned int knowledge_index, float ktrust) noexcept |
Uses add_item and InteractionItem::set_knowledge_trust_item to add a knowledge trust item to the message. More... | |
bool | is_valid (void) const noexcept |
Public Attributes | |
std::list< InteractionItem > | items |
const CommunicationMedium * | medium |
The communication medium the message uses. More... | |
unsigned int | sender |
Agent index of the sender of the message. | |
unsigned int | receiver |
Agent index of the receiver of the message. | |
unsigned int | time_to_send |
The number of time periods until this message should be added to the InteractionMessageQueue. More... | |
An Interaction Message is a container for InteractionItems. In addition a message has a sender, receiver, and medium.
Messages are used send information from one agent to another agent. The sender constructs the message and the receiver parses the message. The medium that a message uses has broader implication for parsing, but is used to restrict how large a message can be in terms of number of InteractionItems. InteractionItems are stored in a vector
using InteractionMessage::iterator = std::list<InteractionItem>::iterator |
summary>
InteractionMessage::InteractionMessage | ( | unsigned int | senderAgentIndex, |
unsigned int | receiverAgentIndex, | ||
const CommunicationMedium * | _medium, | ||
const std::vector< InteractionItem > & | interactionItems = std::vector<InteractionItem>() |
||
) |
Creates a message of information to be sent from agent to agent.
Information in a message is in the form of a list of InteractionItems. Messages are created to transfer that information from the sender agent to the recieving agent. Messages are transferred using a CommunicationMedium. This medium is mainly responsible for restricting the number of InteractionItems in a message. During construction if the size of interactionItems is greater than the medium maximum message complexity, only elements up to the complexity value of the vector are inserted into the list. Otherwise the entire vector is copied to a private member.
If either interactionItem has size zero or medium is not a valid medium, the message becomes an empty message and #valid is set to false.
senderAgentIndex | Agent node index of the sender. The sender constructs the message. |
receiverAgentIndex | Agent node index of the receiver. The receiver parses messages that are sent to them. |
_medium | The CommunicationMedium used to send this message. |
interactionItems | A vector of InteractionItems to be included in a message with length capped by the medium's maximum message complexity. Defaults to an empty vector. |
Example
Output:
Message Sender: 5 Message Receiver: 6 Message Contents: knowledge belief
Complexity
Linear in interactionItem size or medium maximum message complexity, whichever is smaller.
Exception Safety
No throw guarantee: This constructor does not throw exceptions. If a problem occurs, the message will become an empty message in which #valid is set to false. summary>
InteractionMessage::InteractionMessage | ( | unsigned int | senderAgentIndex, |
unsigned int | receiverAgentIndex, | ||
const CommunicationMedium * | _medium, | ||
std::vector< InteractionItem > && | interactionItems | ||
) |
summary>
|
inlinenoexcept |
summary>
|
inlinenoexcept |
summary>
|
noexcept |
Uses add_item and InteractionItem::set_belief_item to add a belief item to the message.
belief_index | The index the belief item is set to. |
belief_value | The value of the belief. |
Example
Output:
Message Sender: 5 Message Receiver: 6 Message Contents: belief, index 4 value 0.3
Complexity
Combination of add_item and InteractionItem::set_belief_item complexity.
Iterator validity
If the list is equal to the medium max message complexity, the iterator at the beginning of the list is invalidated. If a reallocation happens due to the addition, all iterators, pointers and references related to the container are invalidated. Otherwise, only the end iterator is invalidated, and all iterators, pointers and references to elements are guaranteed to keep referring to the same elements they were referring to before the call.
Exception Safety
If the -DEBUG flag is used during compilation a warning is printed when the front of the list is removed. Otherwise, this function does not throw exceptions.
|
noexcept |
Uses add_item and InteractionItem::set_beliefTM_item to add a transactive memory belief item to the message.
belief_index | The index the belief item is set to. |
alter | The index the of the alter the knowledgeTM item is about. |
belief_value | The value of the belief. |
Example
Output:
Message Sender: 5 Message Receiver: 6 Message Contents: beliefTM, index 4 alter 4 value 0.3
Complexity
Combination of add_item and InteractionItem::set_beliefTM_item complexity.
Iterator validity
If the list is equal to the medium max message complexity, the iterator at the beginning of the list is invalidated. If a reallocation happens due to the addition, all iterators, pointers and references related to the container are invalidated. Otherwise, only the end iterator is invalidated, and all iterators, pointers and references to elements are guaranteed to keep referring to the same elements they were referring to before the call.
Exception Safety
If the -DEBUG flag is used during compilation a warning is printed when the front of the list is removed. Otherwise, this function does not throw exceptions.
|
noexcept |
Adds the item to the list of InteractionItems.
If size of the InteractionItem list is equal to the medium's max message complexity, the first item in the list is removed. This creates a first in, first out revolving door when many items are added.
item | Item to be added to the list of InteractionItems. |
Example
Output:
Message Sender: 5 Message Receiver: 6 Message Contents: knowledge belief
Complexity
Constant (amortized time, reallocation may happen). If a reallocation happens, the reallocation is itself up to linear in the entire size.
Iterator validity
If the list is equal to the medium max message complexity, the iterator at the beginning of the list is invalidated. If a reallocation happens due to the addition, all iterators, pointers and references related to the container are invalidated. Otherwise, only the end iterator is invalidated, and all iterators, pointers and references to elements are guaranteed to keep referring to the same elements they were referring to before the call.
Exception Safety
If the -DEBUG flag is used during compilation a warning is printed when the front of the list is removed. Otherwise, this function does not throw exceptions. summary>
|
noexcept |
Uses add_item and InteractionItem::set_knowledge_item to add a knowledge item to the message.
knowledge_index | The index the knowledge item is set to. |
Example
Output:
Message Sender: 5 Message Receiver: 6 Message Contents: knowledge, index 4
Complexity
Combination of add_item and InteractionItem::set_knowledge_item complexity.
Iterator validity
If the list is equal to the medium max message complexity, the iterator at the beginning of the list is invalidated. If a reallocation happens due to the addition, all iterators, pointers and references related to the container are invalidated. Otherwise, only the end iterator is invalidated, and all iterators, pointers and references to elements are guaranteed to keep referring to the same elements they were referring to before the call.
Exception Safety
If the -DEBUG flag is used during compilation a warning is printed when the front of the list is removed. Otherwise, this function does not throw exceptions.
|
noexcept |
Uses add_item and InteractionItem::set_knowledge_trust_item to add a knowledge trust item to the message.
knowledge_index | The index the knowledge item is set to. |
ktrust | Value the knowledge trust is set to. |
Example
Output:
Message Sender: 5 Message Receiver: 6 Message Contents: knowledge trust, index 4 value 0.3
Complexity
Combination of add_item and InteractionItem::set_knowledge_trust_item complexity.
Iterator validity
If the list is equal to the medium max message complexity, the iterator at the beginning of the list is invalidated. If a reallocation happens due to the addition, all iterators, pointers and references related to the container are invalidated. Otherwise, only the end iterator is invalidated, and all iterators, pointers and references to elements are guaranteed to keep referring to the same elements they were referring to before the call.
Exception Safety
If the -DEBUG flag is used during compilation a warning is printed when the front of the list is removed. Otherwise, this function does not throw exceptions.
|
noexcept |
Uses add_item and InteractionItem::set_knowledgeTM_item to add a transactive memory knowledge item to the message.
knowledge_index | The index the knowledgeTM item is set to. |
alter | The index the of the alter the knowledgeTM item is about. |
Example
Output:
Message Sender: 5 Message Receiver: 6 Message Contents: knowledgeTM, index 4 alter 4
Complexity
Combination of add_item and InteractionItem::set_knowledgeTM_item complexity.
Iterator validity
If the list is equal to the medium max message complexity, the iterator at the beginning of the list is invalidated. If a reallocation happens due to the addition, all iterators, pointers and references related to the container are invalidated. Otherwise, only the end iterator is invalidated, and all iterators, pointers and references to elements are guaranteed to keep referring to the same elements they were referring to before the call.
Exception Safety
If the -DEBUG flag is used during compilation a warning is printed when the front of the list is removed. Otherwise, this function does not throw exceptions.
|
inlinenoexcept |
Returns a const_iterator pointer to the first element in the list of InteractionItems.
Example
Output:
Message Sender: 5 Message Receiver: 6 This message contains: knowledge belief
Complexity
Constant.
Iterator validity
No changes.
Exception Safety
No-throw guarantee: this member function never throws exceptions.
|
inlinenoexcept |
Returns an iterator pointer to the first element in the list of InteractionItems.
Example
Output:
Message Sender: 5 Message Receiver: 6 Message Contents: knowledge belief
Complexity
Constant.
Iterator validity
No changes.
Exception Safety
No-throw guarantee: this member function never throws exceptions.
|
inlinenoexcept |
Returns a const_iterator pointer to the beyond the last element in the list of InteractionItems.
Example
Output:
Message Sender: 5 Message Receiver: 6 This message contains: knowledge belief
Complexity
Constant.
Iterator validity
No changes.
Exception Safety
No-throw guarantee: this member function never throws exceptions. summary>
|
inlinenoexcept |
Returns an iterator pointer to the last element in the list of InteractionItems.
Example
Output:
Message Sender: 5 Message Receiver: 6 Message Contents: knowledge belief
Complexity
Constant.
Iterator validity
No changes.
Exception Safety
No-throw guarantee: this member function never throws exceptions.
|
noexcept |
Removes the InteractionItem at the iterator position.
This reduces the size of the list by 1. Because the data structure is a list, inserting and removal at any position is efficient even in the middle of the sequence.
itr | Iterator position of the InteractionItem to be erased. |
Example
Output:
Message Sender: 5 Message Receiver: 6 Message Contents: knowledge belief New Message Contents: belief
Complexity
Linear on the number of elements erased (destructions) plus the number of elements after the last element deleted (moving).
Iterator validity
Iterators, pointers and references referring to the element removed by the function are invalidated. All other iterators, pointers, and references kepp their validity.
Exception Safety
If itr is valid, the function never throws exceptions. Otherwise, it causes undefined behavior.
|
inline |
summary>
|
inlinenoexcept |
summary>
|
inlinenoexcept |
Returns the number of elements of InteractionItems.
Example
Output:
This message contains 2 items.
Complexity
Constant.
Iterator validity
No changes.
Exception Safety
No-throw guarantee: this member function never throws exceptions.
const CommunicationMedium* InteractionMessage::medium |
The communication medium the message uses.
A message is only valid if its medium is valid. The number of InteractionItems holds is limited by a medium's maximum message complexity.
unsigned int InteractionMessage::time_to_send |
The number of time periods until this message should be added to the InteractionMessageQueue.
summary>