Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H-infinity mixed-synthesis #151

Merged
merged 6 commits into from Jan 6, 2018
Merged

Conversation

roryyorke
Copy link
Contributor

This adds methods "augw" and "mixsyn", with interfaces similar to the Matlab and Octave functions of the same name. They are for so-called mixed-sensitivity design, in which the sensitivity, complementary sensitivity, and "input sensitivity" (K*S, or reference to input mapping) can be weighted and stacked for H-infinity synthesis.

As part of this, I've fixed what I think is a bug, namely that empty StateSpace objects could not be created. Such empty objects are convenient in the augw implementation.

I've added two examples for mixsyn, one SISO and one MIMO.

augw is the major part of the new code. It may be that there is some better way to implement it, but I have tried to write it in a way that no uncontrollable or unobservable modes are introduced, and so that is still (somewhat) clear.

@coveralls
Copy link

coveralls commented Jul 1, 2017

Coverage Status

Coverage increased (+0.5%) to 78.162% when pulling b41fe06 on roryyorke:rory/augw into 05d6bc5 on python-control:master.

@murrayrm murrayrm self-requested a review December 27, 2017 16:35
@murrayrm murrayrm added this to the 0.8.0 milestone Dec 27, 2017
@murrayrm
Copy link
Member

murrayrm commented Jan 2, 2018

@roryyorke There's a small conflict with master that it would be good to fix. Will try to do a more thorough review in the coming days...

@murrayrm murrayrm self-assigned this Jan 2, 2018
@roryyorke
Copy link
Contributor Author

Will have a look at the conflict.

New functions augw and mixsyn modelled after Matlab and Octave's
function of the same names.

python-control doesn't currently support input group naming, so that
is not implemented.
Both examples taken from Skogestad and Postlethwaite's Multivariable
Feedback Control.
@coveralls
Copy link

coveralls commented Jan 2, 2018

Coverage Status

Coverage increased (+0.4%) to 78.954% when pulling 7b883ef on roryyorke:rory/augw into 33bebc1 on python-control:master.



def _size_as_needed(w,wname,n):
"""_size_as_needed(w,wname,n) -> w2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nonstandard docstring. I don't think we use this type of docstring (fcn(args) -> output) anyplace else. In addition, parameters, returns, etc are documented in a different format. Would prefer to use a consistent style, as done in hinfsyn in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix here and elsewhere (augw, _matrix, ...). I see I also used this in xferfcn.py in 310f580 in _dc_gain_cont.



def augw(g,w1=None,w2=None,w3=None):
"""augw(g,w1=None,w2=None,w3=None) -> p
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nonstandard docstring.

cl: closed system mapping evaluation inputs to evaluation outputs; if p is the augmented plant, with
[z] = [p11 p12] [w], then cl is the system from w->z with u=-k*y. StateSpace object.
[y] [p21 g] [u]
info: namedtuple with fields, in order,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the first use of a namedtuple in python-control. Is there a more standard way to return this sort of information in numpy or scipy? If so, perhaps we use that format?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namedtuple has been around since Python 2.6, so it's hardly non-standard ;). I couldn't find namedtuple use in numpy, but it is used in scipy (stats/stats.py, for example).

I can change this to a plain tuple; if we do keep the namedtuple, I'd like to remove the leading underscore from the name.

@@ -54,7 +54,7 @@
import math
import numpy as np
from numpy import all, angle, any, array, asarray, concatenate, cos, delete, \
dot, empty, exp, eye, matrix, ones, poly, poly1d, roots, shape, sin, \
dot, empty, exp, eye, matrix, ones, pi, poly, poly1d, roots, shape, sin, \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid using numpy.pi since this can generate errors when numpy is incorporated as a mock function. See PR 171, commit b881b7. Replace with math.pi.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unqualified pi no longer used following your aa6e0df anyway. Will remove.

def _matrix(a):
"""_matrix(a) -> numpy.matrix
a - passed to numpy.matrix
Wrapper around numpy.matrix; unlike that function, _matrix([]) will be 0x0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not clear to my why this is useful? Can you say a bit here (or in a comment in the code)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll expand the commentary; it's just a helper to make it easier to get 0x0 matrices, which are needed for empty state space systems.

control/robust.py:
  - doc-strings conform to python-control conventions
  - use plain tuple instead of namedtuple for auxiliary output in mixsyn

control/statesp.py:
  - don't import pi from numpy
  - doc-string for _matrix expanded, conforms to conventions

control/tests/robust_test.py
  - change test to accept plain tuple
@roryyorke
Copy link
Contributor Author

I thought I'd check the docstrings via sphinx, but when I run make html in the doc sub-directory, I get

  File "/home/rory/miniconda3/envs/control-python27/lib/python2.7/re.py", line 155, in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or buffer

I get the same error on master.

I see doc-requirements.txt references Sphinx from github, but that is somewhat older (log talks about Sphinx 1.3.1, I've got 1.6 installed from conda).

This is my conda environment (2.7-based, and AFAIK up-to-date; don't know why I don't have Scipy 1.0):

alabaster                 0.7.10                   py27_0  
babel                     2.5.0                    py27_0  
cairo                     1.14.8                        0  
certifi                   2016.2.28                py27_0  
cycler                    0.10.0                   py27_0  
dbus                      1.10.20                       0  
docutils                  0.14                     py27_0  
expat                     2.1.0                         0  
fontconfig                2.12.1                        3  
freetype                  2.5.5                         2  
funcsigs                  1.0.2                    py27_0  
functools32               3.2.3.2                  py27_0  
glib                      2.50.2                        1  
gst-plugins-base          1.8.0                         0  
gstreamer                 1.8.0                         0  
icu                       54.1                          0  
imagesize                 0.7.1                    py27_0  
jinja2                    2.9.6                    py27_0  
jpeg                      9b                            0  
libffi                    3.2.1                         1  
libgcc                    5.2.0                         0  
libgfortran               3.0.0                         1  
libiconv                  1.14                          0  
libpng                    1.6.30                        1  
libxcb                    1.12                          1  
libxml2                   2.9.4                         0  
markupsafe                1.0                      py27_0  
matplotlib                2.0.2               np113py27_0  
mkl                       2017.0.3                      0  
mock                      2.0.0                    py27_0  
nose                      1.3.7                    py27_1  
numpy                     1.13.1                   py27_0  
numpydoc                  0.7.0                    py27_0  
openssl                   1.0.2l                        0  
pbr                       1.10.0                   py27_0  
pcre                      8.39                          1  
pip                       9.0.1                    py27_1  
pixman                    0.34.0                        0  
pycairo                   1.10.0                   py27_0  
pygments                  2.2.0                    py27_0  
pyparsing                 2.2.0                    py27_0  
pyqt                      5.6.0                    py27_2  
python                    2.7.13                        0  
python-dateutil           2.6.1                    py27_0  
pytz                      2017.2                   py27_0  
qt                        5.6.2                         5  
readline                  6.2                           2  
requests                  2.14.2                   py27_0  
scipy                     0.19.1              np113py27_0  
setuptools                36.4.0                   py27_1  
sip                       4.18                     py27_0  
six                       1.10.0                   py27_0  
snowballstemmer           1.2.1                    py27_0  
sphinx                    1.6.3                    py27_0  
sphinxcontrib             1.0                      py27_0  
sphinxcontrib-websupport  1.0.1                    py27_0  
sqlite                    3.13.0                        0  
subprocess32              3.2.7                    py27_0  
tk                        8.5.18                        0  
typing                    3.6.2                    py27_0  
wheel                     0.29.0                   py27_0  
zlib                      1.2.11                        0  

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 78.051% when pulling e24c7de on roryyorke:rory/augw into 33bebc1 on python-control:master.

1 similar comment
@coveralls
Copy link

coveralls commented Jan 5, 2018

Coverage Status

Coverage decreased (-0.5%) to 78.051% when pulling e24c7de on roryyorke:rory/augw into 33bebc1 on python-control:master.

@murrayrm
Copy link
Member

murrayrm commented Jan 5, 2018

@roryyorke I had the same problem with sphinx on my local machine. For some reason it seems to work on readthedocs.org. I think the issue may be with the way that version string is being reported (somehow comes in as a float). We should probably chase this down, but perhaps via a separate issue.

I'll try to make sure things look OK on readthedocs when I get a chance (probably tonight or this weekend).

@murrayrm
Copy link
Member

murrayrm commented Jan 6, 2018

Sent @roryyorke a PR that creates the documentation on readthedocs.

@coveralls
Copy link

coveralls commented Jan 6, 2018

Coverage Status

Coverage decreased (-0.4%) to 78.073% when pulling 36e0b0f on roryyorke:rory/augw into 33bebc1 on python-control:master.

@murrayrm murrayrm merged commit 1801c9a into python-control:master Jan 6, 2018
@roryyorke roryyorke deleted the rory/augw branch January 9, 2018 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants