Note
Go to the end to download the full example code.
Coupling graph#
This example illustrates the notion of coupling graph.
from __future__ import annotations
from gemseo import generate_coupling_graph
from gemseo.utils.discipline import DummyDiscipline
Create the disciplines#
First, we create dummy disciplines that do nothing:
dummy_disciplines = [
DummyDiscipline(name=name, input_names=input_names, output_names=output_names)
for (name, input_names, output_names) in (
("A", ["a"], ["b"]),
("B", ["c"], ["a", "n"]),
("C", ["b", "d"], ["c", "e"]),
("D", ["f"], ["d", "g"]),
("E", ["e"], ["f", "h", "o"]),
("F", ["g", "j"], ["i"]),
("G", ["i", "h"], ["k", "l"]),
("H", ["k", "m"], ["j"]),
("I", ["l"], ["m", "w"]),
("J", ["n", "o"], ["p", "q"]),
("K", ["y"], ["x"]),
("L", ["w", "x"], ["y", "z"]),
("M", ["p", "s"], ["r"]),
("N", ["r"], ["t", "u"]),
("O", ["q", "t"], ["s", "v"]),
("P", ["u", "v", "z"], ["z"]),
)
]
Generate the coupling graph#
The coupling graph represents each discipline by a node
and each coupling variable by an edge.
By default,
the generate_coupling_graph() function saves the graphical representation
of the coupling graph as a PDF file.
Here,
we prefer to display it in this web page
by setting file_path to ""
(the same would work in a notebook).
generate_coupling_graph(dummy_disciplines, file_path="")
WARNING - 16:24:52: Two disciplines, among which P, compute the same outputs: {'z'}
We can also draw the condensed coupling graph, where each groups of strongly coupled disciplines is represented by a node:
generate_coupling_graph(dummy_disciplines, file_path="", full=False)
WARNING - 16:24:52: Two disciplines, among which P, compute the same outputs: {'z'}
Total running time of the script: (0 minutes 0.303 seconds)