GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add passivity module, ispassive function, and passivity_test. Introduces optional dependency cvxopt. by Mark-Yeatman · Pull Request #739 · python-control/python-control

Conversation

@Mark-Yeatman

@Mark-Yeatman Mark-Yeatman commented May 31, 2022

Copy link
Copy Markdown
Contributor

I made a discussion topic a couple of weeks ago about making a passivity module, @murrayrm suggested making a draft PR. Here it is!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Mark
Add passivity module, is_passive function, and passivity_test.
e8e87a4
@Mark-Yeatman
Mark-Yeatman marked this pull request as ready for review May 31, 2022 03:53
@Mark-Yeatman

Mark-Yeatman commented May 31, 2022

Copy link
Copy Markdown
Contributor Author

I need to cut the formation of the LMI via symbolic variables for performance. Did a timing test on a size 20 state, input, output system, 99% of the time is spent constructing the LMI and converting to cvxopt form.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnavigator

bnavigator commented May 31, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

The initial disussion is here: #732

Thanks for the initiative!

As far as I understand, you introduce 3 new depenendies because you work with symbolic matrices:

  • sympy
  • lmi_sdp -- https://github.com/cdsousa/PyLMI-SDP, "About" says unmaintained
  • cvxopt -- http://cvxopt.org/ has complex dependencies on various numeric libraries

Would it be possible to implement the matrix handling and solving with NumPy and SciPy functions only?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Mark-Yeatman

Mark-Yeatman commented Jun 1, 2022

Copy link
Copy Markdown
Contributor Author

Would it be possible to implement the matrix handling and solving with NumPy and SciPy functions only?

I'm about 60% sure cvxopt is necessary to solve the linear matrix inequality. Sympy and lmi_sdp can definitely be dropped.

Cvxopt only requires BLAS/LAPACK, which it seems that slycot also requires. So this passivity package could be setup to be optional?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnavigator

bnavigator commented Jun 1, 2022

Copy link
Copy Markdown
Contributor

CVXOPT is available on conda-forge and as wheels with bundled libraries on PyPI. They link and bundle OpenBLAS. I am not sure how well that plays with "Generic" Netlib linked NumPy and Slycot packages. But we can worry about that when it comes up.

It must be installed in the test suite, so we need to add it to the requirements. It can be set as optional similar to how we do it with Slycot.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Mark added 3 commits June 6, 2022 14:32
Mark
Remove dependancies on lmi-sdp and sympy for is_passive.
2eef661
Mark
Use sys.nstates in stead of using A.shape[0]
147a24e
Mark
Attempt to setup cvxopt similar to slycot.
fdb2d4a
@Mark-Yeatman

Mark-Yeatman commented Jun 6, 2022

Copy link
Copy Markdown
Contributor Author

@bnavigator I've removed sympy and lmi-sdp from the function, and I attempted to setup cvxopt in the test suite.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnavigator
bnavigator reviewed Jun 6, 2022
View reviewed changes

@bnavigator bnavigator left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks! Some initial review comments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread control/exception.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .github/workflows/python-package-conda.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread control/passivity.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread control/tests/passivity_test.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

bnavigator
bnavigator reviewed Jun 6, 2022
View reviewed changes
Comment thread control/passivity.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Mark-Yeatman and others added 3 commits June 7, 2022 11:48
@Mark-Yeatman
Remove unused import.
dc46f3c
@Mark-Yeatman @bnavigator
Apply suggestions from code review
0ecc135
Co-authored-by: Ben Greiner <[email protected]>
@Mark-Yeatman
Update passivity.py
649b21e
@coveralls

coveralls commented Jun 7, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.02%) to 94.549% when pulling c2255b0 on Mark-Yeatman:passivity-tools into d98ed29 on python-control:main.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

murrayrm
murrayrm reviewed Jun 7, 2022
View reviewed changes

@murrayrm murrayrm left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

A few comments below. Also, it would be nice to add a unit test to make sure that if cvxopt is not installed that the proper exception is raised.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread control/passivity.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread control/passivity.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

bnavigator
bnavigator reviewed Jun 7, 2022
View reviewed changes
Comment thread .github/workflows/python-package-conda.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

bnavigator
bnavigator reviewed Jun 7, 2022
View reviewed changes
Comment thread control/passivity.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Mark
Address some review comments.
b73e6fe
@Mark-Yeatman

Mark-Yeatman commented Jun 13, 2022

Copy link
Copy Markdown
Contributor Author

@bnavigator I believe I've resolved all the outstanding review comments?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnavigator
bnavigator reviewed Jun 13, 2022
View reviewed changes

@bnavigator bnavigator left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

One more review comment

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread control/passivity.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Mark-Yeatman and others added 3 commits June 13, 2022 14:56
@Mark-Yeatman @bnavigator
Update control/passivity.py
cd7ec0f
Co-authored-by: Ben Greiner <[email protected]>
Mark
Remove duplicate "print" statement.
d65f1d2
Mark
Fix grammar in doc string.
7e79c82
JBannwarth
JBannwarth reviewed Jun 13, 2022
View reviewed changes
Comment thread control/passivity.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Mark
Another grammar in doc string fix.
c57b928
@ilayn

ilayn commented Jun 13, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Instead of writing things in the standard SDP notation, you might want to use CVXPY notation (which acts like YALMIP) so you don't have to use the tiresome basis matrices.

Also note that strictly proper systems cannot be checked via positive real lemma via strict inequalities due zero D + D.T block forcing the optimization problem to infeasibilty. You either have to use extended version or nudge D block with epsilon*np.eye(m). Alternatively you can solve the LMI < alpha*eye(n) and minimize alpha and if it is sufficiently small then you can call it feasible.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Mark-Yeatman

Mark-Yeatman commented Jun 14, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I would definitely be up for using cvxpy, but it looks like it has more dependencies than just using cvxopt (https://www.cvxpy.org/install/#install-from-source vs https://cvxopt.org/install/#building-and-installing-from-source)? That seems like an issue for a project maintainer.

You're right about the D = 0 case, I will nudge it as you suggested. Thanks for catching that.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Mark
Address edge case of stricly proper systems.
27487a9
@bnavigator

bnavigator commented Jun 14, 2022

Copy link
Copy Markdown
Contributor

CVXPY: I don't think it is necessary to employ a full domain specific language with all its dependencies for one hardcoded optimization problem.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnavigator
bnavigator reviewed Jun 14, 2022
View reviewed changes
Comment thread control/passivity.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

bnavigator
bnavigator reviewed Jun 14, 2022
View reviewed changes
Comment thread control/tests/passivity_test.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

bnavigator
bnavigator reviewed Jun 14, 2022
View reviewed changes
Comment thread control/passivity.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

bnavigator
bnavigator reviewed Jun 14, 2022
View reviewed changes
Comment thread control/passivity.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Mark
Expand unit tests, add info to doc string for parameters and returns,…
d6916c6
… rename is_passive to ispassive for naming convention consistency. Autoformat to pep8.
@bnavigator bnavigator changed the title Add passivity module, is_passive function, and passivity_test. Introduces dependencies on lmi_sdp and cvxopt. Add passivity module, ispassive function, and passivity_test. Introduces optional dependency cvxopt. Jun 14, 2022
bnavigator
bnavigator reviewed Jun 14, 2022
View reviewed changes
Comment thread control/tests/passivity_test.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread control/tests/passivity_test.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Mark-Yeatman and others added 4 commits June 14, 2022 11:26
@Mark-Yeatman
Parameterize unit tests. Catch edge case of A=0.
bb16be0
@Mark-Yeatman
Run autopep8.
cf0eac3
@Mark-Yeatman
Add wrapper like functionality for ispassive(), so that it can be cal…
7e47d80
…led in an object oriented style as a LTI class member. Added unit tests for transfer function and oo style calls. Ran autopep8 on lti.py.
@bnavigator
mark the whole passivity_test module as skippable
ce11d0b
@bnavigator

bnavigator commented Jun 16, 2022

Copy link
Copy Markdown
Contributor

I took the liberty of fixing the missing skips. I hope you don't mind.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnavigator
bnavigator reviewed Jun 16, 2022
View reviewed changes
Comment thread control/lti.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Mark and others added 3 commits June 16, 2022 09:14
Mark
Fix bug in tests and lti.py.
f7d74b2
@Mark-Yeatman
Merge branch 'main' into passivity-tools
0c361df
Mark
Fix merge issue.
c2255b0
bnavigator
bnavigator approved these changes Jun 16, 2022
View reviewed changes

@bnavigator bnavigator left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think this is ready for a merge. Any improvements welcome with subsequent PRs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Mark-Yeatman reacted with hooray emoji
All reactions
  • 🎉 1 reaction
@murrayrm
murrayrm merged commit 2f29a4c into python-control:main Jun 16, 2022
@murrayrm murrayrm added this to the 0.9.3 milestone Dec 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@murrayrm murrayrm murrayrm left review comments
@bnavigator bnavigator bnavigator approved these changes
+1 more reviewer
@JBannwarth JBannwarth JBannwarth left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

0.9.3

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@Mark-Yeatman @bnavigator @coveralls @ilayn @murrayrm @JBannwarth
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.