immrax.system#

class immrax.system.System#

Bases: ABC

A dynamical system of one of the following forms:

\[\dot{x} = f(t, x, \dots), \text{ or } x^+ = f(t, x, \dots).\]

where \(t\in T\in\{\mathbb{Z},\mathbb{R}\}\) is a discrete or continuous time variable, \(x\in\mathbb{R}^n\) is the state of the system, and \(\dots\) are some other inputs, perhaps control and disturbance.

There are two main attributes that need to be defined in a subclass:

  • evolution : Literal[‘continuous’, ‘discrete’], which specifies whether the system is continuous or discrete.

  • xlen : int, which specifies the dimension of the state space.

The main method that needs to be defined is f(t, x, *args, **kwargs), which returns the time evolution of the state at time t and state x.

Methods

__call__(*args, **kwargs)

Call self as a function.

compute_trajectory(t0, tf, x0[, inputs, dt, ...])

Computes the trajectory of the system from time t0 to tf with initial condition x0.

f(t, x, *args, **kwargs)

The right hand side of the system

evolution: Literal['continuous', 'discrete']#
xlen: int#
abstractmethod f(t: Integer | Float, x: Array, *args, **kwargs) Array#

The right hand side of the system

Parameters:
tUnion[Integer, Float]

The time of the system

xjax.Array

The state of the system

*args

Inputs (control, disturbance, etc.) as positional arguments depending on parent class.

**kwargs

Other keyword arguments depending on parent class.

Returns:
jax.Array

The time evolution of the state

compute_trajectory(t0: Integer | Float, tf: Integer | Float, x0: Array, inputs: List[Callable[[int, Array], Array]] = [], dt: float = 0.01, *, solver: Literal['euler', 'rk45', 'tsit5'] | AbstractSolver = 'tsit5', f_kwargs: immutabledict = immutabledict({}), **kwargs) Trajectory#

Computes the trajectory of the system from time t0 to tf with initial condition x0.

Parameters:
t0Union[Integer,Float]

Initial time

tfUnion[Integer,Float]

Final time

x0jax.Array

Initial condition

inputsTuple[Callable[[int,jax.Array], jax.Array]], optional

A tuple of Callables u(t,x) returning time/state varying inputs as positional arguments into f, by default ()

dtfloat, optional

Time step, by default 0.01

solverUnion[Literal[‘euler’, ‘rk45’, ‘tsit5’], AbstractSolver], optional

Solver to use for diffrax, by default ‘tsit5’

f_kwargsimmutabledict, optional

An immutabledict to pass as keyword arguments to the dynamics f, by default {}

**kwargs

Additional kwargs to pass to the solver from diffrax

Returns:
Trajectory

_description_

class immrax.system.ReversedSystem(sys: System)#

Bases: System

A system with time reversed dynamics, i.e. \(\dot{x} = -f(t,x,...)\).

Methods

__call__(*args, **kwargs)

Call self as a function.

compute_trajectory(t0, tf, x0[, inputs, dt, ...])

Computes the trajectory of the system from time t0 to tf with initial condition x0.

f(t, x, *args, **kwargs)

The right hand side of the system

sys: System#
f(t: Integer | Float, x: Array, *args, **kwargs) Array#

The right hand side of the system

Parameters:
tUnion[Integer, Float]

The time of the system

xjax.Array

The state of the system

*args

Inputs (control, disturbance, etc.) as positional arguments depending on parent class.

**kwargs

Other keyword arguments depending on parent class.

Returns:
jax.Array

The time evolution of the state

class immrax.system.LinearTransformedSystem(sys: System, T: Array)#

Bases: System

Linear Transformed System A system with dynamics \(\dot{x} = Tf(t, T^{-1}x, ...)\) where \(T\) is an invertible linear transformation.

Methods

__call__(*args, **kwargs)

Call self as a function.

compute_trajectory(t0, tf, x0[, inputs, dt, ...])

Computes the trajectory of the system from time t0 to tf with initial condition x0.

f(t, x, *args, **kwargs)

The right hand side of the system

sys: System#
f(t: Integer | Float, x: Array, *args, **kwargs) Array#

The right hand side of the system

Parameters:
tUnion[Integer, Float]

The time of the system

xjax.Array

The state of the system

*args

Inputs (control, disturbance, etc.) as positional arguments depending on parent class.

**kwargs

Other keyword arguments depending on parent class.

Returns:
jax.Array

The time evolution of the state

class immrax.system.LiftedSystem(sys: System, H: Array, Hp: Array)#

Bases: System

Lifted System A system with dynamics \(\dot{x} = Hf(t, H^+x, ...)\) where H^+Hx = x.

Methods

__call__(*args, **kwargs)

Call self as a function.

compute_trajectory(t0, tf, x0[, inputs, dt, ...])

Computes the trajectory of the system from time t0 to tf with initial condition x0.

f(t, x, *args, **kwargs)

The right hand side of the system

sys: System#
H: Array#
Hp: Array#
f(t: Integer | Float, x: Array, *args, **kwargs) Array#

The right hand side of the system

Parameters:
tUnion[Integer, Float]

The time of the system

xjax.Array

The state of the system

*args

Inputs (control, disturbance, etc.) as positional arguments depending on parent class.

**kwargs

Other keyword arguments depending on parent class.

Returns:
jax.Array

The time evolution of the state

class immrax.system.OpenLoopSystem#

Bases: System, ABC

An open-loop nonlinear dynamical system of the form

\[\dot{x} = f(x,u,w),\]

where \(x\in\mathbb{R}^n\) is the state of the system, \(u\in\mathbb{R}^p\) is a control input to the system, and \(w\in\mathbb{R}^q\) is a disturbance input.

Methods

__call__(*args, **kwargs)

Call self as a function.

compute_trajectory(t0, tf, x0[, inputs, dt, ...])

Computes the trajectory of the system from time t0 to tf with initial condition x0.

f(t, x, u, w)

The right hand side of the open-loop system

abstractmethod f(t: Integer | Float, x: Array, u: Array, w: Array) Array#

The right hand side of the open-loop system

Parameters:
tUnion[Integer, Float]

The time of the system

xjax.Array

The state of the system

ujax.Array

The control input to the system

wjax.Array

The disturbance input to the system

Returns:
jax.Array

The time evolution of the state

class immrax.system.Trajectory(ts: Array, ys: Array, tfinite: Array)#

Bases: object

Attributes:
ts
ys

Methods

from_diffrax

tree_flatten

tree_unflatten

tfinite: Array#
static from_diffrax(sol: Solution) Trajectory#
tree_flatten()#
classmethod tree_unflatten(_, children)#
property ts#
property ys#