Construct version 5.4.4
An agent based modeling framework
CommunicationMedium Struct Reference

Class to contain the medium used by an InteractionMessage. More...

Public Member Functions

 CommunicationMedium (const Node &node)
 Constructor for a medium based on a medium node. More...
 
 CommunicationMedium (const std::string &name, unsigned int medium_node_index, float max_percent_learnable, unsigned int max_msg_complexity, unsigned int time_to_send)
 Constructor for a medium. More...
 

Public Attributes

const std::string name
 The medium's name.
 
const float max_percent_learnable
 maximum value the knowledge strength network can be increased to from a message with this medium
 
const unsigned int time_to_send
 how many timeperiods must pass before a message with this medium is sent to the central message queue
 
const unsigned int max_msg_complexity
 the maximum number of InteractionItem that can be included in a message with this medium
 
const unsigned int index
 The medium's node index.
 
const bool valid
 True if the medium is a valid medium.
 

Detailed Description

Class to contain the medium used by an InteractionMessage.

Constructor & Destructor Documentation

◆ CommunicationMedium() [1/2]

CommunicationMedium::CommunicationMedium ( const Node node)

Constructor for a medium based on a medium node.

The medium node is expected to have attributes "maximum message complexity", "maximum percent learnable", and "time to send". If these attributes are missing, a warning is issued and the medium is no longer valid.

Parameters
nodeIterator pointer to the medium node used to construct this medium.

Example

//the first medium node has the following attributes
// "maximum message complexity" : 1
// "maximum percent learnable" : 1
// "time to send" : 0
Nodeset* mediums = construct->getNodesetManager()->get_nodeset(nodeset_names::comm);
CommunicationMedium medium(mediums->begin());
std::cout << "Is this medium valid? " << medium.valid() << std::endl;
std::cout << "maxMsgComplexity: " << medium.get_msg_complexity() << std::endl;
std::cout << "maximumPercentLearnable: " << medium.get_max_percent_learnable() << std::endl;
std::cout << "time_to_send: " << medium.get_time_to_send() << std::endl;
A container for nodes.
Definition: NodesetManager.h:192
iterator begin(void) const
Returns an iterator pointing the beginning of the vector of nodes.
Definition: NodesetManager.cpp:8
const std::string comm
Definition: NodesetManager.h:22
Class to contain the medium used by an InteractionMessage.
Definition: CommunicationMedium.h:19

Output:

Is this medium valid? True
maxMsgComplexity: 1
maximumPercentLearnable: 1
time_to_send: 0

Exception Safety

If the node attributes are not found, a dynet::could_not_find_parameter exception is thrown. If the node attributes value could not be converted to the appropriate type, a dynet::could_not_convert exception is thrown.

◆ CommunicationMedium() [2/2]

CommunicationMedium::CommunicationMedium ( const std::string &  name,
unsigned int  medium_node_index,
float  max_percent_learnable,
unsigned int  max_msg_complexity,
unsigned int  time_to_send 
)

Constructor for a medium.

Parameters
nameName of the medium
medium_node_indexIndex of this medium in the "medium" Nodeset
max_percent_learnableMaximum amount of knowledge that can be learned via this medium.
max_msg_complexityLimits the size of a InteractionMessage that uses this medium.
time_to_sendNumber of timeperiods before this message is sent.

Example

int main()
{
CommunicationMedium medium("twitter", 0, 1, 1, 0);
std::cout << "Is this medium valid? " << medium.valid() << std::endl;
std::cout << "maxMsgComplexity: " << medium.get_msg_complexity() << std::endl;
std::cout << "maximumPercentLearnable: " << medium.get_max_percent_learnable() << std::endl;
std::cout << "time_to_send: " << medium.get_time_to_send() << std::endl;
}

Output:

Is this medium valid? True
maxMsgComplexity: 1
maximumPercentLearnable: 1
time_to_send: 0

Exception Safety

No-throw guarantee: this constructor never throws exceptions.