@@ -115,7 +115,7 @@ class for a set of subclasses that are used to implement specific
115
115
difference equation for the system. This must be specified by the
116
116
subclass for the system.
117
117
118
- * _out (t, x, u): compute the output for the current state of the system.
118
+ * output (t, x, u): compute the output for the current state of the system.
119
119
The default is to return the entire system state.
120 120
121
121
"""
@@ -392,7 +392,7 @@ def dynamics(self, t, x, u):
392
392
NotImplemented ("Dynamics not implemented for system of type " ,
393
393
type (self ))
394
394
395
- def _out (self , t , x , u , params = {}):
395
+ def output (self , t , x , u , params = {}):
396
396
"""Compute the output of the system
397
397
398
398
Given time `t`, input `u` and state `x`, returns the output of the
@@ -574,7 +574,7 @@ def linearize(self, x0, u0, t=0, params={}, eps=1e-6,
574
574
"""
575
575
#
576
576
# If the linearization is not defined by the subclass, perform a
577
- # numerical linearization use the `dynamics()` and `_out ()` member
577
+ # numerical linearization use the `dynamics()` and `output ()` member
578
578
# functions.
579
579
#
580
580
@@ -589,14 +589,14 @@ def linearize(self, x0, u0, t=0, params={}, eps=1e-6,
589
589
u0 = np .ones ((ninputs ,)) * u0
590
590
591
591
# Compute number of outputs by evaluating the output function
592
- noutputs = _find_size (self .noutputs , self ._out (t , x0 , u0 ))
592
+ noutputs = _find_size (self .noutputs , self .output (t , x0 , u0 ))
593
593
594
594
# Update the current parameters
595
595
self ._update_params (params )
596
596
597
597
# Compute the nominal value of the update law and output
598
598
F0 = self .dynamics (t , x0 , u0 )
599
- H0 = self ._out (t , x0 , u0 )
599
+ H0 = self .output (t , x0 , u0 )
600
600
601
601
# Create empty matrices that we can fill up with linearizations
602
602
A = np .zeros ((nstates , nstates )) # Dynamics matrix
@@ -609,14 +609,14 @@ def linearize(self, x0, u0, t=0, params={}, eps=1e-6,
609
609
dx = np .zeros ((nstates ,))
610
610
dx [i ] = eps
611
611
A [:, i ] = (self .dynamics (t , x0 + dx , u0 ) - F0 ) / eps
612
- C [:, i ] = (self ._out (t , x0 + dx , u0 ) - H0 ) / eps
612
+ C [:, i ] = (self .output (t , x0 + dx , u0 ) - H0 ) / eps
613
613
614
614
# Perturb each of the input variables and compute linearization
615
615
for i in range (ninputs ):
616
616
du = np .zeros ((ninputs ,))
617
617
du [i ] = eps
618
618
B [:, i ] = (self .dynamics (t , x0 , u0 + du ) - F0 ) / eps
619
- D [:, i ] = (self ._out (t , x0 , u0 + du ) - H0 ) / eps
619
+ D [:, i ] = (self .output (t , x0 , u0 + du ) - H0 ) / eps
620
620
621
621
# Create the state space system
622
622
linsys = LinearIOSystem (
@@ -741,7 +741,7 @@ def dynamics(self, t, x, u):
741
741
+ np .dot (self .B , np .reshape (u , (- 1 , 1 )))
742
742
return np .array (xdot ).reshape ((- 1 ,))
743
743
744
-
B41A
def _out (self , t , x , u ):
744
+ def output (self , t , x , u ):
745
745
# Convert input to column vector and then change output to 1D array
746
746
y = np .dot (self .C , np .reshape (x , (- 1 , 1 ))) \
747
747
+ np .dot (self .D , np .reshape (u , (- 1 , 1 )))
@@ -890,12 +890,12 @@ def __call__(sys, u, params=None, squeeze=None):
890
890
"function evaluation is only supported for static "
891
891
"input/output systems" )
892
892
893
- # If we received any parameters, update them before calling _out ()
893
+ # If we received any parameters, update them before calling output ()
894
894
if params is not None :
895
895
sys ._update_params (params )
896
896
897
897
# Evaluate the function on the argument
898
- out = sys ._out (0 , np .array ((0 ,)), np .asarray (u ))
898
+ out = sys .output (0 , np .array ((0 ,)), np .asarray (u ))
899
899
_ , out = _process_time_response (sys , None , out , None , squeeze = squeeze )
900
900
return out
901
901
@@ -909,7 +909,7 @@ def dynamics(self, t, x, u):
909
909
if self .updfcn is not None else []
910
910
return np .array (xdot ).reshape ((- 1 ,))
911
911
912
- def _out (self , t , x , u ):
912
+ def output (self , t , x , u ):
913
913
y = self .outfcn (t , x , u , self ._current_params ) \
914
914
if self .outfcn is not None else x
915
915
return np .array (y ).reshape ((- 1 ,))
@@ -1098,7 +1098,7 @@ def dynamics(self, t, x, u):
1098
1098
1099
1099
return xdot
1100
1100
1101
- def _out (self , t , x , u ):
1101
+ def output (self , t , x , u ):
1102
1102
# Make sure state and input are vectors
1103
1103
x = np .array (x , ndmin = 1 )
1104
1104
u = np .array (u , ndmin = 1 )
@@ -1130,7 +1130,7 @@ def _compute_static_io(self, t, x, u):
1130
1130
state_index , input_index , output_index = 0 , 0 , 0
1131
1131
for sys in self .syslist :
1132
1132
# Compute outputs for each system from current state
1133
- ysys = sys ._out (
1133
+ ysys = sys .output (
1134
1134
t , x [state_index :state_index + sys .nstates ],
1135
1135
ulist [input_index :input_index + sys .ninputs ])
1136
1136
@@ -1521,10 +1521,10 @@ def input_output_response(sys, T, U=0., X0=0, params={}, method='RK45',
1521
1521
if nstates == 0 :
1522
1522
# No states => map input to output
1523
1523
u = U [0 ] if len (U .shape ) == 1 else U [:, 0 ]
1524
- y = np .zeros ((np .shape (sys ._out (T [0 ], X0 , u ))[0 ], len (T )))
1524
+ y = np .zeros ((np .shape (sys .output (T [0 ], X0 , u ))[0 ], len (T )))
1525
1525
for i in range (len (T )):
1526
1526
u = U [i ] if len (U .shape ) == 1 else U [:, i ]
1527
- y [:, i ] = sys ._out (T [i ], [], u )
1527
+ y [:, i ] = sys .output (T [i ], [], u )
1528
1528
return _process_time_response (
1529
1529
sys , T , y , np .array ((0 , 0 , np .asarray (T ).size )),
1530
1530
transpose = transpose , return_x = return_x , squeeze = squeeze )
@@ -1551,10 +1551,10 @@ def ivp_dynamics(t, x): return sys.dynamics(t, x, u(t))
1551
1551
# Compute the output associated with the state (and use sys.out to
1552
1552
# figure out the number of outputs just in case it wasn't specified)
1553
1553
u = U [0 ] if len (U .shape ) == 1 else U [:, 0 ]
1554
- y = np .zeros ((np .shape (sys ._out (T [0 ], X0 , u ))[0 ], len (T )))
1554
+ y = np .zeros ((np .shape (sys .output (T [0 ], X0 , u ))[0 ], len (T )))
1555
1555
for i in range (len (T )):
1556
1556
u = U [i ] if len (U .shape ) == 1 else U [:, i ]
1557
- y [:, i ] = sys ._out (T [i ], soln .y [:, i ], u )
1557
+ y [:, i ] = sys .output (T [i ], soln .y[:, i ], u )
1558
1558
1559
1559
elif isdtime (sys ):
1560
1560
# Make sure the time vector is uniformly spaced
@@ -1587,7 +1587,7 @@ def ivp_dynamics(t, x): return sys.dynamics(t, x, u(t))
1587
1587
for i in range (len (T )):
1588
1588
# Store the current state and output
1589
1589
soln .y .append (x )
1590
- y .append (sys ._out (T [i ], x , u (T [i ])))
1590
+ y .append (sys .output (T [i ], x , u (T [i ])))
1591
1591
1592
1592
# Update the state for the next iteration
1593
1593
x = sys .dynamics (T [i ], x , u (T [i ]))
@@ -1713,19 +1713,19 @@ def find_eqpt(sys, x0, u0=[], y0=None, t=0, params={},
1713
1713
# TODO: update to allow discrete time systems
1714
1714
def ode_dynamics (z ): return sys .dynamics (t , z , u0 )
1715
1715
result = root (ode_dynamics , x0 , ** kw )
1716
- z = (result .x , u0 , sys ._out (t , result .x , u0 ))
1716
+ z = (result .x , u0 , sys .output (t , result .x , u0 ))
1717
1717
else :
1718
1718
# Take y0 as fixed and minimize over x and u
1719
1719
def rootfun (z ):
1720
1720
# Split z into x and u
1721
1721
x , u = np .split (z , [nstates ])
1722
1722
# TODO: update to allow discrete time systems
1723
1723
return np .concatenate (
1724
- (sys .dynamics (t , x , u ), sys ._out (t , x , u ) - y0 ), axis = 0 )
1724
+ (sys .dynamics (t , x , u ), sys .output (t , x , u ) - y0 ), axis = 0 )
1725
1725
z0 = np .concatenate ((x0 , u0 ), axis = 0 ) # Put variables together
1726
1726
result = root (rootfun , z0 , ** kw ) # Find the eq point
1727
1727
x , u = np .split (result .x , [nstates ]) # Split result back in two
1728
- z = (x , u , sys ._out (t , x , u ))
1728
+ z = (x , u , sys .output (t , x , u ))
1729
1729
1730
1730
else :
1731
1731
# General case: figure out what variables to constrain
@@ -1826,7 +1826,7 @@ def rootfun(z):
1826
1826
dx = sys .dynamics (t , x , u ) - dx0
1827
1827
if dtime :
1828
1828
dx -= x # TODO: check
1829
- dy = sys ._out (t , x , u ) - y0
1829
+ dy = sys .output (t , x , u ) - y0
1830
1830
1831
1831
# Map the results into the constrained variables
1832
1832
return np .concatenate ((dx [deriv_vars ], dy [output_vars ]), axis = 0 )
@@ -1840,7 +1840,7 @@ def rootfun(z):
1840
1840
# Extract out the results and insert into x and u
1841
1841
x [state_vars ] = result .x [:nstate_vars ]
1842
1842
u [input_vars ] = result .x [nstate_vars :]
1843
- z = (x , u , sys ._out (t , x , u ))
1843
+ z = (x , u , sys .output (t , x , u ))
1844
1844
1845
1845
# Return the result based on what the user wants and what we found
1846
1846
if not return_y :
0 commit comments