dkpy

Robust control in Python using D-K iteration... and more!

https://github.com/decargroup/dkpy

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.7%) to scientific vocabulary

Keywords

control h-infinity mu-analysis mu-synthesis robust-control
Last synced: 6 months ago · JSON representation ·

Repository

Robust control in Python using D-K iteration... and more!

Basic Info
Statistics
  • Stars: 6
  • Watchers: 3
  • Forks: 0
  • Open Issues: 12
  • Releases: 5
Topics
control h-infinity mu-analysis mu-synthesis robust-control
Created over 1 year ago · Last pushed 6 months ago
Metadata Files
Readme Contributing License Code of conduct Citation Codeowners

README.rst

.. role:: class(code)

dkpy
====

.. image:: https://github.com/decargroup/dkpy/actions/workflows/test-package.yml/badge.svg
    :target: https://github.com/decargroup/dkpy/actions/workflows/test-package.yml
    :alt: Test package
.. image:: https://readthedocs.org/projects/dkpy/badge/?version=stable
    :target: https://dkpy.readthedocs.io/en/stable/?badge=stable
    :alt: Documentation status
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.14511244.svg
    :target: https://doi.org/10.5281/zenodo.14511244
    :alt: DOI

``dkpy`` is a `D-K iteration `_
library written in Python, aiming to build upon
`python-control `_.

The package is currently a work-in-progress, and no API stability guarantees
will be made until version 1.0.0.

D-K iteration
=============

The standard robust control problem has the form::

              ┌─────────┐          
              │         │          
      w2 ┌────┤    Δ    │◄───┐ z2  
         │    │         │    │     
         │    └─────────┘    │     
         │    ┌─────────┐    │     
         └───►│         ├────┘     
    w1 ──────►│    P    ├──────► z1
         ┌───►│         ├────┐     
         │    └─────────┘    │     
         │    ┌─────────┐    │     
         │    │         │    │     
       u └────┤    K    │◄───┘ y   
              │         │          
              └─────────┘          

where ``P`` is the generalized plant, ``K`` is the controller, and ``Δ`` is an
uncertain LTI system whose H-infinity norm is less than or equal to 1.

Synthesizing a controller that makes the transfer matrix from ``w1`` to ``z1``
have an H-infinity norm less than 1 guarantees robust stability by the small
gain theorem.

When ``Δ`` has structure (*e.g.*, ``Δ = diag(Δ1, Δ2)``), this approach is too
conservative. Robust stability can instead be achieved by synthesizing a
controller whose **structured singular value**, ``µ``, is less than 1. Robust
performance problems can also be viewed as robust stability problems with
structured uncertainty.

Minimizing ``µ`` is much more challenging than minimizing the H-infinity norm.
D-K iteration is one method to do so. It relies on the fact that an upper bound
for ``µ`` is::

    µ(M) ≤ min σ̅(DMD⁻¹)
            D

where ``D`` is a complex matrix whose structure commutes with ``Δ``. More
specifically, for each full block in ``Δ``, the corresponding entry of ``D`` is
``d I``, where ``d`` is a scalar and ``I`` is the identity matrix. If ``Δ`` has
any entries of the form ``δ I``, then ``D`` has a full block in the
corresponding entry.

D-K iteration has the following steps, where ``D`` is initially identity.

#. Augment ``P`` with ``D`` and ``D⁻¹``, then synthesize an H-infinity controller.
#. Compute ``µ`` and ``D`` for the closed-loop system without the D-scalings
   over a range of discrete frequencies.
#. Fit a transfer matrix to ``D`` and repeat. Stop when ``µ < 1``.

The D-K iteration process is represented by :class:`dkpy.DkIteration`. The
steps of the process are represented by

#. :class:`dkpy.ControllerSynthesis`,
#. :class:`dkpy.StructuredSingularValue`, and
#. :class:`dkpy.DScaleFit`.

Example
=======

.. code-block:: python

    import dkpy
    import numpy as np

    # Load an example
    eg = dkpy.example_skogestad2006_p325()

    # Set up the D-K iteration method
    dk_iter = dkpy.DkIterListOrder(
        controller_synthesis=dkpy.HinfSynSlicot(),
        structured_singular_value=dkpy.SsvLmiBisection(),
        d_scale_fit=dkpy.DScaleFitSlicot(),
        fit_orders=[4, 4, 4],
    )

    # Synthesize a controller
    omega = np.logspace(-3, 3, 61)
    block_structure = [
        dkpy.ComplexFullBlock(1, 1),
        dkpy.ComplexFullBlock(1, 1),
        dkpy.ComplexFullBlock(2, 2),
    ]
    K, N, mu, d_scale_fit_info, info = dk_iter.synthesize(
        eg["P"],
        eg["n_y"],
        eg["n_u"],
        omega,
        block_structure,
    )

Contributing
============

To install the pre-commit hook, run

.. code-block:: sh

   $ pip install -r requirements.txt
   $ pre-commit install

in the repository root.

Citation
========

If you use this software in your research, please cite it as below or see
``CITATION.cff``.

.. code-block:: bibtex

    @software{dahdah_dkpy_2025,
        title={{decargroup/dkpy}},
        doi={10.5281/zenodo.14511244},
        url={https://github.com/decargroup/dkpy},
        publisher={Zenodo},
        author={Steven Dahdah and Timothy Everett Adams and James Richard Forbes},
        version = {{v0.1.10}},
        year={2025},
    }

Owner

  • Name: DECAR
  • Login: decargroup
  • Kind: organization
  • Location: Canada

Dynamics, Estimation, and Control in Aerospace and Robotics (DECAR)

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
  - family-names: "Dahdah"
    given-names: "Steven"
    orcid: "https://orcid.org/0000-0003-4930-9634"
    affiliation: "McGill University"
  - family-names: "Adams"
    given-names: "Timothy Everett"
    orcid: "https://orcid.org/0009-0008-5291-0686"
    affiliation: "McGill University"
  - family-names: "Forbes"
    given-names: "James Richard"
    orcid: "https://orcid.org/0000-0002-1987-9268"
    affiliation: "McGill University"
title: "decargroup/dkpy"
version: v0.1.10
url: "https://github.com/decargroup/dkpy"

GitHub Events

Total
  • Create event: 20
  • Release event: 6
  • Issues event: 61
  • Watch event: 5
  • Delete event: 11
  • Issue comment event: 20
  • Public event: 1
  • Push event: 126
  • Pull request review event: 13
  • Pull request review comment event: 32
  • Pull request event: 18
Last Year
  • Create event: 20
  • Release event: 6
  • Issues event: 61
  • Watch event: 5
  • Delete event: 11
  • Issue comment event: 20
  • Public event: 1
  • Push event: 126
  • Pull request review event: 13
  • Pull request review comment event: 32
  • Pull request event: 18

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 36
  • Total pull requests: 11
  • Average time to close issues: 6 days
  • Average time to close pull requests: about 13 hours
  • Total issue authors: 4
  • Total pull request authors: 2
  • Average comments per issue: 0.61
  • Average comments per pull request: 0.0
  • Merged pull requests: 10
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 36
  • Pull requests: 11
  • Average time to close issues: 6 days
  • Average time to close pull requests: about 13 hours
  • Issue authors: 4
  • Pull request authors: 2
  • Average comments per issue: 0.61
  • Average comments per pull request: 0.0
  • Merged pull requests: 10
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • sdahdah (27)
  • eid-not-die (5)
  • ovhnw (4)
  • timeverettadams (3)
Pull Request Authors
  • sdahdah (17)
  • timeverettadams (1)
Top Labels
Issue Labels
enhancement (25) bug (6) documentation (4) good first issue (1)
Pull Request Labels
enhancement (8) bug (3) documentation (3)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 39 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 7
  • Total maintainers: 1
pypi.org: dkpy

D-K iteration in Python

  • Homepage: https://github.com/decargroup/dkpy
  • Documentation: https://dkpy.readthedocs.io/
  • License: MIT License Copyright (c) 2024 DECAR Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • Latest release: 0.1.8
    published about 1 year ago
  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 39 Last month
Rankings
Dependent packages count: 10.1%
Average: 33.3%
Dependent repos count: 56.6%
Maintainers (1)
Last synced: 6 months ago

Dependencies

pyproject.toml pypi
  • control >=0.10.0
  • cvxpy >=1.5.0
  • joblib >=1.4.0
  • numpy >=1.21.0,<2
  • scipy >=1.7.0
  • slycot >=0.6.0
requirements.txt pypi
  • control *
  • cvxpy *
  • joblib *
  • mosek >=9.2.49
  • numpy *
  • pytest *
  • pytest-regressions *
  • ruff *
  • scipy *
  • slycot *
  • sphinx *
  • sphinx-rtd-theme *
.github/workflows/check-formatting.yml actions
  • actions/checkout v4 composite
  • astral-sh/ruff-action v1 composite
.github/workflows/check-version.yml actions
  • Bruce17/ghaction-package-latest-version v1 composite
  • actions/checkout v2 composite
.github/workflows/release-package.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • pypa/gh-action-pypi-publish v1.12.2 composite
.github/workflows/test-package.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite