Skip to content

fix rlocus timeout due to inefficient _default_wn calculation #527

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

Merged
merged 1 commit into from
Feb 5, 2021

Conversation

murrayrm
Copy link
Member

This PR fixes an obscure bug that got pointed out to me a year ago in e-mail from a colleague in Costa Rica:

I have a piece of code that I run for my students. I downloaded the latest control module and it does not print the root locus any more. I think it gets stuck in an iterative process. Nothing changed in the code. I suppose something in the updated version is causing the problem. Has anybody else made a complaint about the root locus?

Turns out that the problem was that he had a very unusual pole/zero pattern in which the algorithm for computing the default natural frequencies to use in plotting the grid was introduced in PR #138. The code essentially used the x-axis major ticks as the starting point for the natural frequencies and then added additional ticks to "complete" the frequencies on the y axis. The problem was that if the x-axis had tick marks that were orders of magnitude different that the y-axis, this could generate a lot of additional natural frequencies (which were subsequently removed a later point in the code).

I didn't want to spend a lot of time on this fix, so I basically put in a check to see when you might end up generating an excessive number of ticks based on this heuristic and switched things so that if that happens, you use the y-axis ticks as the starting point. There's a unit test to make sure it is working right (that also covers the new code).

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 87.78% when pulling 4ef4906 on murrayrm:fix_rlocus_timeout into 343d5d6 on python-control:master.

@bnavigator bnavigator merged commit ff7d827 into python-control:master Feb 5, 2021
@murrayrm murrayrm deleted the fix_rlocus_timeout branch February 11, 2021 06:15
@murrayrm murrayrm added this to the 0.9.0 milestone Mar 20, 2021
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.

4 participants