.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/02_visualization/plot_04_structure_matrix.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_02_visualization_plot_04_structure_matrix.py: The system matrix in block-triangular order =========================================== Structural controllability is also a statement about the zero pattern of :math:`[\mathbf{A},\mathbf{B}]`: its generic rank must be full and every row must be connected to a column of :math:`\mathbf{B}`. Sorting the states by a topological order of the strongly connected components makes :math:`\mathbf{A}` block lower triangular; the diagonal blocks are the components, source blocks need an entry in :math:`\mathbf{B}`, sink blocks an entry in :math:`\mathbf{C}`. The entries of the control matching (rings) are a transversal: together with the input entries they cover every row. .. GENERATED FROM PYTHON SOURCE LINES 16-18 Natural and block-triangular order ---------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 18-32 .. code-block:: Python import matplotlib.pyplot as plt import nocad from nocad.datasets import load_nocad_example, make_hen_case_study from nocad.viz import plot_structure_matrix adj = load_nocad_example().adj fig, axes = plt.subplots(1, 2, figsize=(9.0, 4.6)) plot_structure_matrix(adj, order="natural", ax=axes[0], title="natural order") # [snippet:matrix] plot_structure_matrix(adj, order="scc", ax=axes[1], title="SCC (block-triangular) order") # [/snippet:matrix] fig.tight_layout() .. image-sg:: /auto_examples/02_visualization/images/sphx_glr_plot_04_structure_matrix_001.png :alt: natural order, SCC (block-triangular) order :srcset: /auto_examples/02_visualization/images/sphx_glr_plot_04_structure_matrix_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 33-37 Parameter study: the design method changes B and C -------------------------------------------------- For the heat exchanger network every unit is a component with a self-loop on the diagonal; signal sharing and path finding give different input and output patterns. .. GENERATED FROM PYTHON SOURCE LINES 37-45 .. code-block:: Python hen = make_hen_case_study() fig, axes = plt.subplots(1, 2, figsize=(11.0, 5.6)) for ax, method in zip(axes, ("path_finding", "signal_sharing"), strict=True): d = nocad.InputOutputDesign(method).fit(hen.adj) plot_structure_matrix(hen.adj, d.B_, d.C_, d.control_matching_, ax=ax, labels=hen.labels, title=f"{method.replace('_', ' ')}: {d.n_inputs_} input(s), {d.n_outputs_} output(s)") fig.tight_layout() .. image-sg:: /auto_examples/02_visualization/images/sphx_glr_plot_04_structure_matrix_002.png :alt: path finding: 1 input(s), 3 output(s), signal sharing: 1 input(s), 1 output(s) :srcset: /auto_examples/02_visualization/images/sphx_glr_plot_04_structure_matrix_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 46-49 **Take-away.** The block-triangular view connects the graph conditions with matrix language: diagonal blocks are components, the matching is a transversal, and the blocks without predecessors (successors) are where B (C) needs its entries. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.303 seconds) .. _sphx_glr_download_auto_examples_02_visualization_plot_04_structure_matrix.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/ComplexSystemsIntelligence/nocad/main?urlpath=lab/tree/notebooks/auto_examples/02_visualization/plot_04_structure_matrix.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_04_structure_matrix.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_04_structure_matrix.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_04_structure_matrix.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_