Title: place function fails for simple case · Issue #177 · python-control/python-control · GitHub
Open Graph Title: place function fails for simple case · Issue #177 · python-control/python-control
X Title: place function fails for simple case · Issue #177 · python-control/python-control
Description: The pole placement function place fails in some simple situations. This bug is related to the current implementation of place, which is a wrapper for slicot sb01bd. If PR 176 is accepted, this bug report will refer to place_varga instead...
Open Graph Description: The pole placement function place fails in some simple situations. This bug is related to the current implementation of place, which is a wrapper for slicot sb01bd. If PR 176 is accepted, this bug ...
X Description: The pole placement function place fails in some simple situations. This bug is related to the current implementation of place, which is a wrapper for slicot sb01bd. If PR 176 is accepted, this bug ...
Opengraph URL: https://github.com/python-control/python-control/issues/177
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"place function fails for simple case","articleBody":"### The pole placement function `place` fails in some simple situations. \r\nThis bug is related to the *current* implementation of `place`, which is a wrapper for slicot sb01bd. If PR [176](https://github.com/python-control/python-control/pull/176) is accepted, this bug report will refer to `place_varga` instead.\r\n\r\nExample of failure:\r\n```\r\nimport numpy as np\r\nimport control as pc\r\nA = np.array([[0, 1],[100, 0]])\r\nB = np.array([[0],[1]])\r\nPdes = np.array([-20 + 10*1j, -20 - 10*1j])\r\nK = pc.place(A, B, Pdes)\r\n```\r\nThis raises the error (with python 2.7)\r\n\"ValueError: an attempt was made to place a complex conjugate pair on the location of a real eigenvalue\"\r\n\r\nThe problem is related to how the `alpha` parameter is computed when calling `sb01bd`, which is calculated as \r\n```\r\nsystem_eigs = np.linalg.eig(A_mat)[0]\r\nalpha = min(system_eigs.real);\r\n```\r\nClearly, A has eigenvalues [-10, +10]. But np.lingalg.eigvals(A) reports \r\neigvals = [10.000000000000002, -9.9999999999999982], and so we have set\r\n```\r\nalpha = -9.9999999999999982\r\n```\r\n\r\n`sb01bd` will only move eigenvalues that are greater than `alpha`. It seems that `sb01bd` must calculate the eigenvalues slightly differently than scipy, so it thinks it has only one eigenvalue to move (namely, the one at +10). This evidently corresponds to [error 4](http://slicot.org/objects/software/shared/doc/SB01BD.html).\r\n\r\nIf we fudge the `alpha` parameter, and call the sb01bd wrapper directly, this works as expected\r\n```\r\nimport numpy as np\r\nfrom slycot import sb01bd\r\nA = np.array([[0, 1],[100, 0]])\r\nB = np.array([[0],[1]])\r\nPdes = np.array([-20 + 10*1j, -20 - 10*1j])\r\n\r\nalpha = min(np.linalg.eigvals(A).real)*2;\r\nA_z,w,nfp,nap,nup,K,Z = sb01bd(B.shape[0], B.shape[1],\r\n len(Pdes), alpha, A, B, Pdes, 'C')\r\nprint 'Placed Poles: %s'%np.linalg.eigvals(A + B.dot(K))\r\n# yields on my system:\r\n# Placed Poles: [-20.+10.j -20.-10.j]\r\n````\r\n\r\n\r\n\r\n### place() is not implemented for discrete time\r\n`sb01bd` can place poles for discrete time systems. However, the current wrapper assumes a continuous time system, both in how `alpha` is calculated (it should be based on `abs(eigvals)` for discrete systems) and by passing `C` as the dico parameter. This is undocumented in the doc string.\r\n","author":{"url":"https://github.com/rabraker","@type":"Person","name":"rabraker"},"datePublished":"2018-01-03T20:42:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/177/python-control/issues/177"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f046a339-33ae-85c8-90bb-b1ca32502b71 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DF88:3257A7:2262A9:2FAADE:697BBB5B |
| html-safe-nonce | 481293414347c3c533b97f02db85dc63ccce6dc1ee2f9054c6558c2d48270ecc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjg4OjMyNTdBNzoyMjYyQTk6MkZBQURFOjY5N0JCQjVCIiwidmlzaXRvcl9pZCI6IjY0ODExNjc4MzgyNjUxOTUzNTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 80ddddb42c6e52b21aab1beb7d84b9c6dc529d042c6aed1728300ebea1f5e983 |
| hovercard-subject-tag | issue:285803519 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-control/python-control/177/issue_layout |
| twitter:image | https://opengraph.githubassets.com/20078ec5db27f27970146789779d775a45fb96c168903f2b6b23530aed5411c0/python-control/python-control/issues/177 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/20078ec5db27f27970146789779d775a45fb96c168903f2b6b23530aed5411c0/python-control/python-control/issues/177 |
| og:image:alt | The pole placement function place fails in some simple situations. This bug is related to the current implementation of place, which is a wrapper for slicot sb01bd. If PR 176 is accepted, this bug ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rabraker |
| hostname | github.com |
| expected-hostname | github.com |
| None | ab413746e1b95376981dfec4a04b2384a611b96affe802ee3ee6d752200afbb1 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-control/python-control git https://github.com/python-control/python-control.git |
| octolytics-dimension-user_id | 2285872 |
| octolytics-dimension-user_login | python-control |
| octolytics-dimension-repository_id | 22791752 |
| octolytics-dimension-repository_nwo | python-control/python-control |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 22791752 |
| octolytics-dimension-repository_network_root_nwo | python-control/python-control |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bea0e0f1995ab0bb7fa336572c353032cf897ec1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width