Indices and tables¶
Documentation for the Code¶
The KADMOS package is fully described in this documentation.
MDOproblem¶
Below the full KADMOS MDOproblem class description can be found.
-
class
pyKADMOS.MDOproblem.
MDOproblem
(knowledge_base)¶ Class that can be used to formally specify an MDO problem and analyze it based on graph theoretical analyses.
-
analyze_function_files
(print_in_log=True)¶ Function that analyzes all tool files (input, output, info) and returns all the xpaths in the xml file plus a dictionary with the nodes that have a value.
Parameters: print_in_log – Boolean on whether the results should be printed to the log Returns: function_data dict with all function data like ‘input’, ‘output’, ‘unique_xpaths’, ‘sorted_xpaths’
-
analyze_function_xml
(xml_file)¶ Function that analyzes a single tool XML input or output file.
Parameters: xml_file – name of XML file to be analyzed Returns: dict with collection of XML file properties, valued_nodes, and all_xpaths
-
check_against_xsd
()¶ Check the XML files in the knowledge base against the XML Schema.
Return type: Error
-
get_FPG_based_on_sink
(sink)¶ Function to get the Fundamental Problem Graph based on the required output variable.
Parameters: sink – node name of desired variable Returns: Fundamental problem graph (FPG) object
-
get_FPG_based_on_sinks
(list_of_sinks)¶ Function to get the Fundamental Problem Graph based on a list of sinks / required output variables.
Parameters: list_of_sinks – list with strings that specify the desired output Returns: Fundamental Problem Graph (FPG) object
-
get_MCG
()¶ Function to create Maximal Connectivity Graph (Pate, 2014) by composing a list of graphs.
Returns: maximal connectivity graph (MCG)
-
get_PSG
(FPG, MDA_type, analysis_order)¶ Create the PSG graph for the MDF method.
Parameters: - FPG (DiGraph) – fundamental problem graph with required node properties
- MDA_type (str) – type of multidisciplinary analysis to be implemented (‘Gauss-Seidel’ or ‘Jacobi’)
- analysis_order (list) – list with the order of the analyses in the MDA
Returns: dictionary with the PSG process flow and the PSG data flow
Return type: dict
-
get_common_nodes
()¶ Function to find the common nodes between tool inputs and outputs.
Returns: dictionary with common nodes
-
get_contracted_graph
(graph, contraction_level)¶ Function to contract the nodes of a graph to a given xpath level.
Parameters: - graph – input graph
- contraction_level – int from 0 (highest level) to X (lowest level existing in XML schema)
Returns: graph with contracted nodes
-
get_extended_MCG
()¶ Function to create extended maximal connectivity graph (additional variable nodes for shared variables).
Returns: extended maximal connectivity graph (MCG)
-
get_function_graph
(function_name)¶ Function to automatically create the digraph of the function element.
Parameters: function_name – name of the function according to XML file names. Returns: graph of the function.
-
get_function_graphs
()¶ Function to collect all function graphs in the MDO problem class.
Returns: list with all function graph objects.
-
get_function_names
()¶ Get the function names in the function_i_o_xmls based on the input XML files.
Returns: function_names list with file name strings
-
get_partitioned_graph
(G, n_parts, tpwgts=None, recursive=False, contig=False, output='DiGraph')¶ Partition a graph using the Metis algorithm (http://glaros.dtc.umn.edu/gkhome/metis/metis/overview). Note that partitioning can only be performed on undirected graphs. Therefore every graph input is translated into an undirected graph.
Parameters: - G – graph object
- n_parts – number of partitions requested (algorithm might provide less)
- tpwgts – list of target partition weights
- recursive – Metis option
- contig – Metis option
- output – set whether expected output is a DiGraph or normal Graph
Returns: list of edges that have been cut
Returns: list of partition group to which each node belongs
-
MDOstatic¶
Below the static graph functions used by KADMOS are listed.
Collection of static functions
-
pyKADMOS.MDOstatic.
add_nodes_subcategory
(graph)¶ Function to analyze and sort the graph nodes according to different variable descriptions.
CATEGORY OF NODE SUBCATEGORY INDEGREE OUTDEGREE variable hole 0 0 supplied input 0 1 supplied shared input 0 >1 output 1 0 collision >1 0 coupling 1 1 shared coupling 1 >1 collided coupling >1 1 collided shared coupling >1 >1 variable group hole group 0 0 supplied input group 0 1 supplied shared input group 0 >1 output groupe >0 0 coupling groupe >0 1 shared coupling groupe >0 >1 function hole 0 0 inputless 0 >0 outputless >0 0 complete >0 >0 Parameters: graph – directed graph Returns: dictionary with sorted variables
-
pyKADMOS.MDOstatic.
find_all_nodes
(graph, category='all', subcategory='all', attr_cond=None, print_in_log=False, print_attributes='all')¶ Advanced search function to get nodes and their properties.
Parameters: - graph (DiGraph) – input graph
- category (list) – category of the node (you can specify multiple in a list), see note for allowed values.
- subcategory (list) – subcategory of the node (you can specify multiple in a list), see note for allowed values.
- attr_cond (list) – conditional on the node attribute value (e.g. [‘execution time’,’>’,200])
- print_in_log (bool) – parameter to set printing in log on or off
- print_attributes (str or list) – attributes that should be printed in the log
Returns: list of all nodes that meet the search criteria
Return type: list
Note
The following categories are allowed:
- all
- variables
- variable groups
- functions
Note
The following subcategories are allowed:
- all
- all inputs
- all outputs
- all couplings
- all problematic nodes
- holes
- supplied inputs
- supplied shared inputs
- outputs
- collisions
- couplings
- shared couplings
- collided couplings
- collided shared couplings
- hole groups
- supplied input groups
- supplied shared input groups
- output groups
- coupling groups
- shared coupling groups
- holes
- inputlesss
- outputlesss
- completes
Example usage: Just get all nodes of a graph in a list:
>>> all_nodes = find_all_nodes(graph)
Get all input nodes in a list and print them in the log as well:
>>> all_nodes = find_all_nodes(graph, category='all', subcategory='all inputs', print_in_log=True)
Get all input nodes with a certain attribute value:
>>> all_nodes = find_all_nodes(graph, category='all', subcategory='all inputs', attr_cond=['execution time','>',5], >>> print_in_log=True)
-
pyKADMOS.MDOstatic.
get_adjacency_matrix
(graph, print_in_log=True)¶ Function to determine the adjacency matrix of a graph.
Parameters: - graph – input graph
- print_in_log – Boolean on whether the results should be printed to the log
Returns: different methods of storing the same adjacency matrix in one dictionary
-
pyKADMOS.MDOstatic.
get_categorized_nodes
(graph, print_in_log=True)¶ Function that returns a dictionary with graph nodes grouped according to category and subcategory.
Parameters: - graph – input graph
- print_in_log – Boolean on whether the results should be printed to the log
Returns: dictionary with analysis results
-
pyKADMOS.MDOstatic.
get_graph_nodes_indegree
(graph)¶ Function to get the indegree of all the graph nodes and store them in a dictionary.
Parameters: graph – DiGraph object Returns: dictionary with node name key and indegree integer value.
-
pyKADMOS.MDOstatic.
get_graph_nodes_outdegree
(graph)¶ Function to get the outdegree of all the graph nodes and store them in a dictionary.
Parameters: graph – DiGraph object Returns: dictionary with node name key and outdegree integer value.
-
pyKADMOS.MDOstatic.
get_node_attributes
(graph, node, attr_list, print_in_log=False)¶ Function to get and print certain attributes of a node from the graph.
Parameters: - graph (DiGraph) – DiGraph of the complete graph in which the node is present
- node (str) – node name
- attr_list (list) – list with attributes to be pulled
- print_in_log (bool) – parameter to set printing in log on or off
Returns: dictionary with node attributes
Return type: dict
-
pyKADMOS.MDOstatic.
test_attr_cond
(attr_value, operator, test_value)¶ Function to check a given conditional statement and return True or False.
Parameters: - attr_value (str, float, int) – value of the actual attribute
- operator (str) – conditional operator to be used (‘<’,’<=’,’==’,’!=’,’>=’,’>’)
- test_value (str, float, int) – value to which the attribute value should be compared.
Returns: result of the conditional statement.
Return type: bool
MDOvisualization¶
Below the visualization functions used by KADMOS are listed.
-
pyKADMOS.MDOvisualization.
color_list
()¶ A list of distinguisable colors.
Returns: list with HTML Hex colors
-
pyKADMOS.MDOvisualization.
draw_adjacency_matrix
(G, fig_num=1, fig_size=(7, 7), show_now=True)¶ Draw the adjacency matrix in a plot window.
Parameters: - G – networkx graph
- fig_num – figure number
- fig_size – figure size
- show_now – Boolean whether to plot directly (pausing the execution until the plot is closed), or not.
Returns: window with plot
-
pyKADMOS.MDOvisualization.
plot_graph
(G, fig_num=1, fig_size=(18, 11), color_setting='default', save_as=None, show_now=True)¶ Function to plot a graph. Note that you need to add matplotlib.pyplot.show() at the end of your code to see the plot window.
Parameters: - G –
- fig_num – figure number
- fig_size – size of figure window
- color_setting – choose from ‘default’, ‘sinks’, ‘categories’, ‘partitions’
- save_as – save plot as figure file
- show_now – Boolean whether to plot directly (pausing the execution until the plot is closed), or not.
Returns: window with plot
MDOexport¶
Below the export functions used by KADMOS are listed.
Class that can be used export MDO processes defined in the MDOproblem class.
-
pyKADMOS.MDOexport.
save_as_graphml
(graph, filename)¶ Save the graph in the graphml extension
Parameters: - graph – graph object
- filename – file name without extension
Returns: graphml file stored in same folder