Construct version 5.4.4
An agent based modeling framework
GraphManager::set_of_generators Struct Reference

Class that contains the set of all generators Construct can use on a Graph. More...

Collaboration diagram for GraphManager::set_of_generators:

Public Member Functions

 set_of_generators (GraphManager *_graph_manager, Random *_random)
 
template<typename T >
void dynetml_generator (const dynet::ParameterMap &params, Graph< T > *graph)
 Imports a DyNetML formated xml file and parses the specified network in the Graph. More...
 
template<typename T >
void binary_generator_2d (const dynet::ParameterMap &params, Graph< T > *graph)
 Assigns a binary value randomly to each link in the Graph. More...
 
template<typename T >
void binary_generator_3d (const dynet::ParameterMap &params, Graph< std::vector< T > > *graph)
 Assigns a binary value randomly to each link in the Graph. More...
 
template<typename T >
void uniform_generator_2d (const dynet::ParameterMap &params, Graph< T > *graph)
 Assigns an iid unform random value to a fractions of links in the Graph. More...
 
template<typename T >
void uniform_generator_3d (const dynet::ParameterMap &params, Graph< std::vector< T > > *graph)
 Assigns an iid unform random value to a fractions of links in the Graph. More...
 
template<typename T >
void uniform_generator_3d (const dynet::ParameterMap &params, Graph< std::map< unsigned int, T > > *graph)
 Assigns an iid unform random value to a fractions of links in the Graph. More...
 
template<typename T >
void csv_generator_2d (const dynet::ParameterMap &params, Graph< T > *graph)
 Imports a csv file and parses each link in the Graph. More...
 
template<typename T >
void csv_generator_3d (const dynet::ParameterMap &params, Graph< std::vector< T > > *graph)
 Imports a csv file and parses each link in the Graph. More...
 
template<typename T >
void csv_generator_3d (const dynet::ParameterMap &params, Graph< std::map< unsigned int, T > > *graph)
 Imports a csv file and parses each link in the Graph. More...
 
template<typename T >
void perception_generator (const dynet::ParameterMap &params, Graph< std::vector< T > > *graph)
 Copies values from a 2d network with errors into a Graph. More...
 
template<typename T >
void perception_generator (const dynet::ParameterMap &params, Graph< std::map< unsigned int, T > > *graph)
 Copies values from a 2d network with errors into a Graph. More...
 

Public Attributes

GraphManager *const graph_manager
 
Random *const random
 

Detailed Description

Class that contains the set of all generators Construct can use on a Graph.

Member Function Documentation

◆ binary_generator_2d()

template<typename T >
void GraphManager::set_of_generators::binary_generator_2d ( const dynet::ParameterMap params,
Graph< T > *  graph 
)

Assigns a binary value randomly to each link in the Graph.

The generator is only applied on the bounding box defined by the parameters "src min", "src max", "trg min", and "trg max". If the "symmetrical" parameter is set to true, the link at (i,j) will equal the link at (j,i). Each link the generator is applied will be set 1 with probability from the "density" parameter, otherwise the link is set to zero.

Parameters
paramsSet of parameters that dictates the generator's function. Required parameters: "src min", "src max", "trg min", and "trg max" Optional parameters: "symmetrical" and "density"
graphThe Graph data structure that is being edited. Only 2d Graphs (slice_nodeset == NULL) can be used with this generator.

Complexity

Linear for each link within the bounding box if both graph dimensions are dense. If a dimension is sparse each link is an additional O(ln(n)) where n is the number of elements that don't equal the default value.

Exception Safety

If any of the required parameters are missing from the ParameterMap, a dynet::could_not_find_parameter is thrown. A dynet::could_not_convert_parameter is thrown if any of the values in the parameter map can not be converted to their proper types. These types need not correspond to the template instantiation data type. Finally, a dynet::out_of_range is thrown if a "density" parameter is included and its value is outside the range [0,1].

Here is the call graph for this function:

◆ binary_generator_3d()

template<typename T >
void GraphManager::set_of_generators::binary_generator_3d ( const dynet::ParameterMap params,
Graph< std::vector< T > > *  graph 
)

Assigns a binary value randomly to each link in the Graph.

The generator is only applied on the bounding box defined by the parameters "src min", "src max", "trg min", "trg max", "slc min", and "slc max". If the "symmetrical" parameter is set to true, for each permutation of i,j,k the links at (i,j)[k] will equal each other. Each link the generator is applied will be set 1 with probability from the "density" parameter, otherwise the link is set to zero.

Parameters
paramsSet of parameters that dictates the generator's function. Required parameters: "src min", "src max", "trg min", "trg max", "slc min", and "slc max" Optional parameters: "symmetrical" and "density"
graphThe Graph data structure that is being edited. Only 3d Graphs (slice_nodeset != NULL) with a dense slice dimension can be used with this generator.

Complexity

Linear for each link within the bounding box if both source and target dimensions are dense. If a dimension is sparse each link is an additional O(ln(n)) where n is the number of elements that don't equal the default value.

Exception Safety

If any of the required parameters are missing from the ParameterMap, a dynet::could_not_find_parameter is thrown. A dynet::could_not_convert_parameter is thrown if any of the values in the parameter map can not be converted to their proper types. These types need not correspond to the template instantiation data type. Finally, a dynet::out_of_range is thrown if a "density" parameter is included and its value is outside the range [0,1].

◆ csv_generator_2d()

template<typename T >
void GraphManager::set_of_generators::csv_generator_2d ( const dynet::ParameterMap params,
Graph< T > *  graph 
)

Imports a csv file and parses each link in the Graph.

Parameters
paramsSet of parameters that dictates the generator's function. Required parameters: "file"
graphThe Graph data structure that is being edited. Only 2d Graphs (slice_nodeset == NULL) can be used with this generator.

Example CSV file Graph has float links and has source and target dimension size of 4

0.1,1.2,3.4,5.9 3.9,4.2,3.3,1.7 0.3,0.4,5.2,1.4 4.2,0.5,2.2,1.8

Complexity

Linear for each link if both graph dimensions are dense. If a dimension is sparse each link is an additional O(ln(n)) where n is the number of elements that don't equal the default value.

Exception Safety

If required parameter is missing from the ParameterMap, a dynet::could_not_find_parameter is thrown. If the file could not be opened a dynet::could_not_open_file is thrown. If a dimension is not the correct length a dynet::csv_too_many_rows or dynet::csv_too_many_cols is thrown. If the value at each link can not be converted to the graph's data type, a dynet::could_not_convert_value is thrown.

Here is the call graph for this function:

◆ csv_generator_3d() [1/2]

template<typename T >
void GraphManager::set_of_generators::csv_generator_3d ( const dynet::ParameterMap params,
Graph< std::map< unsigned int, T > > *  graph 
)

Imports a csv file and parses each link in the Graph.

Parameters
paramsSet of parameters that dictates the generator's function. Required parameters: "file"
graphThe Graph data structure that is being edited. Only 3d Graphs (slice_nodeset != NULL) with a sparse slice dimension can be used with this generator.

Example CSV file Graph has bool links and has source and target dimension size of 4 and a slice dimension of 3.

{0:0,1:0},{1:1,2:1},{0:1,2:0},{0:0} {0:1,2:0},{0:0,1:0},{0:0,1:0},{2:0} {1:1,2:1},{0:1,2:0},{0:0,1:0},{} {0:0},{0:1,1:1,2:1},{0:1,2:0},{1:1,2:1}

Complexity

O(ln(m)) where m is size of a slice dimension for each link if both graph dimensions are dense. If a dimension is sparse each link is an additional O(ln(n)) where n is the number of elements that don't equal the default value.

Exception Safety

If required parameter is missing from the ParameterMap, a dynet::could_not_find_parameter is thrown. If the file could not be opened a dynet::could_not_open_file is thrown. If each slice element is not contained in curly brackets ({...}), a dynet::csv_missing_beginning_bracket or dynet::csv_missing_ending_bracket is thrown. If a dimension is not the correct length a dynet::csv_too_many_rows or dynet::csv_too_many_cols is thrown. If a slice index is out of range of the slice nodeset, a dynet::ns_index_out_of_range is thrown. If a slice index could not be converted to unsigned int, a dynet::could_not_convert_value is thrown. If the value at each link can not be converted to the graph's data type, a dynet::could_not_convert_value is thrown.

Here is the call graph for this function:

◆ csv_generator_3d() [2/2]

template<typename T >
void GraphManager::set_of_generators::csv_generator_3d ( const dynet::ParameterMap params,
Graph< std::vector< T > > *  graph 
)

Imports a csv file and parses each link in the Graph.

Parameters
paramsSet of parameters that dictates the generator's function. Required parameters: "file"
graphThe Graph data structure that is being edited. Only 3d Graphs (slice_nodeset != NULL) with a dense slice dimension can be used with this generator.

Example CSV file Graph has int links and has source and target dimension size of 4 and a slice dimension of 3.

{1,2,3},{3,2,1},{2,3,1},{2,1,3} {2,1,3},{1,2,3},{2,3,1},{3,2,1} {2,3,1},{2,1,3},{3,2,1},{1,2,3} {2,1,3},{3,2,1},{1,2,3},{2,3,1}

Complexity

Linear for each link if both graph dimensions are dense. If a dimension is sparse each link is an additional O(ln(n)) where n is the number of elements that don't equal the default value.

Exception Safety

If required parameter is missing from the ParameterMap, a dynet::could_not_find_parameter is thrown. If the file could not be opened a dynet::could_not_open_file is thrown. If each slice element is not contained in curly brackets ({...}), a dynet::csv_missing_beginning_bracket or dynet::csv_missing_ending_bracket is thrown. If a dimension is not the correct length a dynet::csv_too_many_rows, dynet::csv_too_many_cols, or dynet::csv_too_many_slcs is thrown. If the value at each link can not be converted to the graph's data type, a dynet::could_not_convert_value is thrown.

Here is the call graph for this function:

◆ dynetml_generator()

template<typename T >
void GraphManager::set_of_generators::dynetml_generator ( const dynet::ParameterMap params,
Graph< T > *  graph 
)

Imports a DyNetML formated xml file and parses the specified network in the Graph.

Parameters
paramsSet of parameters that dictates the generator's function. Required parameters: "file", "network name"
graphThe Graph data structure that is being edited. Only 2d Graphs (slice_nodeset == NULL) with default value of zero can be used with this generator.

Complexity

Linear for each link if both graph dimensions are dense. If a dimension is sparse each link is an additional O(ln(n)) where n is the number of elements that don't equal the default value.

Exception Safety

If either required parameters are missing from the ParameterMap, a dynet::could_not_find_parameter is thrown. If the Graph has a default value that does not equal zero, a dynet::construct_exception is thrown. Any parsing errors will throw a dynet::construct_exception, such as missing elements or attributes. A dynet::construct_exception is also thrown if the source or target node in a link can't be found or the optional value attribute can't be converted to the template instantiation data type.

◆ perception_generator() [1/2]

template<typename T >
void GraphManager::set_of_generators::perception_generator ( const dynet::ParameterMap params,
Graph< std::map< unsigned int, T > > *  graph 
)

Copies values from a 2d network with errors into a Graph.

The perception network is copied over into the Graph by using the perception network's source and target index as the graph's target and slice index respectively. Additionally a values at a source and target index are only copied over if the link in the influence network at the same indexes are true. Values are copied over with error.

The implementation of this noise is determined by the "noise implementation" parameter for Graphs with the float data type. In the "normal" implementation a normal distribution is sampled. In the "unit_normal" implementation, values in the range [0,1] are transformed into the range (-&infin,&infin), where a normal distribution is then sampled and transformed back into the range [0,1].

For Graphs with bool, int, and unsigned int, a simple not statement is done to flip the value. The frequency at which a value is flipped is determined by the parameters "false positive rate" and "false negative rate".

Parameters
paramsSet of parameters that dictates the generator's function. Required parameters: "perception network", "influence network", "src min", "src max", "trg min", "trg max", "slc min", "slc max" Required parameters for float graphs: "noise implementation", "variance" Required parameters for bool, int, and unsigned int graphs: "false positive rate", "false negative rate"
graphThe Graph data structure that is being edited. Only 3d Graphs (slice_nodeset != NULL) with a sparse slice dimension can be used with this generator.

Complexity

For each link complexity depends on the dimension representation of the graph, the perception network, and the influence network.

Exception Safety

If required parameter is missing from the ParameterMap, a dynet::could_not_find_parameter is thrown. If the "variance" parameter is less than or equal to zero, a dynet::out_of_range is thrown, as well as if "false negative rate", "false positive rate", and "density" is outside the range [0,1]. A dynet::unknown_value is thrown if the "noise implemenation" parameter is neither "normal" or "unit_normal". A dynet::construct_exception is thrown if a graph with edge_type of std::string is used.

◆ perception_generator() [2/2]

template<typename T >
void GraphManager::set_of_generators::perception_generator ( const dynet::ParameterMap params,
Graph< std::vector< T > > *  graph 
)

Copies values from a 2d network with errors into a Graph.

The perception network is copied over into the Graph by using the perception network's source and target index as the graph's target and slice index respectively. Additionally a values at a source and target index are only copied over if the link in the influence network at the same indexes are true. Values are copied over with error.

The implementation of this noise is determined by the "noise implementation" parameter for Graphs with the float data type. In the "normal" implementation a normal distribution is sampled. In the "unit_normal" implementation, values in the range [0,1] are transformed into the range (-&infin,&infin), where a normal distribution is then sampled and transformed back into the range [0,1].

For Graphs with bool, int, and unsigned int, a simple not statement is done to flip the value. The frequency at which a value is flipped is determined by the parameters "false positive rate" and "false negative rate".

Parameters
paramsSet of parameters that dictates the generator's function. Required parameters: "perception network", "influence network", "src min", "src max", "trg min", "trg max", "slc min", "slc max" Required parameters for float graphs: "noise implementation", "variance" Required parameters for bool, int, and unsigned int graphs: "false positive rate", "false negative rate"
graphThe Graph data structure that is being edited. Only 3d Graphs (slice_nodeset != NULL) with a dense slice dimension can be used with this generator.

Complexity

For each link complexity depends on the dimension representation of the graph, the perception network, and the influence network.

Exception Safety

If required parameter is missing from the ParameterMap, a dynet::could_not_find_parameter is thrown. If the "variance" parameter is less than or equal to zero, a dynet::out_of_range is thrown, as well as if "false negative rate", "false positive rate", and "density" is outside the range [0,1]. A dynet::unknown_value is thrown if the "noise implemenation" parameter is neither "normal" or "unit_normal". A dynet::construct_exception is thrown if a graph with edge_type of std::string is used.

◆ uniform_generator_2d()

template<typename T >
void GraphManager::set_of_generators::uniform_generator_2d ( const dynet::ParameterMap params,
Graph< T > *  graph 
)

Assigns an iid unform random value to a fractions of links in the Graph.

The generator is only applied on the bounding box defined by the parameters "src min", "src max", "trg min", and "trg max". If the "symmetrical" parameter is set to true, the link at (i,j) will equal the link at (j,i). A fraction of links equal to the "density" parameter is selected randomly and is set to sample from a uniform random distribution with range [min, max] where min is the "min" parameter and max is the "max" parameter.

Parameters
paramsSet of parameters that dictates the generator's function. Required parameters: "src min", "src max", "trg min", "trg max", "min", and "max" Optional parameters: "symmetrical" and "density"
graphThe Graph data structure that is being edited. Only 2d Graphs (slice_nodeset == NULL) can be used with this generator.

Complexity

Linear for each link within the bounding box if both graph dimensions are dense. If a dimension is sparse each link is an additional O(ln(n)) where n is the number of elements that don't equal the default value.

Exception Safety

If any of the required parameters are missing from the ParameterMap, a dynet::could_not_find_parameter is thrown. A dynet::could_not_convert_parameter is thrown if any of the values in the ParameterMap can not be converted to their proper types. These types need not correspond to the template instantiation data type. Finally, a dynet::out_of_range is thrown if the "density", "min", or "max" parameters are outside the range [0,1].

Here is the call graph for this function:

◆ uniform_generator_3d() [1/2]

template<typename T >
void GraphManager::set_of_generators::uniform_generator_3d ( const dynet::ParameterMap params,
Graph< std::map< unsigned int, T > > *  graph 
)

Assigns an iid unform random value to a fractions of links in the Graph.

The generator is only applied on the bounding box defined by the parameters "src min", "src max", "trg min", "trg max", "slc min", and "slc max". If the "symmetrical" parameter is set to true, for each permutation of i,j,k the links at (i,j)[k] will equal each other. A fraction of links equal to the "density" parameter is selected randomly and is set to sample from a uniform random distribution with range [min, max] where min is the "min" parameter and max is the "max" parameter.

Parameters
paramsSet of parameters that dictates the generator's function. Required parameters: "src min", "src max", "trg min", "trg max", "slc min", "slc max", "min", and "max" Optional parameters: "symmetrical" and "density"
graphThe Graph data structure that is being edited. Only 3d Graphs (slice_nodeset != NULL) with a sparse slice dimension can be used with this generator.

Complexity

O(ln(m)) where m is size of a slice dimension for each link within the bounding box if both source and target dimensions are dense. If a dimension is sparse each link is an additional O(ln(n)) where n is the number of elements that don't equal the default value.

Exception Safety

If any of the required parameters are missing from the ParameterMap, a dynet::could_not_find_parameter is thrown. A dynet::could_not_convert_parameter is thrown if any of the values in the parameter map can not be converted to their proper types. These types need not correspond to the template instantiation data type. Finally, a dynet::out_of_range is thrown if the "density", "min", "max" parameter is outside the range [0,1].

◆ uniform_generator_3d() [2/2]

template<typename T >
void GraphManager::set_of_generators::uniform_generator_3d ( const dynet::ParameterMap params,
Graph< std::vector< T > > *  graph 
)

Assigns an iid unform random value to a fractions of links in the Graph.

The generator is only applied on the bounding box defined by the parameters "src min", "src max", "trg min", "trg max", "slc min", and "slc max". If the "symmetrical" parameter is set to true, for each permutation of i,j,k the links at (i,j)[k] will equal each other. A fraction of links equal to the "density" parameter is selected randomly and is set to sample from a uniform random distribution with range [min, max] where min is the "min" parameter and max is the "max" parameter.

Parameters
paramsSet of parameters that dictates the generator's function. Required parameters: "src min", "src max", "trg min", "trg max", "slc min", "slc max", "min", and "max" Optional parameters: "symmetrical" and "density"
graphThe Graph data structure that is being edited. Only 3d Graphs (slice_nodeset != NULL) with a dense slice dimension can be used with this generator.

Complexity

Linear for each link within the bounding box if both source and target dimensions are dense. If a dimension is sparse each link is an additional O(ln(n)) where n is the number of elements that don't equal the default value.

Exception Safety

If any of the required parameters are missing from the ParameterMap, a dynet::could_not_find_parameter is thrown. A dynet::could_not_convert_parameter is thrown if any of the values in the parameter map can not be converted to their proper types. These types need not correspond to the template instantiation data type. Finally, a dynet::out_of_range is thrown if the "density", "min", "max" parameter is outside the range [0,1].

Member Data Documentation

◆ graph_manager

GraphManager* const GraphManager::set_of_generators::graph_manager

summary>

◆ random

Random* const GraphManager::set_of_generators::random

summary>