## Dynamical System

The Dynamical System panel allows to test, tweak and observe how different algorithms model a dynamical system in a N-dimensional space: "the canvas".
The DS implemented in MLDemos are time-independent and provide, for each position in space, a desired velocity.
Trajectories are drawn by hand (or imported) as positions in space. A velocity for each step will be computed uniformly using the user-defined dT temporal step.
The canvas will display the results of the dynamical system in multiple layers, which can be toggled using the display options. These are:

- Samples: the original trajectory data, colors indicate class labels, which will be ignored by (most) DS algorithm
- Model Info: additional information from the algorithm (gaussian position and shape, support vectors, etc.)
- Density Map: (for 2D canvas only) a colored map or line sketch displaying the flow of the dynamical system in different regions of canvas space

For multi-dimensional data, it is not possible to display the dynamical system flow in space, therefore only the reconstruction of the known trajectories is provided.
Moving the mouse on the canvas will display the computed trajectory from the starting position until the dynamical system stops or deviates to infinity.
The canvas can also animate learned trajectories from given positions defined by the Drag Me target button.
Obstacle Avoidance
The Dynamical System can be coupled to an obstacle avoidance method, which will adapt the dynamical system so as not to penetrate obstacles put in the canvas. New obstacles can be added to the canvas using the Obstacle tool in the drawing options.
In Practice
The easiest way to test the dynamical system is to:

1. Draw some trajectories (left-click and drag around) in the canvas
2. Click on "Train"

This should train the dynamical system and draw the result.
Options and Commands
The interface for dynamical system (the right-hand side of the Algorithm Options dialog) provides the following commands:

- Train: train the dynamical system using the currently selected algorithm and options
- Clear: clear the current dynamical system model (does NOT clear the data)
- Load/Save: Load and save the current DS model (e.g. for usage in another software)
- Compare: adds the current algorithm and options to the Compare dialog for batch comparisons
- Drag Me: (for display purposes only) generate and animate trajectories from a specific starting positions (drag and drop onto the canvas)
- X: erase all displayed trajectories

The comparison is performed by computing the step-by-step error for the known trajectories, or the error between ending points,
to evaluate the DS stability at target.
The following options are available:

- Centering: align all trajectories so that they share the same Starting/Ending point, or do not align
- Zero: ensure zero velocity at the ending point in each trajectory
- Samples: number of samples per trajectory; each trajectory will be resampled, or truncated depending on the provided method (by default: uniform resampling)
- dT: temporal step, used to determine the velocity of each trajectory, and for the generation of new trajectory by the Dynamica System
- color: display the DS flow as flow-lines or as a color map (luminosity: speed, hue: direction)
- Manual Selection: manually select the training samples (overrides the Train/Test ratio option)
- Obstacle Avoidance: determine the method for obstacle avoidance (or disable it)

All other options are algorithm-dependent and should be described in the help menu of the algorithm itself.