Construct version 5.4.4
An agent based modeling framework
|
Manages all graphs in Construct. More...
Classes | |
struct | set_of_generators |
Class that contains the set of all generators Construct can use on a Graph. More... | |
Public Member Functions | |
bool | is_imported (Typeless_Graph *graph) |
Returns true if the submitted graph was imported before model loading. | |
Graph_Intermediary | load_required (const std::string &name, const Nodeset *src, const Nodeset *trg, const Nodeset *slc=nullptr) const |
Finds a loaded Graph and returns it via a proxy class. More... | |
Graph_Intermediary | load_required (const std::string &name, const Nodeset &src, const Nodeset &trg) |
Graph_Intermediary | load_required (const std::string &name, const Nodeset &src, const Nodeset &trg, const Nodeset &slc) |
Graph_Intermediary | load_required (const std::string &name, const std::string &source_nodeset, const std::string &target_nodeset, const std::string &slice_nodeset="") const |
Similar to GraphManager::load_required(const std::string&, const Nodeset*, const Nodeset*, const Nodeset*). More... | |
Graph_Intermediary | load_required (const std::string &name, const std::string &source_nodeset, const std::string &target_nodeset, const std::string &slice_nodeset="") |
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. More... | |
Graph_Intermediary | load_optional (const std::string &name, const Nodeset &src, const Nodeset &trg) |
Graph_Intermediary | load_optional (const std::string &name, const Nodeset &src, const Nodeset &trg, const Nodeset &slc) |
Graph_Intermediary | load_optional (const std::string &name, const std::string &source_nodeset, const std::string &target_nodeset, const std::string &slice_nodeset="") const |
Similar to GraphManager::load_optional(const std::string&, const Nodeset*, const Nodeset*, const Nodeset*). More... | |
Graph_Intermediary | load_optional (const std::string &name, const std::string &source_nodeset, const std::string &target_nodeset, const std::string &slice_nodeset="") |
template<typename T > | |
Graph_Intermediary | load_optional (const std::string &name, const T &vals, const Nodeset *src, bool row_dense, const Nodeset *trg, bool col_dense, const Nodeset *slc=nullptr) |
Finds a Graph, creates a new Graph if it can't be found, and returns it via a proxy class. More... | |
template<typename T > | |
Graph_Intermediary | load_optional (const std::string &name, const T &vals, const Nodeset &src, bool row_dense, const Nodeset &trg, bool col_dense) |
template<typename T > | |
Graph_Intermediary | load_optional (const std::string &name, const T &vals, const Nodeset &src, bool row_dense, const Nodeset &trg, bool col_dense, const Nodeset &slc) |
template<typename T > | |
Graph_Intermediary | load_optional (const std::string &name, const T &vals, const std::string &source_nodeset, bool row_dense, const std::string &target_nodeset, bool col_dense, const std::string &slice_nodeset="") |
Similar to GraphManager::load_optional(const std::string&, const T&, const Nodeset*, bool, const Nodeset*, bool, const Nodeset*). More... | |
Typeless_Graph * | get_network (const std::string &name) noexcept |
Finds the parent class pointer for the requested Graph. More... | |
void | import_network (Typeless_Graph *graph) |
Causes this manager to take ownership of the graph. More... | |
void | export_network (Typeless_Graph *graph) noexcept |
Causes this manager to relieve its ownership of the graph. More... | |
Public Attributes | |
std::function< void(Typeless_Graph &)> | adding_network |
std::set< Typeless_Graph * > | imported_graphs |
The set of graphs imported before model loading. | |
set_of_generators | generators |
Manages all graphs in Construct.
Graphs are the primary data storage class for information connecting more than one node. Ex. which agents can interact with which other agent, which agent has which knowledge, which knowledge can be used on a communication medium. Construct when parsing an input xml file will create a graph and add data to based on the input. This included adding the specified links and applying any generators in the associated XML element.
The graph manager allows developers to require that a graph be created before a model is constructed or that it be optional. Using load_required will search for the specified graph and ensure that its dimension's match the developers specifications and data type. Exceptions are thrown any if any of these steps fail. By contrast, load_optional will performs similar checks on the dimensions and data type, but returns a null pointer if the graph isn't found. An overload of load_optional will create a graph if the graph is not found using the submitted dimensions, representation, and default value. Both functions return a Graph_Intermediary wrapping the returned Typeless_Graph. When cast, this object will automatically convert the wrapped pointer to either a Graph pointer or reference assuming the Typless_Graph::edge_type matches the conversion type.
Graphs that are loaded by xml file parsing are added to the imported_graphs member. In addition, any graph that is imported via import_network is added to the same member. Any Graph can be exported from the GraphManager. Graphs that are exported will not be deallocated by the GraphManager when itself is deallocated. Conversly, any Graph that is imported will be deallocated by the GraphManager if it is not exported before deallocation. Graphs that are exported are no longer contained in the GraphManager and can no
|
noexcept |
Causes this manager to relieve its ownership of the graph.
This Typeless_Graph is removed from the container and will not be deallocated when this manager is deallocated. This can be used to save the Typeless_Graph for a future Construct instance without copying the old contents.
graph | The Typeless_Graph that this manager is relieving its owership of. |
Exception Safety
No-throw guarantee: this member function never throws exceptions.
|
noexcept |
Finds the parent class pointer for the requested Graph.
name | Name of the requested Graph. |
Example
Output:
knowledge network is currently available.
Complexity
Constant.
Exception Safety
Strong Guarantee: This function never throws exceptions.
void GraphManager::import_network | ( | Typeless_Graph * | graph | ) |
Causes this manager to take ownership of the graph.
This Typeless_Graph is added to the container and it is deallocated when this manager is deallocated. This can be used to import a Typeless_Graph from a previous Construct instance without copying the old contents.
graph | The Typeless_Graph that this manager is taking owership of. |
Exception Safety
A dynet::already_exists exception is thrown if a Typeless_Graph with the same name already exists.
Graph_Intermediary GraphManager::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.
Graphs are identified by their name. Once the graph has been identified, its row and column nodeset dimensions are compared with the submitted nodesets. This ensures an imported graph's dimensions are correct. Exceptions are raised if it's dimensions do not match. If the Graph is not found, the returned proxy class will hold a null pointer.
The returned object is a wrapper for the graph. This object can be automatically converted to a graph of the correct template type. If Graph::edge_type does not correspond to the requested type, an exception is raised. Additionally this object is converted to a pointer or reference automatically. An exception is raised if the proxy holding a null pointer is converted to a reference.
name | Name of the graph being requested. |
src | The source nodeset that the requested graph must match. |
trg | The target nodeset that the requested graph must match. |
slc | The slice nodeset that the requested graph must match. Two dimensional graph's do not require a slice nodeset. |
Example
Complexity
Constant.
Exception Safety If the graph can not be found, a null pointer is returned. Otherwise, if either input source, target, or slice nodeset pointers do not equal the respective pointers in the requested graph, or the requested graph's edge_type does not match the corresponding dynet::get_edge_type for the template instantiation, a dynet::construct_exception is thrown.
Graph_Intermediary GraphManager::load_optional | ( | const std::string & | name, |
const std::string & | source_nodeset, | ||
const std::string & | target_nodeset, | ||
const std::string & | slice_nodeset = "" |
||
) | const |
Similar to GraphManager::load_optional(const std::string&, const Nodeset*, const Nodeset*, const Nodeset*).
For each nodeset name string submitted, a Nodeset pointer is queried from the NodesetManager. These are then submitted to the overload function compliment of this function.
Graph_Intermediary GraphManager::load_optional | ( | const std::string & | name, |
const T & | vals, | ||
const Nodeset * | src, | ||
bool | row_dense, | ||
const Nodeset * | trg, | ||
bool | col_dense, | ||
const Nodeset * | slc = nullptr |
||
) |
Finds a Graph, creates a new Graph if it can't be found, and returns it via a proxy class.
Graphs are identified by their name. Once the graph has been identified, its row and column nodeset dimensions are compared with the submitted nodesets. This ensures an imported graph's dimensions are correct. Exceptions are raised if it's dimensions do not match. If the Graph is not found, a Graph is created with default values, dimensions, and represenations based on inputs.
The returned object is a wrapper for the graph. This object can be automatically converted to a graph of the correct template type. If Graph::edge_type does not correspond to the requested type, an exception is raised. Additionally this object is converted to a pointer or reference automatically. An exception is raised if the proxy holding a null pointer is converted to a reference.
name | Name of the graph being requested. |
vals | If a graph is made, this parameter sets its default value. |
src | The source nodeset that the requested graph must match. |
row_dense | If a graph is made, the graph's source dimension (rows) will be dense if parameter is set to true, otherwise the dimension will be sparse. |
trg | The target nodeset that the requested graph must match. |
col_dense | If a graph is made, the graph's target dimension (columns) will be dense if parameter is set to true, otherwise the dimension will be sparse. |
slc | The slice nodeset that the requested graph must match. Two dimensional graph's do not require a slice nodeset. |
Example
Complexity
Constant.
Exception Safety If a graph already exists and either input source, target, or slice nodeset pointers do not equal the respective pointers in the requested graph, or the requested graph's edge_type does not match the corresponding dynet::get_edge_type for the template instantiation, a dynet::construct_exception is thrown.
Graph_Intermediary GraphManager::load_optional | ( | const std::string & | name, |
const T & | vals, | ||
const std::string & | source_nodeset, | ||
bool | row_dense, | ||
const std::string & | target_nodeset, | ||
bool | col_dense, | ||
const std::string & | slice_nodeset = "" |
||
) |
For each nodeset name string submitted, a Nodeset pointer is queried from the NodesetManager. These are then submitted to the overload function compliment of this function.
Graph_Intermediary GraphManager::load_required | ( | const std::string & | name, |
const Nodeset * | src, | ||
const Nodeset * | trg, | ||
const Nodeset * | slc = nullptr |
||
) | const |
Finds a loaded Graph and returns it via a proxy class.
Graphs are identified by their name. Once the graph has been identified, its row and column nodeset dimensions are compared with the submitted nodesets. This ensures an imported graph's dimensions are correct. Exceptions are raised if the graph can't be found or if it's dimensions do not match.
The returned object is a wrapper for the graph. This object can be automatically converted to a graph of the correct template type. If Graph::edge_type does not correspond to the requested type, an exception is raised. Additionally this object is converted to a pointer or reference automatically.
name | Name of the graph being requested. |
src | The source nodeset that the requested graph must match. |
trg | The target nodeset that the requested graph must match. |
slc | The slice nodeset that the requested graph must match. Two dimensional graph's do not require a slice nodeset. |
Example
Complexity
Constant.
Exception Safety
If either input source, target, or slice nodeset pointers do not equal the respective pointers in the requested graph, or the requested graph's edge_type does not match the corresponding dynet::get_edge_type for the template instantiation a dynet::construct_exception is thrown. If the graph can not be found, a dynet::could_not_find_network is thrown.
Graph_Intermediary GraphManager::load_required | ( | const std::string & | name, |
const std::string & | source_nodeset, | ||
const std::string & | target_nodeset, | ||
const std::string & | slice_nodeset = "" |
||
) | const |
Similar to GraphManager::load_required(const std::string&, const Nodeset*, const Nodeset*, const Nodeset*).
For each nodeset name string submitted, a Nodeset pointer is queried from the NodesetManager. These are then submitted to the overload function compliment of this function.