Construct version 5.4.4
An agent based modeling framework
|
Interaction Items is a container of three maps. Each map corresponds to a different datatype. More...
Public Types | |
enum class | item_keys : char { knowledge , alter , belief , ktm , btm , ktrust , twitter_event , facebook_event , feed_position , emotion , banned , upvotes , downvotes , subreddit , prev_banned , reddit_event } |
using | attribute_iterator = std::unordered_set< item_keys >::iterator |
using | attribute_const_iterator = std::unordered_set< item_keys >::const_iterator |
using | index_iterator = std::unordered_map< item_keys, unsigned int >::iterator |
using | index_const_iterator = std::unordered_map< item_keys, unsigned int >::const_iterator |
using | value_iterator = std::unordered_map< item_keys, float >::iterator |
using | value_const_iterator = std::unordered_map< item_keys, float >::const_iterator |
Public Member Functions | |
bool | contains (item_keys key) const |
InteractionItem & | set_knowledge_item (unsigned int knowledge_index) noexcept |
Sets an item to become a knowledge item. More... | |
InteractionItem & | set_knowledgeTM_item (unsigned int knowledge_index, unsigned int alter_agent) noexcept |
Sets an item to become a knowledge transactive memory item. More... | |
InteractionItem & | set_belief_item (unsigned int belief_index, float belief_value) noexcept |
Sets an item to become a belief item. More... | |
InteractionItem & | set_beliefTM_item (unsigned int belief_index, unsigned int alter_agent, float belief_value) noexcept |
Sets an item to become a belief transactive memory item. More... | |
InteractionItem & | set_knowledge_trust_item (unsigned int knowledge_index, float ktrust) noexcept |
Sets an item to become a knowledge trust item. More... | |
unsigned int | get_knowledge () const |
Parses an item for knowledge More... | |
std::tuple< unsigned int, unsigned int > | get_knowledgeTM () const |
Parses an item for knowledge transactive memory More... | |
std::tuple< unsigned int, float > | get_belief () const |
Parses an item for beliefs. More... | |
std::tuple< unsigned int, unsigned int, float > | get_beliefTM () const |
Parses an item for belief transactive memory. More... | |
std::tuple< unsigned int, float > | get_knowledge_trust () const |
Parses an item for knowledge trust. More... | |
void | clear (void) noexcept |
Clears all containers in item. More... | |
Static Public Member Functions | |||
static const std::string & | get_item_name (InteractionItem::item_keys key) | ||
Returns the name registered in InteractionItem::item_names for the submitted key. | |||
static InteractionItem::item_keys | get_item_key (const std::string &name) | ||
Returns the key registered in InteractionItem::item_names for the submitted name. More... | |||
static InteractionItem | create_knowledge_item (unsigned int knowledge_index) noexcept | ||
Creates a knowledge item using set_knowledge_item.
| |||
static InteractionItem | create_knowledgeTM_item (unsigned int knowledge_index, unsigned int alter_agent) noexcept | ||
Creates a knowledge transactive memory item using set_knowledgeTM_item. More... | |||
static InteractionItem | create_belief_item (unsigned int belief_index, float belief_value) noexcept | ||
Creates a belief item using set_beliefTM_item. More... | |||
static InteractionItem | create_beliefTM_item (unsigned int belief_index, unsigned int alter_agent, float belief_value) noexcept | ||
Creates a belief transactive memory item using set_beliefTM_item. More... | |||
static InteractionItem | create_knowledge_trust_item (unsigned int knowledge_index, float ktrust) noexcept | ||
Creates a knowledge trust item using set_knowledge_trust_item. More... | |||
Public Attributes | |
std::unordered_map< item_keys, unsigned int > | indexes |
std::unordered_map< item_keys, float > | values |
std::unordered_set< item_keys > | attributes |
Static Public Attributes | |
static std::unordered_map< InteractionItem::item_keys, std::string > | item_names |
Interaction Items is a container of three maps. Each map corresponds to a different datatype.
using InteractionItem::attribute_const_iterator = std::unordered_set<item_keys>::const_iterator |
summary>
using InteractionItem::attribute_iterator = std::unordered_set<item_keys>::iterator |
summary>
using InteractionItem::index_const_iterator = std::unordered_map<item_keys, unsigned int>::const_iterator |
summary>
using InteractionItem::index_iterator = std::unordered_map<item_keys, unsigned int>::iterator |
summary>
using InteractionItem::value_const_iterator = std::unordered_map<item_keys, float>::const_iterator |
summary> Calls InteractionItem::attributes::contains and returns the result.
using InteractionItem::value_iterator = std::unordered_map<item_keys, float>::iterator |
summary>
|
strong |
Keys used for an InteractionItem.
|
noexcept |
Clears all containers in item.
attributes, indexes, and values are cleared using unordered_map::clear.
Example
Output:
This item contains: knowledge index 5 This item contains: knowledge index: 5 belief index: 3 belief value: 0.4 This item contains: belief index: 5 belief value: 0.2
Complexity
Linear in container size of attributes, indexes, and values.
Iterator validity
All iterators, pointers, and references are invalidated.
Exception Safety
This member function never throws exceptions.
|
staticnoexcept |
Creates a belief item using set_beliefTM_item.
belief_index | Value the "belief" key in indexes is set to. |
belief_value | Value the "belief" key in values is set to. |
Example
Output:
This item contains: belief index: 5 belief value: 0.3
Complexity
This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes, indexes and values.
Iterator validity
In most cases, all iterators in the attributes, indexes, and values container remain valid with the only exception when any container is rehashed. See unordered_map::insert for further details.
Exception Safety
This member function never throws exceptions.
|
staticnoexcept |
Creates a belief transactive memory item using set_beliefTM_item.
belief_index | Value the "belief" key in indexes is set to. |
alter_agent | Value the "alter" key in indexes is set to. |
belief_value | Value the "belief" key in values is set to. |
Example
Output:
This item contains: belief index: 5 alter agent index: 4 belief value: 0.3
Complexity
This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes, indexes, and values.
Iterator validity
In most cases, all iterators in the attributes, indexes, and values container remain valid with the only exception when any container is rehashed. See unordered_map::insert for further details.
Exception Safety
This member function never throws exceptions.
|
staticnoexcept |
Creates a knowledge item using set_knowledge_item.
knowledge_index | Value the "knowledge" key in indexes is set to. |
Output:
This item contains: knowledge index: 5
Complexity
This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes and indexes.
Iterator validity
No changes to iterators for values. In most cases, all iterators in the attributes and indexes container remain valid with the only exception when either container is rehashed. See unordered_map::insert for further details.
Exception Safety
This member function never throws exceptions.
|
staticnoexcept |
Creates a knowledge trust item using set_knowledge_trust_item.
knowledge_index | Value the "knowledge" key in indexes is set to. |
ktrust | Value the "knowledge trust" key in values is set to. |
Example
Output:
This item contains: knowledge index: 5 knowledge trust value: 0.3
Complexity
This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes, indexes and values.
Iterator validity
In most cases, all iterators in the attributes, indexes, and values container remain valid with the only exception when any container is rehashed. See unordered_map::insert for further details.
Exception Safety
This member function never throws exceptions.
|
staticnoexcept |
Creates a knowledge transactive memory item using set_knowledgeTM_item.
knowledge_index | Value the "knowledge" key in indexes is set to. |
alter_agent | Value the "alter" key in indexes is set to. |
Example
Output:
This item contains: knowledge index: 5 alter agent index: 4
Complexity
This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes and indexes.
Iterator validity
No changes to iterators for values. In most cases, all iterators in the attributes and indexes container remain valid with the only exception when either container is rehashed. See unordered_map::insert for further details.
Exception Safety
This member function never throws exceptions.
std::tuple< unsigned int, float > InteractionItem::get_belief | ( | ) | const |
Parses an item for beliefs.
Item should be checked to ensure it contains beliefs (InteractionItem::contains(InteractionItem::item_keys::belief)).
Example
Output:
This item contains: belief index: 3 belief value: 0.4
Complexity
This function uses unordered_map::find.
Average case: constant.
Worst case: linear in container size of attributes, indexes, and values.
Iterator validity
No changes.
Exception Safety
An assertion is raised when indexes does not contain an entry with the key InteractionItem::item_keys::belief or values does not contain an entry with the key InteractionItem::item_keys::belief.
std::tuple< unsigned int, unsigned int, float > InteractionItem::get_beliefTM | ( | ) | const |
Parses an item for belief transactive memory.
Item should be checked to ensure it contains beliefs (InteractionItem::contains(InteractionItem::item_keys::btm)).
Example
Output:
This item contains: belief index: 3 alter agent index: 5 belief value: 0.4
Complexity
This function uses unordered_map::find.
Average case: constant.
Worst case: linear in container size of attributes, indexes, and values.
Iterator validity
No changes.
Exception Safety
An assertion is raised when indexes does not contain an entry with the key InteractionItem::item_keys::belief or InteractionItem::item_keys::alter or values does not contain an entry with the key InteractionItem::item_keys::belief.
|
static |
Returns the key registered in InteractionItem::item_names for the submitted name.
summary>
unsigned int InteractionItem::get_knowledge | ( | ) | const |
Parses an item for knowledge
Item should be checked to ensure it contains knowledge (InteractionItem::contains(InteractionItem::item_keys::knowledge)).
Example
Output:
This item contains: knowledge index: 3
Complexity
This function uses unordered_map::find.
Average case: constant.
Worst case: linear in container size of attributes and indexes.
Iterator validity
No changes.
Exception Safety
An assertion is raised when indexes does not contain an entry with the key InteractionItem::item_keys::knowledge.
std::tuple< unsigned int, float > InteractionItem::get_knowledge_trust | ( | ) | const |
Parses an item for knowledge trust.
Item should be checked to ensure it contains knowledge turst (InteractionItem::contains(InteractionItem::item_keys::ktrust)).
Example
Output:
This item contains: knowledge index: 3 knowledge trust: 0.4
Complexity
This function uses unordered_map::find.
Average case: constant.
Worst case: linear in container size of attributes, indexes, and values.
Iterator validity
No changes.
Exception Safety
An assertion is raised when an item's indexes does not contain the key InteractionItem::item_keys::knowledge, or values does not contain the key InteractionItem::item_keys::ktrust.
std::tuple< unsigned int, unsigned int > InteractionItem::get_knowledgeTM | ( | ) | const |
Parses an item for knowledge transactive memory
Item should be checked to ensure it contains knowledge transactive memory (InteractionItem::contains(InteractionItem::item_keys::ktm)).
Example
Output:
This item contains: knowledge index: 3 alter agent index: 4
Complexity
This function uses unordered_map::find.
Average case: constant.
Worst case: linear in container size of attributes and indexes.
Iterator validity
No changes.
Exception Safety
An assertion is raised when indexes does not contain an entry with the key InteractionItem::item_keys::knowledge or InteractionItem::item_keys::alter.
|
noexcept |
Sets an item to become a belief item.
Adds InteractionItem::item_keys::belief to the item's attributes. Sets the item's indexes[InteractionItem::item_keys::belief] to the belief index and the item's values[InteractionItem::item_keys::belief] to the belief value.
belief_index | Value the "belief" key in indexes is set to. |
belief_value | Value the "belief" key in values is set to. |
Example
Output:
This item contains: belief index: 5 belief value: 0.3
Complexity
This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes, indexes and values.
Iterator validity
In most cases, all iterators in the attributes, indexes, and values container remain valid with the only exception when any container is rehashed. See unordered_map::insert for further details.
Exception Safety
This member function never throws exceptions.
|
noexcept |
Sets an item to become a belief transactive memory item.
Adds the following keys to the item's attributes:
Updates the following data structures:
belief_index | Value the "belief" key in indexes is set to. |
alter_agent | Value the "alter" key in indexes is set to. |
belief_value | Value the "belief" key in values is set to. |
Example
Output:
This item contains: belief index: 5 alter agent index: 4 belief value: 0.3
Complexity
This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes, indexes, and values.
Iterator validity
In most cases, all iterators in the attributes, indexes, and values container remain valid with the only exception when any container is rehashed. See unordered_map::insert for further details.
Exception Safety
This member function never throws exceptions.
|
noexcept |
Sets an item to become a knowledge item.
Adds item_keys::knowledge to the item's attributes. Adds the corresponding index to the item's indexes using the same key.
knowledge_index | Value the "knowledge" key in indexes is set to. |
Example:
Output:
This item contains: knowledge index: 5
Complexity
This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes and indexes.
Iterator validity
No changes to iterators for values. In most cases, all iterators in the attributes and indexes container remain valid with the only exception when either container is rehashed. See unordered_map::insert for further details.
Exception Safety
This member function never throws exceptions.
|
noexcept |
Sets an item to become a knowledge trust item.
Adds InteractionItem::item_keys::knowledge and InteractionItem::item_keys::ktrust to the item. Sets indexes[InteractionItem::item_keys::knowledge] to the knowledge index and values[InteractionItem::item_keys::ktrust] to the knowledge trust.
knowledge_index | Value the "knowledge" key in indexes is set to. |
ktrust | Value the "knowledge trust" key in values is set to. |
Example
Output:
This item contains: knowledge index: 5 knowledge trust value: 0.3
Complexity
This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes, indexes and values.
Iterator validity
In most cases, all iterators in the attributes, indexes, and values container remain valid with the only exception when any container is rehashed. See unordered_map::insert for further details.
Exception Safety
This member function never throws exceptions.
|
noexcept |
Sets an item to become a knowledge transactive memory item.
Adds InteractionItem::item_keys::ktm, InteractionItem::item_keys::knowledge, and InteractionItem::item_keys::alter to the item's attributes. The knowledge index is saved at indexes[InteractionItem::item_keys::knowledge] and the alter index is saved at indexes[InteractionItem::item_keys::alter].
knowledge_index | Value the "knowledge" key in indexes is set to. |
alter_agent | Value the "alter" key in indexes is set to. |
Example
Output:
This item contains: knowledge index: 5 alter agent index: 4
Complexity
This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes and indexes.
Iterator validity
No changes to iterators for values. In most cases, all iterators in the attributes and indexes container remain valid with the only exception when either container is rehashed. See unordered_map::insert for further details.
Exception Safety
This member function never throws exceptions.
|
static |