You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In simulation, simple vectors are used to represent all states, signals and event values. In the simulation results, they are represented as matrices, with the row being the time-axis and the column being the state/signal/event axis. This is inconsistent, e.g., with the matrix algebra for LTI, and also makes vectorization of state derivative, signal and event functions more difficult.
For an LTI, the state derivative is represented as A x(t) + B u(t) , with the state x(t) and the input u(t). Thus, both the state and the input are expected to be column vectors. Considering a time series -- such as the result of a simulation -- it is most natural to represent the values of state and inputs at different times as columns of matrices X and U, so that the matrix of state derivatives would naturally be A X + B U.
Similarly, linear outputs can be represented as y(t) = C x(t) + D u(t), and for a time series, Y = C X + D U would still hold. The structure of the formula -- and the code representing the formula -- would not have to change.
NumPy supports vectorization and broadcasting in that manner, and, for example, most of the ODE solvers provided by SciPy also do. If we were to consistently represent state and input vectors as column vectors, we could make use of these features by default without any code-changes on the state derivative, signal and event functions being necessary.
Vectorization would be the default then, and for any function not vectorizable for any reason, the numpy.vectorize function could be used as an adaptor.
This would mostly require changes to the SimulatorResult class, but also would allow us to simplify the linearization implementation.
The text was updated successfully, but these errors were encountered:
In simulation, simple vectors are used to represent all states, signals and event values. In the simulation results, they are represented as matrices, with the row being the time-axis and the column being the state/signal/event axis. This is inconsistent, e.g., with the matrix algebra for LTI, and also makes vectorization of state derivative, signal and event functions more difficult.
For an LTI, the state derivative is represented as
A x(t) + B u(t)
, with the statex(t)
and the inputu(t)
. Thus, both the state and the input are expected to be column vectors. Considering a time series -- such as the result of a simulation -- it is most natural to represent the values of state and inputs at different times as columns of matricesX
andU
, so that the matrix of state derivatives would naturally beA X + B U
.Similarly, linear outputs can be represented as
y(t) = C x(t) + D u(t)
, and for a time series,Y = C X + D U
would still hold. The structure of the formula -- and the code representing the formula -- would not have to change.NumPy supports vectorization and broadcasting in that manner, and, for example, most of the ODE solvers provided by SciPy also do. If we were to consistently represent state and input vectors as column vectors, we could make use of these features by default without any code-changes on the state derivative, signal and event functions being necessary.
Vectorization would be the default then, and for any function not vectorizable for any reason, the
numpy.vectorize
function could be used as an adaptor.This would mostly require changes to the
SimulatorResult
class, but also would allow us to simplify the linearization implementation.The text was updated successfully, but these errors were encountered: