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 — Undesired model reduction · Issue #526 · python-control/python-control

Undesired model reduction #526

New issue
Copy link
New issue
Copy link
Closed
Closed
Undesired model reduction#526
Copy link
Labels
duplicate

Description

@DarioTurchi
DarioTurchi
opened on Jan 30, 2021
Issue body actions

Hello,
It seems to me that when I try to define a non-minimal state representation (e.g. with a state that can't be controlled or that doesn't have a dynamic) the system returned by the StateSpace class is automatically reduced, by eliminating such "non meaningful" states.
As example consider the following code:

from control import StateSpace

a = [[0., 0., 0.], [0., 0., 0.], [0., 0., 0.]]
b = [[1, 0], [0, 0], [0, 1]]
c = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
d = [[0, 0], [0, 0], [0, 0]]
x = StateSpace(a,b,c,d)

the obtained state representation is the following :

>>> x
A = [[0. 0.]
 [0. 0.]]

B = [[1. 0.]
 [0. 1.]]

C = [[1. 0.]
 [0. 0.]
 [0. 1.]]

D = [[0. 0.]
 [0. 0.]
 [0. 0.]]

where the second state has been removed. Is it possible to not have this automatic model reduction (regardless of the fact that such state is not meaningful ) ? I couldn't find anything in the documentation

Activity

  1. bnavigator commented on Jan 30, 2021

    @bnavigator
    bnavigator
    on Jan 30, 2021
    Contributor
    More actions

    Hello Dario,

    this has recently been fixed in #509. Until it lands in a release, you can manually set remove_useless_states=False:

    >>> from control.config import set_defaults
    >>> set_defaults('statesp', remove_useless_states=False)
    >>> x = StateSpace(a,b,c,d)
    >>> x
    StateSpace(array([[0., 0., 0.],
           [0., 0., 0.],
           [0., 0., 0.]]), array([[1., 0.],
           [0., 0.],
           [0., 1.]]), array([[1., 0., 0.],
           [0., 1., 0.],
           [0., 0., 1.]]), array([[0., 0.],
           [0., 0.],
           [0., 0.]]))
    
    
  2. murrayrm
    added
    duplicate
    on Jan 30, 2021
  3. murrayrm commented on Jan 30, 2021

    @murrayrm
    murrayrm
    on Jan 30, 2021
    Member
    More actions

    Closing since this has been fixed (also duplicates #244).

  4. murrayrm
    closed this as completedon Jan 30, 2021
  5. DarioTurchi commented on Jan 31, 2021

    @DarioTurchi
    DarioTurchi
    on Jan 31, 2021
    Author
    More actions

    @murrayrm @bnavigator
    I am really sorry to keep bothering you, but this is still not working for me.
    Do I need the package above a specific version (have 0.8.3)?
    Am I doing anything stupid ?

    I tried with both numpy array and lists for the definition of matrices A,B,C,D:

    Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
    [GCC 9.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import control as ctr
    >>> ctr.config.set_defaults('statesp', remove_useless_states=False)
    >>> a = [[0., 0., 0.], [0., 0., 0.], [0., 0., 0.]]
    >>> b = [[1, 0], [0, 0], [0, 1]]
    >>> c = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
    >>> d = [[0, 0], [0, 0], [0, 0]]
    >>> x = ctr.StateSpace(a,b,c,d)
    >>> ctr.config._get_param('statesp', 'remove_useless_states')
    False
    >>> x
    A = [[0. 0.]
     [0. 0.]]
    
    B = [[1. 0.]
     [0. 1.]]
    
    C = [[1. 0.]
     [0. 0.]
     [0. 1.]]
    
    D = [[0. 0.]
     [0. 0.]
     [0. 0.]]
    
    >>>
    
    Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
    [GCC 9.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from numpy import array
    >>> from control import StateSpace
    >>> from control.config import set_defaults, _get_param
    >>> a = array([[0., 0., 0.], [0., 0., 0.], [0., 0., 0.]])
    >>> b = array([[1, 0], [0, 0], [0, 1]])
    >>> c = array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
    >>> d = array([[0, 0], [0, 0], [0, 0]])
    >>> set_defaults('statesp', remove_useless_states=False)
    >>> x = StateSpace(a,b,c,d)
    >>> _get_param('statesp', 'remove_useless_states')
    False
    >>> x
    A = [[0. 0.]
     [0. 0.]]
    
    B = [[1. 0.]
     [0. 1.]]
    
    C = [[1. 0.]
     [0. 0.]
     [0. 1.]]
    
    D = [[0. 0.]
     [0. 0.]
     [0. 0.]]
    
    >>>
    

    The _get_param function correctly reports the considered setting as False, still getting a reduced model

  6. sawyerbfuller commented on Jan 31, 2021

    @sawyerbfuller
    sawyerbfuller
    on Jan 31, 2021 via email
    Contributor
    More actions
    Try remove_useless=False? (Leave out ‘states’) the constructor should raise an error if it receives an un-recognized keyword like this.
  7. murrayrm commented on Jan 31, 2021

    @murrayrm
    murrayrm
    on Jan 31, 2021
    Member
    More actions

    Yes, in v0.8.3 the keyword was called remove_useless, so you have to use

    x = ctr.StateSpace(a,b,c,d, remove_useless=False)
    

    Note also that v0.8.3 did not use the config module to set the default value, so calling set_defaults won't work in that version.

    v0.8.4 changes the name of the keyword to remove_useless_states and sets the default value to True (but you can use set_defaults to override).

    v0.9.0 (upcoming) sets the default value to False.

  8. DarioTurchi commented on Jan 31, 2021

    @DarioTurchi
    DarioTurchi
    on Jan 31, 2021
    Author
    More actions

    Many thanks

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — 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.