Metadata-Version: 2.5
Name: nocad
Version: 1.0.1
Summary: Network-based observability and controllability analysis of dynamical systems: maximum matching, driver and sensor nodes, structural controllability, relative degree, sensor placement and visualization.
Project-URL: Homepage, https://github.com/ComplexSystemsIntelligence/nocad
Project-URL: Documentation, https://complexsystemsintelligence.github.io/nocad
Project-URL: Repository, https://github.com/ComplexSystemsIntelligence/nocad
Project-URL: Issues, https://github.com/ComplexSystemsIntelligence/nocad/issues
Project-URL: Changelog, https://github.com/ComplexSystemsIntelligence/nocad/blob/main/CHANGELOG.md
Project-URL: Book (PDF), https://complexsystemsintelligence.github.io/nocad/nocad-book.pdf
Author: Dániel Leitold, Ágnes Vathy-Fogarassy
Author-email: János Abonyi <janos@abonyilab.com>
License-Expression: MIT
License-File: LICENSE
Keywords: complex networks,driver nodes,dynamical systems,maximum matching,network science,observability,sensor placement,structural controllability
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.10
Requires-Dist: matplotlib>=3.7
Requires-Dist: networkx>=3.0
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.0
Requires-Dist: scipy>=1.11
Provides-Extra: book
Requires-Dist: beautifulsoup4>=4.12; extra == 'book'
Requires-Dist: lxml; extra == 'book'
Requires-Dist: pillow; extra == 'book'
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: control>=0.10; extra == 'dev'
Requires-Dist: igraph>=0.11; extra == 'dev'
Requires-Dist: myst-parser; extra == 'dev'
Requires-Dist: numpydoc; extra == 'dev'
Requires-Dist: openpyxl>=3.1; extra == 'dev'
Requires-Dist: pydata-sphinx-theme; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: sphinx-copybutton; extra == 'dev'
Requires-Dist: sphinx-design; extra == 'dev'
Requires-Dist: sphinx-gallery>=0.15; extra == 'dev'
Requires-Dist: sphinx>=7; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Provides-Extra: docs
Requires-Dist: myst-parser; extra == 'docs'
Requires-Dist: numpydoc; extra == 'docs'
Requires-Dist: openpyxl>=3.1; extra == 'docs'
Requires-Dist: pydata-sphinx-theme; extra == 'docs'
Requires-Dist: sphinx-copybutton; extra == 'docs'
Requires-Dist: sphinx-design; extra == 'docs'
Requires-Dist: sphinx-gallery>=0.15; extra == 'docs'
Requires-Dist: sphinx>=7; extra == 'docs'
Provides-Extra: interop
Requires-Dist: control>=0.10; extra == 'interop'
Requires-Dist: igraph>=0.11; extra == 'interop'
Requires-Dist: openpyxl>=3.1; extra == 'interop'
Provides-Extra: test
Requires-Dist: openpyxl>=3.1; extra == 'test'
Requires-Dist: pytest-cov; extra == 'test'
Requires-Dist: pytest>=7; extra == 'test'
Description-Content-Type: text/markdown

<p align="center"><img src="https://raw.githubusercontent.com/ComplexSystemsIntelligence/nocad/main/docs/_static/banner.png" alt="nocad: network-based controllability and observability analysis in Python"></p>

# nocad: network-based controllability and observability analysis in Python

[![tests](https://github.com/ComplexSystemsIntelligence/nocad/actions/workflows/ci.yml/badge.svg)](https://github.com/ComplexSystemsIntelligence/nocad/actions/workflows/ci.yml)
[![docs](https://img.shields.io/badge/docs-gallery%20%2B%20API-285780)](https://complexsystemsintelligence.github.io/nocad)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/ComplexSystemsIntelligence/nocad/blob/main/LICENSE)

**nocad** analyses the controllability and observability of dynamical systems on
the network of their state variables. It succeeds the *NOCAD — Network-based
Observability and Controllability Analysis of Dynamical systems* toolbox for MATLAB
(Leitold, Vathy-Fogarassy, Abonyi) and implements its three modules — network
mapping, system characterisation, and the improvement of input and output
configurations — together with new methods: the exact minimum of dedicated inputs,
node roles and edge classes, control profiles, robustness analysis, and a
visualization module whose layouts make the structural conditions of
controllability visible.

| Module | Contents |
|---|---|
| `nocad.design`, `nocad.matching` | maximum matching (Hopcroft–Karp), path finding, signal sharing, exact minimum of dedicated inputs; driver and sensor nodes; generation of B, C, D; node roles and edge classes |
| `nocad.structural`, `nocad.components` | Lin's structural test, generic dimension of the controllable subspace (orthogonal Krylov iteration), Kalman and PBH tests, control and observe centrality; strongly connected components and condensation |
| `nocad.distances` | geodesic distances, control and observation depth and regions, relative degree, placement cost |
| `nocad.profiles`, `nocad.robustness` | driver and sensor types, control profiles; robustness against node and edge removal |
| `nocad.connection` | the seven connection types, node and edge dynamics, dynamics heat maps |
| `nocad.measures` | about fifty network, node, configuration and edge measures as pandas tables |
| `nocad.placement` | grassroot and retrofit set covering, centrality-based retrofit, mCLASA and GDFCMSA simulated annealing (`Placement` estimator) |
| `nocad.io`, `nocad.annotation` | import and export: NetworkX, igraph, pandas, state-space matrices, python-control; GraphML, GEXF (Gephi), GML, Cytoscape JSON, node-link JSON, Graphviz DOT, Pajek, edge lists, CSV, Excel, MATLAB (NOCAD toolbox), NumPy; node and edge tables with the role of every element, carried as attributes by every export and restored on import |
| `nocad.viz` | SCC hierarchy layout, bipartite matching view, control cacti, block-triangular structure matrix, depth maps with network-Voronoi regions, operability plane, role and robustness maps, dashboards |
| `nocad.datasets`, `nocad.plotting` | the networks of the NOCAD studies (Sets I–III, *C. elegans* frontal network), generators (random, water tanks, heat exchanger networks), drawing primitives |

## Installation

```bash
pip install nocad
```

Python ≥ 3.10; depends on numpy, scipy, networkx, pandas and matplotlib.
`pip install "nocad[interop]"` adds python-control, igraph and openpyxl for the
corresponding conversions.

## Quick start

```python
import nocad
from nocad.datasets import load_nocad_example
from nocad.viz import plot_control_cacti, plot_operability_summary

adj = load_nocad_example().adj             # network of the state variables (W = A^T)

design = nocad.InputOutputDesign(method="path_finding").fit(adj)
design.driver_nodes_, design.sensor_nodes_  # where the inputs and outputs go
A, B, C, D = design.matrices()              # structured state-space matrices
design.is_controllable(), design.is_observable()

nocad.InputOutputDesign(method="minimum").fit(adj).n_inputs_   # exact minimum

plot_control_cacti(adj)                     # Lin's cacti: why the design works
plot_operability_summary(adj)               # hierarchy, depth maps, operability plane

ann = design.annotate()                     # role of every node and edge (pandas tables)
design.write("example.gexf")                # Gephi, with role colors and positions
G = design.to_networkx()                    # annotated networkx.DiGraph
net = nocad.read_network("example.gexf")    # network and configuration come back
```

Estimators follow the scikit-learn conventions (`fit`, fitted attributes with a
trailing underscore, `get_params`/`set_params`); networks are accepted as NumPy
arrays, SciPy sparse matrices, NetworkX digraphs, igraph graphs or pandas DataFrames,
and node names are kept in every table, file and figure.

## Documentation, examples, book

* **Documentation and example gallery**: <https://complexsystemsintelligence.github.io/nocad>.
  29 runnable examples in seven sections; each generates or loads its own network,
  explains the method and ends with a study of its parameters. Every example is also
  a Jupyter notebook.
* **Book**: *Network-Based Controllability and Observability Analysis in Python: The
  nocad toolbox*: [read online](https://complexsystemsintelligence.github.io/nocad/book/),
  [PDF](https://complexsystemsintelligence.github.io/nocad/nocad-book.pdf) (136 pages) and
  [EPUB](https://complexsystemsintelligence.github.io/nocad/nocad-book.epub), CC BY 4.0;
  LaTeX source in `book/`, built by `book/build.sh` (PDF), `book/epub/make_epub.py`
  and `book/web/make_web.py`. Theory in one notation, algorithm boxes, propositions with proofs,
  and the gallery examples as case studies.
* **Migration from the MATLAB toolbox**: Appendix B of the book and
  `docs/migration.rst`.

## Development

```bash
git clone https://github.com/ComplexSystemsIntelligence/nocad.git && cd nocad
pip install -e ".[dev]"
pytest                                   # unit tests and doctests
ruff check src tests tools examples
python docs/build_api_pages.py && sphinx-build -b html docs docs/_build/html
book/build.sh                            # cover, figures, appendices, PDF
python book/epub/make_epub.py            # EPUB edition (tex4ebook)
python book/web/make_web.py              # web edition (make4ht) -> book/_build_web/site
```

`DESIGN.md` sets the conventions for the code, the docstrings, the examples and the
book (notation, API contract, layout, templates).

## Citing

Please cite the software through `CITATION.cff` (a Zenodo DOI is assigned with the
first release) and the original publications of the methods you use, in
particular

* D. Leitold, Á. Vathy-Fogarassy, J. Abonyi: Controllability and observability in
  complex networks – the effect of connection types. *Scientific Reports* 7, 151
  (2017), doi:10.1038/s41598-017-00160-5;
* D. Leitold, Á. Vathy-Fogarassy, J. Abonyi: Network-based observability and
  controllability analysis of dynamical systems: the NOCAD toolbox.
  *F1000Research* 8:646 (2019), doi:10.12688/f1000research.19029.2.

Every docstring and chapter lists the publications behind its methods.

## About

nocad is developed by the HUN-REN–PE Complex Systems Monitoring Research Group
([AbonyiLab](https://www.abonyilab.com)) at the University of Pannonia, Veszprém,
Hungary. The group's open textbooks and software are collected at
[complexsystemsintelligence.github.io](https://complexsystemsintelligence.github.io/).
The work was supported by the National Research, Development and Innovation Office
of Hungary (NKFIH) through the OTKA 143482 project.

## License

Code: MIT. Book: CC BY 4.0. Authors: János Abonyi, Dániel Leitold and Ágnes
Vathy-Fogarassy (University of Pannonia), who also wrote the MATLAB toolbox this
project succeeds.
