dynax.system
Classes representing dynamical systems.
Functions
|
Mark an attribute value as trainable and box-constrained on [lower, upper]. |
|
Mark an attribute value as trainable and unconstrained. |
|
Mark an attribute value as trainable and non-negative. |
|
Mark an attribute value as non-trainable. |
Classes
Base class for control-affine dynamical systems. |
|
Base class for dynamical systems. |
|
|
System with dynamic state-feedback. |
|
Two systems connected via feedback. |
|
A linear, time-invariant dynamical system. |
|
Two systems in series. |
|
System with static state-feedback. |
- dynax.system.field(**kwargs)[source]
Mark an attribute value as trainable and unconstrained.
- Parameters:
**kwargs (
Any) – Keyword arguments passed todataclasses.field().- Return type:
- dynax.system.static_field(**kwargs)[source]
Mark an attribute value as non-trainable.
Like
equinox.field(), but marks the field as unconstrained and converts JAX arrays to NumPy arrays so the value is treated as a static constant.
- dynax.system.boxed_field(lower, upper, **kwargs)[source]
Mark an attribute value as trainable and box-constrained on [lower, upper].
- Parameters:
lower (
float) – Lower bound.upper (
float) – Upper bound.**kwargs (
Any) – Keyword arguments passed todataclasses.field().
- Return type:
- dynax.system.non_negative_field(min_val=0.0, **kwargs)[source]
Mark an attribute value as trainable and non-negative.
- Parameters:
min_val (
float) – Minimum value.**kwargs (
Any) – Keyword arguments passed todataclasses.field().
- Return type:
- class dynax.system.AbstractSystem[source]
Bases:
ModuleBase class for dynamical systems.
Any dynamical system in Dynax must inherit from this class. Subclasses can define continuous-time
\[\begin{split}ẋ &= f(x, u, t) \\ y &= h(x, u, t)\end{split}\]or discrete-time
\[\begin{split}x_{k+1} &= f(x_k, u_k, t) \\ y_k &= h(x_k, u_k, t)\end{split}\]system. The distinction between the two is only made when instances of subclasses are passed to objects such as
dynax.evolution.Flow,dynax.evolution.Map,dynax.linearize.input_output_linearize, ordynax.linearize.discrete_input_output_linearize.Subclasses must set values for the n_inputs, and initial_state attributes and implement the vector_field method. The output method describes the measurement equations. By default, the full state vector is returned as output.
Example:
class IntegratorAndGain(AbstractSystem): n_states = 1 n_inputs = "scalar" gain: float def vector_field(self, x, u, t): dx = u return dx def output(self, x, u, t): return self.gain*x
AbstractSystem is a dataclass and as such defines a default constructor which can make it necessary to implement a custom __init__ method.
- linearize(x0=None, u0=None, t0=None)[source]
Compute the Jacobian linearization around a point.
- Parameters:
- Returns:
LinearSystem– Linearized system.
- class dynax.system.AbstractControlAffine[source]
Bases:
AbstractSystemBase class for control-affine dynamical systems.
Both in continuous-time
\[\begin{split}ẋ &= f(x) + g(x)u \\ y &= h(x) + i(x)u\end{split}\]or the discrete-time equivalent.
Subclasses must implement the f and g methods that characterize the vector field. Optionally, the h and i methods can be implemented to describe the measurement equations. By default, the full state vector is returned as output.
- class dynax.system.LinearSystem(A, B, C, D, initial_state=None)[source]
Bases:
AbstractControlAffineA linear, time-invariant dynamical system.
\[\begin{split}ẋ &= Ax + Bu \\ y &= Cx + Du\end{split}\]- Parameters:
A (
Array) – System matrices of appropriate shape.B (
Array) – System matrices of appropriate shape.C (
Array) – System matrices of appropriate shape.D (
Array) – System matrices of appropriate shape.
- A: Array
State matrix.
- B: Array
Input matrix.
- C: Array
Output matrix.
- D: Array
Feedthrough matrix.
- initial_state: Array = None
Initial state vector.
- class dynax.system.SeriesSystem(sys1, sys2)[source]
Bases:
AbstractSystem,_CoupledSystemMixinTwo systems in series.
\[\begin{split}ẋ_1 &= f_1(x_1, u, t) \\ y_1 &= h_1(x_1, u, t) \\ ẋ_2 &= f_2(x_2, y1, t) \\ y_2 &= h_2(x_2, y1, t)\end{split}\]- Parameters:
sys1 (
AbstractSystem) – System with \(n\) outputs.sys2 (
AbstractSystem) – System with \(n\) inputs.
- initial_state: Array
Initial state vector.
- class dynax.system.FeedbackSystem(sys1, sys2)[source]
Bases:
AbstractSystem,_CoupledSystemMixinTwo systems connected via feedback.
\[\begin{split}ẋ_1 &= f_1(x_1, u + y_2, t) \\ y_1 &= h_1(x_1, t) \\ ẋ_2 &= f_2(x_2, y_1, t) \\ y_2 &= h_2(x_2, y_1, t)\end{split}\]- Parameters:
sys1 (
AbstractSystem) – System in forward path with \(n\) inputs.sys2 (
AbstractSystem) – System in feedback path with \(n\) outputs.
- initial_state: Array
Initial state vector.
- class dynax.system.StaticStateFeedbackSystem(sys, v)[source]
Bases:
AbstractSystemSystem with static state-feedback.
\[\begin{split}ẋ &= f(x, v(x), t) \\ y &= h(x, u, t)\end{split}\]- Parameters:
sys (
AbstractSystem) – System with vector field \(f\) and output \(h\).v (
Callable[[Array],Array]) – Static feedback law \(v\).
- initial_state: Array
Initial state vector.
- class dynax.system.DynamicStateFeedbackSystem(sys1, sys2, v)[source]
Bases:
AbstractSystem,_CoupledSystemMixinSystem with dynamic state-feedback.
\[\begin{split}ẋ_1 &= f_1(x_1, v(x_1, x_2, u), t) \\ ẋ_2 &= f_2(x_2, u, t) \\ y &= h_1(x_1, u, t)\end{split}\]- Parameters:
sys1 (
AbstractSystem) – System with vector field \(f_1\) and output \(h\).sys2 (
AbstractSystem) – System with vector field \(f_2\).v (
Callable[[Array,Array,Array|float],Array]) – dynamic feedback law \(v\).
- initial_state: Array
Initial state vector.