paroto.viz#

Visualization module for Paroto.

This module provides tools for visualizing optimization problems, parameter hierarchies, and model connectivity in multiple formats.

Main Functions#

extract_hierarchy : Extract parameter hierarchy from OpenMDAO Problem generate_hierarchical_graph : Generate hierarchical Mermaid diagram generate_simple_graph : Generate simple all-to-all Mermaid diagram to_networkx : Convert hierarchy to NetworkX DiGraph model_graph_to_cytoscape : Convert graph to Cytoscape format for Dash

Submodules#

Classes#

ProblemGraph

Unified graph abstraction for OpenMDAO Problem visualization.

Functions#

get_cytoscape_layout()

Get default Cytoscape layout configuration.

get_cytoscape_stylesheet()

Get default Cytoscape stylesheet for model graphs.

model_graph_to_cytoscape(parameters, models, constraints)

Convert model graph to Cytoscape elements format.

extract_hierarchy(prob, primary_params[, constraint_names])

Extract parameter hierarchy from an OpenMDAO Problem.

generate_hierarchical_graph(graph, output_path[, ...])

Generate hierarchical Mermaid diagram showing parameter dependencies.

generate_simple_graph(graph, output_path)

Generate a simple Mermaid flowchart showing system connectivity.

analyze_hierarchy(graph)

Analyze hierarchy structure and return statistics.

export_graphml(graph, output_path)

Export NetworkX graph to GraphML format.

export_json(graph, output_path)

Export NetworkX graph to JSON format.

plot_hierarchy(graph, output_path[, figsize, dpi])

Generate static image of hierarchy using matplotlib.

to_networkx(graph)

Convert ProblemGraph to NetworkX DiGraph.

Package Contents#

paroto.viz.get_cytoscape_layout()#

Get default Cytoscape layout configuration.

Returns:

Cytoscape layout configuration

Return type:

dict

paroto.viz.get_cytoscape_stylesheet()#

Get default Cytoscape stylesheet for model graphs.

Returns:

Cytoscape stylesheet

Return type:

list

paroto.viz.model_graph_to_cytoscape(parameters, models, constraints, connections=None)#

Convert model graph to Cytoscape elements format.

Parameters:
  • parameters (list of str) – List of parameter names

  • models (list of str) – List of model names

  • constraints (list of str) – List of constraint names

  • connections (list of tuple, optional) – List of (source, target) tuples for explicit connections. If None, auto-generates all-to-all connections

Returns:

Cytoscape elements list with nodes and edges

Return type:

list

paroto.viz.extract_hierarchy(prob, primary_params, constraint_names=None)#

Extract parameter hierarchy from an OpenMDAO Problem.

Analyzes the connection structure of an OpenMDAO problem to determine which parameters are primary (design variables), secondary (outputs of models consuming primary parameters), and so on.

Parameters:
  • prob (openmdao.api.Problem) – Configured OpenMDAO problem (should call setup() called)

  • primary_params (list of str) – List of primary parameter names (design variables) These can be partial names that will be matched

  • constraint_names (list of str, optional) – List of constraint output names. If None, attempts to detect constraints

Returns:

Graph abstraction with nodes, edges, and hierarchy levels

Return type:

ProblemGraph

Notes

Hierarchy levels: - Level 0: Primary parameters (user-specified design variables) - Level N: Parameters/outputs that depend only on levels 0 through N-1 - Constraints are assigned their own level based on dependencies

paroto.viz.generate_hierarchical_graph(graph, output_path, max_level=None, orientation='LR')#

Generate hierarchical Mermaid diagram showing parameter dependencies.

Creates a layered graph where nodes are organized by hierarchy level, showing actual connections between parameters, models, and constraints.

Parameters:
  • graph (ProblemGraph) – Problem graph from extract_hierarchy()

  • output_path (str) – File path where the Mermaid diagram will be saved

  • max_level (int, optional) – Maximum hierarchy level to display. If None, shows all levels

  • orientation (str, optional) – Graph orientation: “LR” (left-right) or “TD” (top-down). Default: “LR”

Returns:

The output file path where the diagram was saved

Return type:

str

paroto.viz.generate_simple_graph(graph, output_path)#

Generate a simple Mermaid flowchart showing system connectivity.

Creates a graph with three layers: parameters (inputs), models (processing), and constraints (outputs/checks). Automatically extracts nodes from the ProblemGraph.

Parameters:
  • graph (ProblemGraph) – Problem graph from extract_hierarchy()

  • output_path (str) – File path where the Mermaid diagram will be saved

Returns:

The output file path where the diagram was saved

Return type:

str

paroto.viz.analyze_hierarchy(graph)#

Analyze hierarchy structure and return statistics.

Parameters:

graph (networkx.DiGraph) – Graph to analyze

Returns:

Statistics including: - ‘num_nodes’: total number of nodes - ‘num_edges’: total number of edges - ‘num_levels’: number of hierarchy levels - ‘nodes_by_level’: dict mapping level -> count - ‘nodes_by_type’: dict mapping type -> count - ‘max_in_degree’: maximum number of inputs to a node - ‘max_out_degree’: maximum number of outputs from a node

Return type:

dict

paroto.viz.export_graphml(graph, output_path)#

Export NetworkX graph to GraphML format.

GraphML is supported by tools like yEd, Gephi, and Cytoscape.

Parameters:
  • graph (networkx.DiGraph) – Graph to export

  • output_path (str) – Output file path (.graphml extension recommended)

Returns:

The output file path

Return type:

str

paroto.viz.export_json(graph, output_path)#

Export NetworkX graph to JSON format.

Exports in node-link format compatible with D3.js and other JavaScript libraries.

Parameters:
  • graph (networkx.DiGraph) – Graph to export

  • output_path (str) – Output file path (.json extension recommended)

Returns:

The output file path

Return type:

str

paroto.viz.plot_hierarchy(graph, output_path, figsize=(12, 8), dpi=150)#

Generate static image of hierarchy using matplotlib.

Parameters:
  • graph (networkx.DiGraph) – Graph to plot

  • output_path (str) – Output file path (extension determines format: .png, .pdf, .svg)

  • figsize (tuple, optional) – Figure size in inches (width, height). Default: (12, 8)

  • dpi (int, optional) – Resolution for raster outputs. Default: 150

Returns:

The output file path

Return type:

str

paroto.viz.to_networkx(graph)#

Convert ProblemGraph to NetworkX DiGraph.

Parameters:

graph (ProblemGraph) – Problem graph from extract_hierarchy()

Returns:

Directed graph with node attributes: - ‘level’: hierarchy level (int) - ‘type’: node type (str) - ‘units’: variable units (str) - ‘value’: variable value - ‘label’: simplified display name

Return type:

networkx.DiGraph

class paroto.viz.ProblemGraph(prob, primary_params=None, constraint_markers=None)#

Unified graph abstraction for OpenMDAO Problem visualization.

This class wraps an OpenMDAO Problem and provides a clean, unified interface for extracting graph structure that can be consumed by any visualization backend.

Parameters:
  • prob (openmdao.api.Problem) – OpenMDAO problem (must have setup() called)

  • primary_params (list of str, optional) – List of primary parameter names (design variables). Can be partial names that will be matched

  • constraint_markers (list of str, optional) – Keywords to identify constraint variables (e.g., [‘margin’, ‘constraint’])

nodes#

Mapping of node_id -> node attributes (type, level, units, value, label, subsystem)

Type:

dict

edges#

List of (source, target) connections

Type:

list of tuple

primary_params#

Full names of primary parameters

Type:

list

prob#
model#
nodes: Dict[str, Dict[str, Any]]#
edges: List[Tuple[str, str]] = []#
primary_params: List[str] = []#
get_nodes_by_level(max_level=None)#

Get nodes organized by hierarchy level.

Parameters:

max_level (int, optional) – Maximum level to include. If None, includes all levels

Returns:

Mapping of level -> list of node_ids

Return type:

dict

get_nodes_by_subsystem()#

Get nodes organized by subsystem.

Returns:

Mapping of subsystem_name -> list of node_ids

Return type:

dict

get_nodes_by_type()#

Get nodes organized by type.

Returns:

Mapping of node_type -> list of node_ids

Return type:

dict

filter_by_level(max_level)#

Get filtered view with nodes up to max_level.

Parameters:

max_level (int) – Maximum hierarchy level to include

Returns:

(filtered_nodes, filtered_edges) dictionaries

Return type:

tuple

get_statistics()#

Get graph statistics.

Returns:

Statistics including node counts, edge counts, level distribution

Return type:

dict