Skip to content

Return type of eigenvalues from lqr and lqe not consistent #439

Description

@bnavigator

This came up while pytestifying statefbk_test.py (#438)

lqr() will always return E as (nstates, ) array

E = w[0:nstates];
return _ssmatrix(K), _ssmatrix(S), E

lqe() returns _ssmatrix(E) which is a (nstates, ) array or (1, nstates) matrix depending on config.defaults.use_numpy_matrix()

return _ssmatrix(LT.T), _ssmatrix(P), _ssmatrix(E)

Activity

  1. sawyerbfuller commented on Jul 29, 2020

    @sawyerbfuller
    Contributor
  2. bnavigator commented on Jul 29, 2020

    @bnavigator
    ContributorAuthor

    I agree :)

  3. bnavigator commented on Aug 16, 2020

    @bnavigator
    ContributorAuthor

    See also #418

  4. added this to the 0.8.4 milestone on Dec 22, 2020
  5. self-assigned this
    on Dec 22, 2020
  6. murrayrm commented on Dec 24, 2020

    @murrayrm
    Member

    I'd like to clean this up before 0.8.4 release, but there are a few issues that could break users' code:

    • lqr returns _ssmatrix(K), _ssmatrix(S), E, for which the first return value is the gain matrix (2D array or matrix, depending on config settings), the second return value is the solution to the Riccati equation (2D array or matrix), and the third value is a 1D array (list of closed loop eigenvalues).
    • lqe returns _ssmatrix(K), _ssmatrix(S), _ssmatrix(E), which forces the third argument to be a 2D array.
    • care and dare return _ssmatrix(X), w[:n], _ssmatrix(G), for which the first return value is the solution to the Riccati equation (2D array or matrix), the second return value is a list of eigenvalues (1D array), and the third argument is the gain matrix (2D array or matrix).

    I think we should make the following change in 0.8.4:

    • Change return values for lqe to match lqr

    This will require an updated unit test (as noted above) and could break some users' code. But the fix to user code is simple (convert to 2D array) and so I think it is OK for 0.8.4.

    I think we might want to consider whether to make changes to care and dare in 0.9.0:

    • We can leave things the same with the argument that care and dare are returning solutions to the Riccati equation as their primary usage => that solution should be first. The lqr and lqe functions call care or dare, but are returning controllers as their primary usage => OK for the order to be different.

    • We can change the order of the return values for care and dare to match lqr and lqe.

    My current feeling is that we leave care and dare alone. Thoughts?

  7. sawyerbfuller commented on Dec 24, 2020

    @sawyerbfuller
    Contributor
  8. murrayrm commented on Dec 26, 2020

    @murrayrm
    Member

    Fixed in #477.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions