Repository navigation
Undesired model reduction #526
Description
Activity
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.]]))Closing since this has been fixed (also duplicates #244).
@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_paramfunction correctly reports the considered setting asFalse, still getting a reduced model- Try remove_useless=False? (Leave out ‘states’) the constructor should raise an error if it receives an un-recognized keyword like this.
Yes, in v0.8.3 the keyword was called
remove_useless, so you have to usex = ctr.StateSpace(a,b,c,d, remove_useless=False)Note also that v0.8.3 did not use the
configmodule to set the default value, so callingset_defaultswon't work in that version.v0.8.4 changes the name of the keyword to
remove_useless_statesand sets the default value toTrue(but you can useset_defaultsto override).v0.9.0 (upcoming) sets the default value to
False.Many thanks
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:
the obtained state representation is the following :
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