DynamicModeDecompositionWithControl<T>
Models & Types · AiDotNet.Control
Identifies a linear state-space model from measured trajectories by dynamic mode decomposition with control.
For Beginners
You poke a system, record what it does, and this works backwards to the equations. It is how you get a model of something you cannot derive from physics — a chemical process, a building’s temperature, a machine with unknown friction. What comes out plugs straight into the controllers in this namespace.
How It Works
Implements DMDc from J. L. Proctor, S. L. Brunton and J. N. Kutz, “Dynamic Mode Decomposition with Control”, SIAM Journal on Applied Dynamical Systems 15(1), 2016, pp. 142-161.
The idea, which is simpler than it sounds. Line up every measured transition: a matrix
X of states, the matrix X' of the states that followed them, and the matrix
Υ of the inputs applied in between. If the system really is x' = Ax + Bu then
X' = [A B]·[X; Υ], and recovering [A B] is a least-squares problem — solved through
the pseudoinverse of the stacked data. There is no iteration and no initial guess; the answer is
a single matrix factorization.
Why the SVD rather than a normal-equations solve. Real trajectory data is close to rank-deficient: states move together, inputs are correlated with the responses they caused, and successive snapshots are nearly the same. Forming the normal equations squares the condition number of all that, and a mildly ill-conditioned data set becomes an unusable one. Truncating the singular value decomposition instead discards precisely the directions the data does not determine, which is both better conditioned and more honest — a direction with no information in it should not be assigned a coefficient.
The distinguishing difficulty DMDc solves. Plain dynamic mode decomposition applied to
controlled data gives the wrong dynamics: it cannot tell whether the state moved because of the
system or because of the input, and so it attributes the actuation to the system’s own behaviour.
Including the inputs in the regression is what separates the two, and it is why the identified
A here describes the uncontrolled system rather than the closed loop that produced the
data.
Example
// states: one column per snapshot; nextStates: the same system one step later;
// inputs: the command applied at each of those snapshots.
var states = new Matrix<double>(new double[,] { { 1.0, 0.9, 0.8 }, { 0.0, 0.1, 0.2 } });
var nextStates = new Matrix<double>(new double[,] { { 0.9, 0.8, 0.7 }, { 0.1, 0.2, 0.3 } });
var inputs = new Matrix<double>(new double[,] { { 0.1, 0.1, 0.1 } });
var result = new DynamicModeDecompositionWithControl<double>()
.Identify(states, nextStates, inputs);
// LQR weights the state and input costs as matrices
var stateCost = Matrix<double>.CreateIdentity(2);
var inputCost = Matrix<double>.CreateIdentity(1);
var controller = new LinearQuadraticRegulator<double>(
result.StateMatrix, result.InputMatrix, stateCost, inputCost);
Constructors
| Constructor | Summary |
|---|---|
DynamicModeDecompositionWithControl(double singularValueThreshold) |
Creates a DMDc identifier. |
Methods
| Method | Summary |
|---|---|
SystemIdentificationResult<T> Identify(Matrix<T> states, Matrix<T> nextStates, Matrix<T> inputs, int? rank) |
Identifies A and B from measured transitions. |