Construct version 5.4.4
An agent based modeling framework
Construct Struct Reference

The API class that coordinates the transfer of information between classes. More...

Collaboration diagram for Construct:

Public Member Functions

 Construct ()
 Distributes pointers, prints the version number, records starting time, and sets dynet::end_early::stop = false.
 
void load_from_xml (const std::string &fname)
 Imports information from a Construct input xml file in to Construct More...
 
bool run ()
 Runs the simulation. More...
 
bool contains_parser (const std::string &name)
 Returns true if the named parser is contained in Construct::message_parsers, false otherwise.
 
void addMessage (const InteractionMessage &msg) noexcept
 If the message is valid, its added to the front of the interaction_message_queue.
 
void addMessage (InteractionMessage &&msg) noexcept
 If the message is valid, its added to the front of the interaction_message_queue. More...
 
bool intercept (InteractionItem &item, unsigned int sender, unsigned int receiver, const CommunicationMedium *medium)
 

Public Attributes

time_t begTim = 0
 Time set at construction.
 
time_t loadtime = 0
 
time_t simulation_start = 0
 
time_t cycle_start = 0
 
time_t cycle_end = 0
 
time_t simulation_end = 0
 
Random random
 The manager that produces random variables and ensures exact reproduction of results given a random seed.
 
NodesetManager ns_manager
 The manager that holds all nodesets.
 
GraphManager graph_manager
 The manager that holds all graphs/networks.
 
ModelManager model_manager
 The manager that holds all the models and executes all of their various functions.
 
OutputManager output_manager
 The manager that holds all outputs.
 
std::set< InteractionMessageParser * > message_parsers
 Holds all parsers that parse messages before models.
 
std::list< InteractionMessageinteraction_message_queue
 Messages in this queue are dispersed to the Model::communicate function and are cleared at the very end of a simulation cycle.
 
std::string working_directory = ""
 Directory for output.
 
std::string custom_library = ""
 File containing custom model and output library
 
unsigned int current_time = 0
 The current time period
 
unsigned int time_count = 1
 The size of the time nodeset and total number of time periods. Defaults to 1 when no time nodeset is found.
 
bool verbose_initialization = false
 Set to true if a verbose initialization is requested. More...
 
bool verbose_runtime = false
 Set to true if a verbose runtime is requested. More...
 

Static Public Attributes

static constexpr const char * version = "5.4.4"
 
static std::function< void(Construct &)> constructor_output
 
static std::function< void(Construct &)> loading_complete_output
 
static std::function< void(Construct &)> simulation_start_output
 
static std::function< void(Construct &)> cycle_end_output
 
static std::function< void(Construct &)> simulation_complete_output
 

Detailed Description

The API class that coordinates the transfer of information between classes.

This class primarily deals with 5 class managers and runs the main sequence of the program execution. Through this class the managers can communicate and request information, typically pointers to data structures. This class also executes the main loop that progresses the simulation over time.

Member Function Documentation

◆ addMessage()

void Construct::addMessage ( InteractionMessage &&  msg)
inlinenoexcept

If the message is valid, its added to the front of the interaction_message_queue.

summary> Calls and ands each return from each loaded model's Model::intercept.

◆ load_from_xml()

void Construct::load_from_xml ( const std::string &  fname)

Imports information from a Construct input xml file in to Construct

Parameters
fnameThe filename with either an absolute or relative path.

◆ run()

bool Construct::run ( )

Runs the simulation.

Begins the simulation cycle starting with initilaizing all models. All the contents of the simulation is contained in try catch statement. If any exceptions are raised, they are printed and this function will return false. Otherwise if the simulation completes, true is returned.

Returns
True if the simulation was completed, false otherwise.

Exception Safety

This function can only be called once. An assertion is raised if the function is called a second time on the same Construct instance.

Here is the call graph for this function:

Member Data Documentation

◆ constructor_output

std::function< void(Construct &)> Construct::constructor_output
static
Initial value:
= [](Construct& construct) {
dynet::cout << "Start time: " << std::ctime(&construct.begTim) << dynet::endl; }
The API class that coordinates the transfer of information between classes.
Definition: Construct.h:40

◆ cycle_end_output

std::function< void(Construct &)> Construct::cycle_end_output
static
Initial value:
= [](Construct& construct) {
dynet::cout << "Time step " << construct.current_time << " completed. Elapsed Time: ";
dynet::cout << (unsigned)(construct.cycle_end - construct.cycle_start) << " seconds" << dynet::endl << dynet::endl; }

◆ loading_complete_output

std::function< void(Construct &)> Construct::loading_complete_output
static
Initial value:
= [](Construct& construct) {
dynet::cout << "Construct loading complete. Elapsed time: ";
dynet::cout << (float)std::difftime(construct.loadtime, construct.begTim) << " second." << dynet::endl; }

◆ simulation_complete_output

std::function< void(Construct &)> Construct::simulation_complete_output
static
Initial value:
= [](Construct& construct) {
dynet::cout << "Construct simulation complete." << dynet::endl;
dynet::cout << "End time: " << std::ctime(&construct.simulation_end) << ", Elapsed time : ";
dynet::cout << (float)std::difftime(construct.simulation_end, construct.simulation_start) << " second." << dynet::endl; }

◆ simulation_end

time_t Construct::simulation_end = 0

summary>

◆ simulation_start_output

std::function< void(Construct &)> Construct::simulation_start_output
static
Initial value:
= [](Construct& construct) {
dynet::cout << "Construct simulation start time: " << std::ctime(&construct.simulation_start) << dynet::endl; }

◆ verbose_initialization

bool Construct::verbose_initialization = false

Set to true if a verbose initialization is requested.

In general a verbose initialization increases the amount of information the end user receives when initializing the simulation.

◆ verbose_runtime

bool Construct::verbose_runtime = false

Set to true if a verbose runtime is requested.

In general a verbose runtime increases the amount of information the end user receives when during run time. This includes readouts when the simulation executes model functions such as think and cleanup.