Types

This section describes systems types implemented in MathematicalSystems.jl.

Abstract Systems

Continuous Systems

MathematicalSystems.ConstrainedContinuousIdentitySystemType
ConstrainedContinuousIdentitySystem <: AbstractContinuousSystem

Trivial identity continuous-time system with domain constraints of the form:

\[ x(t)' = 0, \; x(t) ∈ \mathcal{X} \; \forall t.\]

Fields

  • statedim – number of state variables
  • X – state constraints
source
MathematicalSystems.ConstrainedAffineControlContinuousSystemType
ConstrainedAffineControlContinuousSystem

Continuous-time affine control system with domain constraints of the form:

\[ x(t)' = A x(t) + B u(t) + c, \; x(t) ∈ \mathcal{X}, \; u(t) ∈ \mathcal{U} \; \forall t.\]

Fields

  • A – state matrix
  • B – input matrix
  • c – affine term
  • X – state constraints
  • U – input constraints
source
MathematicalSystems.ConstrainedLinearControlContinuousSystemType
ConstrainedLinearControlContinuousSystem

Continuous-time linear control system with domain constraints of the form:

\[ x(t)' = A x(t) + B u(t), \; x(t) ∈ \mathcal{X}, \; u(t) ∈ \mathcal{U} \; \forall t.\]

Fields

  • A – state matrix
  • B – input matrix
  • X – state constraints
  • U – input constraints
source
MathematicalSystems.ConstrainedPolynomialContinuousSystemType
ConstrainedPolynomialContinuousSystem

Continuous-time polynomial system with domain constraints:

\[ x(t)' = p(x(t)), \; x(t) ∈ \mathcal{X} \; \forall t.\]

Fields

  • p – polynomial vector field
  • X – constraint set
  • statedim – number of state variables
source
MathematicalSystems.BlackBoxContinuousSystemType
BlackBoxContinuousSystem <: AbstractContinuousSystem

Continuous-time system defined by a right-hand side of the form:

\[ x(t)' = f(x(t)) \; \forall t.\]

Fields

  • f – function that holds the right-hand side
  • statedim – number of state variables
source
MathematicalSystems.ConstrainedBlackBoxContinuousSystemType
ConstrainedBlackBoxContinuousSystem <: AbstractContinuousSystem

Continuous-time system defined by a right-hand side with domain constraints of the form:

\[ x(t)' = f(x(t)), \; x(t) ∈ \mathcal{X} \; \forall t.\]

Fields

  • f – function that holds the right-hand side
  • statedim – number of state variables
  • X – state constraints
source
MathematicalSystems.BlackBoxControlContinuousSystemType
BlackBoxControlContinuousSystem <: AbstractContinuousSystem

Continuous-time control system defined by a right-hand side of the form:

\[ x(t)' = f(x(t), u(t)) \; \forall t.\]

Fields

  • f – function that holds the right-hand side
  • statedim – number of state variables
  • inputdim – number of input variables
source
MathematicalSystems.ConstrainedBlackBoxControlContinuousSystemType
ConstrainedBlackBoxControlContinuousSystem <: AbstractContinuousSystem

Continuous-time control system defined by a right-hand side with domain constraints of the form:

\[ x(t)' = f(x(t), u(t)), \; x(t) ∈ \mathcal{X}, \; u(t) ∈ \mathcal{U} \; \forall t.\]

Fields

  • f – function that holds the right-hand side
  • statedim – number of state variables
  • inputdim – number of input variables
  • X – state constraints
  • U – input constraints
source
MathematicalSystems.NoisyConstrainedLinearContinuousSystemType
NoisyConstrainedLinearContinuousSystem

Continuous-time linear system with additive disturbance and domain constraints of the form:

\[ x(t)' = A x(t) + D w(t), \; x(t) ∈ \mathcal{X}, \; w(t) ∈ \mathcal{W} \; \forall t.\]

Fields

  • A – state matrix
  • D – noise matrix
  • X – state constraints
  • W – disturbance set
source
MathematicalSystems.NoisyConstrainedLinearControlContinuousSystemType
NoisyConstrainedLinearControlContinuousSystem

Continuous-time linear control system with additive disturbance and domain constraints of the form:

\[ x(t)' = A x(t) + B u(t) + D w(t), \; x(t) ∈ \mathcal{X}, \; u(t) ∈ \mathcal{U}, \; w(t) ∈ \mathcal{W} \; \forall t.\]

Fields

  • A – state matrix
  • B – input matrix
  • D – noise matrix
  • X – state constraints
  • U – input constraints
  • W – disturbance set
source
MathematicalSystems.NoisyAffineControlContinuousSystemType
NoisyAffineControlContinuousSystem

Continuous-time affine control system with additive disturbance of the form:

\[ x(t)' = A x(t) + B u(t) + c + D w(t) \; \forall t.\]

Fields

  • A – state matrix
  • B – input matrix
  • c – affine term
  • D – noise matrix
source
MathematicalSystems.NoisyConstrainedAffineControlContinuousSystemType
NoisyConstrainedAffineControlContinuousSystem

Continuous-time affine control system with additive disturbance and domain constraints of the form:

\[ x(t)' = A x(t) + B u(t) + c + D w(t), \; x(t) ∈ \mathcal{X}, \; u(t) ∈ \mathcal{U}, \; w(t) ∈ \mathcal{W} \; \forall t.\]

Fields

  • A – state matrix
  • B – input matrix
  • c – affine term
  • D – noise matrix
  • X – state constraints
  • U – input constraints
  • W – disturbance set
source
MathematicalSystems.NoisyBlackBoxControlContinuousSystemType
NoisyBlackBoxControlContinuousSystem <: AbstractContinuousSystem

Continuous-time disturbance-affected control system defined by a right-hand side of the form:

\[ x(t)' = f(x(t), u(t), w(t)) \; \forall t.\]

Fields

  • f – function that holds the right-hand side
  • statedim – number of state variables
  • inputdim – number of input variables
  • noisedim – number of noise variables
source
MathematicalSystems.NoisyConstrainedBlackBoxControlContinuousSystemType
NoisyConstrainedBlackBoxControlContinuousSystem <: AbstractContinuousSystem

Continuous-time disturbance-affected control system defined by a right-hand side with domain constraints of the form:

\[ x(t)' = f(x(t), u(t), w(t)), \quad x(t) ∈ \mathcal{X}, \quad u(t) ∈ \mathcal{U}, \quad w(t) ∈ \mathcal{W} \quad \forall t.\]

Fields

  • f – function that holds the right-hand side
  • statedim – number of state variables
  • inputdim – number of input variables
  • noisedim – number of noise variables
  • X – state constraints
  • U – input constraints
  • W – disturbance set
source
MathematicalSystems.SecondOrderConstrainedAffineControlContinuousSystemType
SecondOrderConstrainedAffineControlContinuousSystem

Continuous-time second order constrained affine control system of the form:

\[ Mx''(t) + Cx'(t) + Kx(t) = Bu(t) + d, \; x(t) ∈ \mathcal{X}, \; u(t) ∈ \mathcal{U} \; \forall t.\]

Fields

  • M – mass matrix
  • C – viscosity matrix
  • K – stiffness matrix
  • B – input matrix
  • d – affine term
  • X – state constraints
  • U – input constraints
source
MathematicalSystems.SecondOrderConstrainedLinearControlContinuousSystemType
SecondOrderConstrainedLinearControlContinuousSystem

Continuous-time second order constrained linear control system of the form:

\[ Mx''(t) + Cx'(t) + Kx(t) = Bu(t), \; x(t) ∈ \mathcal{X}, \; u(t) ∈ \mathcal{U} \; \forall t.\]

Fields

  • M – mass matrix
  • C – viscosity matrix
  • K – stiffness matrix
  • B – input matrix
  • X – state constraints
  • U – input constraints
source
MathematicalSystems.SecondOrderContinuousSystemType
SecondOrderContinuousSystem

Continuous-time second-order system of the form:

\[ Mx''(t) + Cx'(t) + f_i(x) = f_e(t) \forall t\]

Fields

  • M – mass matrix
  • C – viscosity matrix
  • fi – internal forces
  • fe – external forces

Notes

Typically fi(x) is a state-dependent function, and fe is a given vector. In this implementation, their respective types, FI and FE, are generic.

source
MathematicalSystems.SecondOrderConstrainedContinuousSystemType
SecondOrderConstrainedContinuousSystem

Continuous-time constrained second-order system of the form:

\[ Mx''(t) + Cx'(t) + f_i(x) = f_e(t) \forall t, x ∈ X, f_e(t) ∈ U\]

Fields

  • M – mass matrix
  • C – viscosity matrix
  • fi – internal forces
  • fe – external forces
  • X – state set
  • U – input set
source

Discrete Systems

MathematicalSystems.ConstrainedDiscreteIdentitySystemType
ConstrainedDiscreteIdentitySystem <: AbstractDiscreteSystem

Trivial identity discrete-time system with domain constraints of the form:

\[ x_{k+1} = x_k, \; x_k ∈ \mathcal{X} \; \forall k.\]

Fields

  • statedim – number of state variables
  • X – state constraints
source
MathematicalSystems.ConstrainedAffineDiscreteSystemType
ConstrainedAffineDiscreteSystem

Discrete-time affine system with domain constraints of the form:

\[ x_{k+1} = A x_k + c, \; x_k ∈ \mathcal{X} \; \forall k.\]

Fields

  • A – state matrix
  • c – affine term
  • X – state constraints
source
MathematicalSystems.ConstrainedLinearControlDiscreteSystemType
ConstrainedLinearControlDiscreteSystem

Discrete-time linear control system with domain constraints of the form:

\[ x_{k+1} = A x_k + B u_k, \; x_k ∈ \mathcal{X}, \; u_k ∈ \mathcal{U} \; \forall k.\]

Fields

  • A – state matrix
  • B – input matrix
  • X – state constraints
  • U – input constraints
source
MathematicalSystems.ConstrainedAffineControlDiscreteSystemType
ConstrainedAffineControlDiscreteSystem

Continuous-time affine control system with domain constraints of the form:

\[ x_{k+1} = A x_k + B u_k + c, \; x_k ∈ \mathcal{X}, \; u_k ∈ \mathcal{U} \; \forall k.\]

Fields

  • A – state matrix
  • B – input matrix
  • c – affine term
  • X – state constraints
  • U – input constraints
source
MathematicalSystems.BlackBoxDiscreteSystemType
BlackBoxDiscreteSystem <: AbstractDiscreteSystem

Discrete-time system defined by a right-hand side of the form:

\[ x_{k+1} = f(x_k) \; \forall k.\]

Fields

  • f – function that holds the right-hand side
  • statedim – number of state variables
source
MathematicalSystems.ConstrainedBlackBoxDiscreteSystemType
ConstrainedBlackBoxDiscreteSystem <: AbstractDiscreteSystem

Discrete-time system defined by a right-hand side with domain constraints of the form:

\[ x_{k+1} = f(x_k), \; x_k ∈ \mathcal{X} \; \forall k.\]

Fields

  • f – function that holds the right-hand side
  • statedim – number of state variables
  • X – state constraints
source
MathematicalSystems.BlackBoxControlDiscreteSystemType
BlackBoxControlDiscreteSystem <: AbstractDiscreteSystem

Discrete-time control system defined by a right-hand side of the form:

\[ x_{k+1} = f(x_k, u_k) \; \forall k.\]

Fields

  • f – function that holds the right-hand side
  • statedim – number of state variables
  • inputdim – number of input variables
source
MathematicalSystems.ConstrainedBlackBoxControlDiscreteSystemType
ConstrainedBlackBoxControlDiscreteSystem <: AbstractDiscreteSystem

Discrete-time control system defined by a right-hand side with domain constraints of the form:

\[ x_{k+1} = f(x_k, u_k), \; x_k ∈ \mathcal{X}, \; u_k ∈ \mathcal{U} \; \forall k.\]

Fields

  • f – function that holds the right-hand side
  • statedim – number of state variables
  • inputdim – number of input variables
  • X – state constraints
  • U – input constraints
source
MathematicalSystems.NoisyConstrainedLinearDiscreteSystemType
NoisyConstrainedLinearDiscreteSystem

Discrete-time linear system with additive disturbance and domain constraints of the form:

\[ x_{k+1} = A x_k + D w_k, \; x_k ∈ \mathcal{X}, \; w(t) ∈ \mathcal{W} \; \forall k.\]

Fields

  • A – state matrix
  • D – noise matrix
  • X – state constraints
  • W – disturbance set
source
MathematicalSystems.NoisyConstrainedLinearControlDiscreteSystemType
NoisyConstrainedLinearControlDiscreteSystem

Continuous-time linear control system with additive disturbance and domain constraints of the form:

\[ x_{k+1} = A x_k + B u_k + D w_k, \; x_k ∈ \mathcal{X}, \; u_k ∈ \mathcal{U}, \; w_k ∈ \mathcal{W} \; \forall k.\]

Fields

  • A – state matrix
  • B – input matrix
  • D – noise matrix
  • X – state constraints
  • U – input constraints
  • W – disturbance set
source
MathematicalSystems.NoisyAffineControlDiscreteSystemType
NoisyAffineControlDiscreteSystem

Continuous-time affine control system with additive disturbance of the form:

\[ x_{k+1} = A x_k + B u_k + c + D w_k \; \forall k.\]

Fields

  • A – state matrix
  • B – input matrix
  • c – affine term
  • D – noise matrix
source
MathematicalSystems.NoisyConstrainedAffineControlDiscreteSystemType
NoisyConstrainedAffineControlDiscreteSystem

Continuous-time affine control system with additive disturbance and domain constraints of the form:

\[ x_{k+1} = A x_k + B u_k + c + D w_k, \; x_k ∈ \mathcal{X}, \; u_k ∈ \mathcal{U}, \; w_k ∈ \mathcal{W} \; \forall k.\]

Fields

  • A – state matrix
  • B – input matrix
  • c – affine term
  • D – noise matrix
  • X – state constraints
  • U – input constraints
  • W – disturbance set
source
MathematicalSystems.NoisyBlackBoxControlDiscreteSystemType
NoisyBlackBoxControlDiscreteSystem <: AbstractDiscreteSystem

Discrete-time disturbance-affected control system defined by a right-hand side of the form:

\[ x_{k+1} = f(x_k, u_k) \quad \forall k.\]

Fields

  • f – function that holds the right-hand side
  • statedim – number of state variables
  • inputdim – number of input variables
  • noisedim – number of noise variables
source
MathematicalSystems.NoisyConstrainedBlackBoxControlDiscreteSystemType
NoisyConstrainedBlackBoxControlDiscreteSystem <: AbstractDiscreteSystem

Discrete-time disturbance-affected control system defined by a right-hand side with domain constraints of the form:

\[ x_{k+1} = f(x_k, u_k), \quad x_k ∈ \mathcal{X}, \quad u_k ∈ \mathcal{U}, \quad w_k ∈ \mathcal{W} \quad \forall k.\]

Fields

  • f – function that holds the right-hand side
  • statedim – number of state variables
  • inputdim – number of input variables
  • noisedim – number of noise variables
  • X – state constraints
  • U – input constraints
  • W – disturbance set
source
MathematicalSystems.SecondOrderConstrainedAffineControlDiscreteSystemType
SecondOrderConstrainedAffineControlDiscreteSystem

Discrete-time second order constrained affine control system of the form:

\[ Mx_{k+2} + Cx_{k+1} + Kx_k = Bu_k + d, \; x_k ∈ \mathcal{X}, \; u_k ∈ \mathcal{U} \; \forall k.\]

Fields

  • M – mass matrix
  • C – viscosity matrix
  • K – stiffness matrix
  • B – input matrix
  • d – affine term
  • X – state constraints
  • U – input constraints
source
MathematicalSystems.SecondOrderConstrainedLinearControlDiscreteSystemType
SecondOrderConstrainedLinearControlDiscreteSystem

Discrete-time second order constrained linear control system of the form:

\[ Mx_{k+2} + Cx_{k+1} + Kx_k = Bu_k, \; x_k ∈ \mathcal{X}, \; u_k ∈ \mathcal{U} \; \forall k.\]

Fields

  • M – mass matrix
  • C – viscosity matrix
  • K – stiffness matrix
  • B – input matrix
  • X – state constraints
  • U – input constraints
source
MathematicalSystems.SecondOrderDiscreteSystemType
SecondOrderDiscreteSystem

Discrete-time second-order system of the form:

\[ Mx_{k+2} + Cx_{k} + f_i(x_k) = f_e(t_k) \forall k.\]

Fields

  • M – mass matrix
  • C – viscosity matrix
  • fi – internal forces
  • fe – external forces

Notes

Typically fi(x_k) is a state-dependent function, and fe is a given vector. In this implementation, their respective types, FI and FE, are generic.

source
MathematicalSystems.SecondOrderConstrainedDiscreteSystemType
SecondOrderConstrainedDiscreteSystem

Discrete-time constrained second-order system of the form:

\[ Mx_{k+2} + Cx_{k} + f_i(x_k) = f_e(t_k) \forall k, x_k ∈ X, f_e(t_k) ∈ U\]

Fields

  • M – mass matrix
  • C – viscosity matrix
  • fi – internal forces
  • fe – external forces
  • X – state set
  • U – input set
source

Discretization Algorithms

MathematicalSystems.AbstractDiscretizationAlgorithmType
AbstractDiscretizationAlgorithm

Abstract supertype for all discretization algorithms.

Note

For implementing a custom discretization algorithm, a type definition struct NewDiscretizationAlgorithm <: AbstractDiscretizationAlgorithm end and a _discretize method

_discretize(::NewDiscretizationAlgorithm, ΔT::Real,
             A::AbstractMatrix, B::AbstractMatrix, c::AbstractVector, D::AbstractMatrix)

are required.

source
MathematicalSystems.ExactDiscretizationType
ExactDiscretization <: AbstractDiscretizationAlgorithm

Exact discretization algorithm for affine systems.

Algorithm

This algorithm consists of integrating the continuous differential equation over a specified time interval to obtain an associated difference equation. The algorithm applies to any system of the form x' = Ax + Bu + c + Dw where the state matrix A is invertible, and other system types, e.g. linear systems x' = Ax which are included in the above formulation.

Without loss of generality, consider a NoisyAffineControlledContinuousSystem with system dynamics $x' = Ax + Bu + c + Dw$.

The exact discretization is calculated by integrating on both sides of the continuous ODE over the time span [t, t + ΔT], for a fixed input u and fixed noise realization w at time t. The resulting discretization writes as $x^+ = A^d x + B^d u + c^d + D^d w$ where $A^d = \exp^{A ~ ΔT}$, $B^d = A^{-1}(A^d - I)B$, $c^d = A^{-1}(A^d - I)c$ and $D^d = A^{-1}(A^d - I)D$.

The algorithm described above is a well known result from the literature [1].

[1] Wikipedia

source
MathematicalSystems.EulerDiscretizationType
EulerDiscretization <: AbstractDiscretizationAlgorithm

Euler discretization algorithm for affine systems.

Algorithm

This algorithm consists of a first-order approximation to obtain an associated difference equation. The algorithm applies to any system of the form x' = Ax + Bu + c + Dw, and other system types, e.g. linear systems x' = Ax which are included in the above formulation.

Without loss of generality, consider a NoisyAffineControlledContinuousSystem with system dynamics $x' = Ax + Bu + c + Dw$.

The Euler discretization is calculated by taking the first-order approximation of the exact discretization ExactDiscretization. The resulting discretization writes as $x^+ = A^d x + B^d u + c^d + D^d w$ where $A^d = I + ΔT ~ A$, $B^d = ΔT ~ B$, $c^d = ΔT ~ c$ and $D^d = ΔT ~ D$.

The algorithm described above is a well-known result from the literature [1].

[1] Wikipedia

source

Initial Value Problems

MathematicalSystems.InitialValueProblemType
InitialValueProblem{S <: AbstractSystem, XT} <: AbstractSystem

Parametric composite type for initial value problems. It is parameterized in the system's type and the initial state's type

Fields

  • s – system
  • x0 – initial state

Examples

The linear system $x' = -x$ with initial condition $x₀ = [-1/2, 1/2]$:

julia> s = LinearContinuousSystem([-1.0 0.0; 0.0 -1.0]);

julia> x₀ = [-1/2, 1/2];

julia> p = InitialValueProblem(s, x₀);

julia> initial_state(p) # same as p.x0
2-element Vector{Float64}:
 -0.5
  0.5

julia> statedim(p)
2

julia> inputdim(p)
0
source
MathematicalSystems.initial_stateFunction
initial_state(ivp::InitialValueProblem)

Return the initial state of an initial-value problem.

Input

  • ivp – initial-value problem

Output

The initial state of an initial-value problem.

source
MathematicalSystems.systemFunction
system(ivp::InitialValueProblem)

Return the system wrapped by an initial-value problem.

Input

  • ivp – initial-value problem

Output

The system of the given initial-value problem.

source

Identity Operator

MathematicalSystems.IdentityMultipleType
IdentityMultiple{T} < AbstractMatrix{T} where T

A scalar multiple of the identity matrix of given order and numeric type.

Fields

  • M – uniform scaling operator of type T
  • n – size of the identity matrix

Notes

This type can be used to create multiples of the identity of given size. Since only the multiple and the order are stored, the allocations are minimal.

Internally, the type wraps Julia's lazy multiple of the identity operator, UniformScaling. IdentityMultiple subtypes AbstractMatrix, hence it can be used in usual matrix arithmetic and for dispatch on AbstractMatrix.

The difference between UniformScaling and IdentityMultiple is that while the size of the former is generic, the size of the latter is fixed.

Examples

Only specifying the matrix size represents an identity matrix:

julia> using MathematicalSystems: IdentityMultiple

julia> I2 = Id(2)
IdentityMultiple{Float64} of value 1.0 and order 2

julia> I2 + I2
IdentityMultiple{Float64} of value 2.0 and order 2

julia> 4*I2
IdentityMultiple{Float64} of value 4.0 and order 2

The scaling (default 1.0) can be passed as the second argument:

julia> I2r = Id(2, 1//1)
IdentityMultiple{Rational{Int64}} of value 1//1 and order 2

julia> I2r + I2r
IdentityMultiple{Rational{Int64}} of value 2//1 and order 2

julia> 4*I2r
IdentityMultiple{Rational{Int64}} of value 4//1 and order 2

Alternatively, use the constructor passing the UniformScaling (I):

julia> using LinearAlgebra

julia> I2 = IdentityMultiple(2.0*I, 2)
IdentityMultiple{Float64} of value 2.0 and order 2

julia> I2r = IdentityMultiple(2//1*I, 2)
IdentityMultiple{Rational{Int64}} of value 2//1 and order 2
source
MathematicalSystems.IdFunction
Id(n::Int, [λ]::Number=1.0)

Convenience constructor of an IdentityMultiple.

Input

  • n – dimension
  • λ – (optional; default: 1.0) scaling factor

Output

An IdentityMultiple of the given size and scaling factor.

source

Input Types

MathematicalSystems.AbstractInputType
AbstractInput

Abstract supertype for all input types.

Notes

The input types defined here implement an iterator interface, such that other methods can build upon the behavior of inputs which are either constant or varying.

Iteration is supported with an index number called iterator state. The iteration function Base.iterate takes and returns a tuple (input, state), where input represents the value of the input, and state is an index which counts the number of times this iterator was called.

A convenience function nextinput(input, n) is also provided and it returns the first n elements of input.

source
MathematicalSystems.ConstantInputType
ConstantInput{UT} <: AbstractInput

Type representing an input that remains constant in time.

Fields

  • U – input set

Examples

The constant input holds a single element and its length is infinite. To access the field U, you can use Base's iterate given a state, or the method nextinput given the number of desired input elements:

julia> c = ConstantInput(-1//2)
ConstantInput{Rational{Int64}}(-1//2)

julia> iterate(c, 1)
(-1//2, nothing)

julia> iterate(c, 2)
(-1//2, nothing)

julia> collect(nextinput(c, 4))
4-element Vector{Rational{Int64}}:
 -1//2
 -1//2
 -1//2
 -1//2

The elements of this input are rational numbers:

julia> eltype(c)
Rational{Int64}

To transform a constant input, you can use map as in:

julia> map(x->2*x, c)
ConstantInput{Rational{Int64}}(-1//1)
source
MathematicalSystems.VaryingInputType
VaryingInput{UT, VUT<:AbstractVector{UT}} <: AbstractInput

Type representing an input that may vary with time.

Fields

  • U – vector of input sets

Examples

The varying input holds a vector and its length equals the number of elements in the vector. Consider an input given by a vector of rational numbers:

julia> v = VaryingInput([-1//2, 1//2])
VaryingInput{Rational{Int64}, Vector{Rational{Int64}}}(Rational{Int64}[-1//2, 1//2])

julia> length(v)
2

julia> eltype(v)
Rational{Int64}

Base's iterate method receives the input and an integer state and returns the input element and the next iteration state:

julia> iterate(v, 1)
(-1//2, 2)

julia> iterate(v, 2)
(1//2, 3)

The method nextinput receives a varying input and an integer n and returns an iterator over the first n elements of this input (where n=1 by default):

julia> typeof(nextinput(v))
Base.Iterators.Take{VaryingInput{Rational{Int64}, Vector{Rational{Int64}}}}

julia> collect(nextinput(v, 1))
1-element Vector{Rational{Int64}}:
 -1//2

julia> collect(nextinput(v, 2))
2-element Vector{Rational{Int64}}:
 -1//2
  1//2

You can collect the inputs in an array, or equivalently use list comprehension, (or use a for loop):

julia> collect(v)
2-element Vector{Rational{Int64}}:
 -1//2
  1//2

julia> [3*vi for vi in v]
2-element Vector{Rational{Int64}}:
 -3//2
  3//2

Since this input type is finite, querying more elements than its length returns the full vector:

julia> collect(nextinput(v, 4))
2-element Vector{Rational{Int64}}:
 -1//2
  1//2

To transform a varying input, you can use map as in:

julia> map(x->3*x, v)
VaryingInput{Rational{Int64}, Vector{Rational{Int64}}}(Rational{Int64}[-3//2, 3//2])
source

Maps

MathematicalSystems.ConstrainedLinearControlMapType
ConstrainedLinearControlMap

A linear control map with state and input constraints

\[ (x, u) ↦ Ax + Bu, x ∈ \mathcal{X}, u ∈ \mathcal{U}.\]

Fields

  • A – matrix
  • B – matrix
  • X – state constraints
  • U – input constraints
source
MathematicalSystems.ConstrainedAffineControlMapType
ConstrainedAffineControlMap

An affine control map with state and input constraints

\[ (x, u) ↦ Ax + Bu + c, x ∈ \mathcal{X}, u ∈ \mathcal{U}.\]

Fields

  • A – matrix
  • B – matrix
  • c – vector
  • X – state constraints
  • U – input constraints
source
MathematicalSystems.ResetMapType
ResetMap

A reset map

\[ x ↦ R(x),\]

such that a subset of the variables is given a specified value, and the rest are unchanged.

Fields

  • dim – dimension
  • dict – dictionary whose keys are the indices of the variables that are reset, and whose values are the new values
source
MathematicalSystems.ConstrainedResetMapType
ConstrainedResetMap

A reset map with state constraints of the form

\[ x ↦ R(x), x ∈ \mathcal{X},\]

such that the specified variables are assigned a given value, and the remaining variables are unchanged.

Fields

  • dim – dimension
  • X – state constraints
  • dict – dictionary whose keys are the indices of the variables that are reset, and whose values are the new values
source
MathematicalSystems.ConstrainedBlackBoxMapType
ConstrainedBlackBoxMap

A constrained black-box map of the form

\[ x ↦ h(x), x ∈ \mathcal{X}.\]

Fields

  • dim – state dimension
  • output_dim – output dimension
  • h – output function
  • X – state constraints
source
MathematicalSystems.BlackBoxControlMapType
BlackBoxControlMap

A black-box control map of the form

\[ (x, u) ↦ h(x, u).\]

Fields

  • dim – state dimension
  • input_dim – input dimension
  • output_dim – output dimension
  • h – output function
source
MathematicalSystems.ConstrainedBlackBoxControlMapType
ConstrainedBlackBoxControlMap

A constrained black-box control map of the form

\[ (x, u) ↦ h(x, u), x ∈ \mathcal{X}, u ∈ \mathcal{U}.\]

Fields

  • dim – state dimension
  • input_dim – input dimension
  • output_dim – output dimension
  • h – output function
  • X – state constraints
  • U – input constraints
source

Systems with Output

MathematicalSystems.SystemWithOutputType
SystemWithOutput{ST<:AbstractSystem, MT<:AbstractMap} <: AbstractSystem

Parametric composite type for systems with outputs. It is parameterized in the system's type (ST) and in the map's type (MT).

Fields

  • s – system of type ST
  • outputmap – output map of type MT
source
MathematicalSystems.LinearTimeInvariantSystemFunction
LinearTimeInvariantSystem(A, B, C, D)

A linear time-invariant system with of the form

\[x' = Ax + Bu,\\ y = Cx + Du.\]

Input

  • A – matrix
  • B – matrix
  • C – matrix
  • D – matrix

Output

A system with output such that the system is a linear control continuous system and the output map is a linear control map.

source
LinearTimeInvariantSystem(A, B, C, D, X, U)

A linear time-invariant system with state and input constraints of the form

\[x' = Ax + Bu,\\ y = Cx + Du,\]

where $x(t) ∈ X$ and $u(t) ∈ U$ for all $t$.

Input

  • A – matrix
  • B – matrix
  • C – matrix
  • D – matrix
  • X – state constraints
  • U – input constraints

Output

A system with output such that the system is a constrained linear control continuous system and the output map is a constrained linear control map.

source

Vector Fields

MathematicalSystems.VectorFieldType
VectorField{T<:Function}

Type that computes the vector field of an AbstractContinuousSystem.

Fields

  • field – function for calculating the vector field
source

Macros

MathematicalSystems.@systemMacro
system(expr...)

Return an instance of the system type corresponding to the given expressions.

Input

  • expr – expressions separated by commas which define the dynamic equation, the constraint sets or the dimensionality of the system

Output

A system that best matches the given expressions.

Notes

Terms. The expression expr contains one or more of the following sub-expressions:

  • dynamic equation, either continuous, e.g.x' = Ax, or discrete, e.g. x⁺ = Ax
  • set constraints, e.g. x ∈ X
  • input constraints, e.g. u ∈ U
  • dimensionality, e.g. dim: (2,1) or dim = 1
  • specification of the input variable, e.g. input: u or input = u
  • specification of the noise variable, e,g, noise: w or noise = w

The macro call is then formed by separating the previous sub-expressions (which we simply call terms hereafter), as in:

@system(dynamic eq., set constr., input constr., input specif., noise spec., dimens.)

The different terms that compose the system's definition do not have to appear in any particular order. Moreover, the only mandatory term is the dynamic equation; the other terms are optional and default values may apply depending on the system type; this is explained next.

Dynamic equation. The time derivative in a continuous system is specified by using ', as in x' = A*x. A discrete system is specified using (which can be written with the combination of keys \^+[TAB]), as in x⁺ = A*x. Moreover, the asterisk denoting matrix-vector products is optional. For instance, both x' = Ax and x' = A*x are parsed as the linear continuous system whose state matrix is A. The matrix is supposed to be defined at the call site.

Default values. When the dynamic equation is parsed, the variable on the left-hand side is interpreted as the state variable. The input variable is by default u and the noise variable is by default w. If we want to change the default name of the input variable, this can be done by adding the term input: var (or equivalently, input=var) where var corresponds to the new name of the input variable, eg. @system(x' = A*x + B*v, input:v). Similarly, a noise variable is specified with noise: var or noise=var.

Exceptions. The following exceptions and particular cases apply:

  • If the right-hand side has the form A*x + B*foo, A*x + B*foo + c or f(x, foo), the equation is parsed as a controlled linear (affine) or controlled black-box system with input foo. Note that in this case, input variable does not correspond to the default value of u, but foo is parsed as being the input.

  • If the left-hand side contains a multiplicative term in the form E*x⁺ or E*x', the equation is parsed as an algebraic equation and hence gives rise to a descriptor system. In this case, the asterisk * operator is mandatory.

  • Systems of the form x' = α*x where α is a scalar are parsed as linear systems. The default dimension is 1 and α is parsed as Float64; if the system is higher-dimensional, use dim, as in x' = 2x, dim=3.

Examples

Let us first create a continuous linear system using this macro:

julia> A = [1. 0; 0 1.];

julia> @system(x' = A*x)
LinearContinuousSystem{Float64, Matrix{Float64}}([1.0 0.0; 0.0 1.0])

A discrete system is defined by using :

julia> @system(x⁺ = A*x)
LinearDiscreteSystem{Float64, Matrix{Float64}}([1.0 0.0; 0.0 1.0])

Additionally, a set definition x ∈ X can be added to create a constrained system. For example, a discrete controlled affine system with constrained states and inputs writes as:

julia> using LazySets

julia> B = Matrix([1.0 0.5]');

julia> c = [1.0, 1.5];

julia> X = BallInf(zeros(2), 10.0);

julia> U = BallInf(zeros(1), 2.0);

julia> @system(x' = A*x + B*u + c, x ∈ X, u ∈ U)
ConstrainedAffineControlContinuousSystem{Float64, Matrix{Float64}, Matrix{Float64}, Vector{Float64}, BallInf{Float64, Vector{Float64}}, BallInf{Float64, Vector{Float64}}}([1.0 0.0; 0.0 1.0], [1.0; 0.5;;], [1.0, 1.5], BallInf{Float64, Vector{Float64}}([0.0, 0.0], 10.0), BallInf{Float64, Vector{Float64}}([0.0], 2.0))

For the creation of a black-box system, the state, input and noise dimensions have to be defined separately. For a constrained controlled black-box system, the macro writes as

julia> f(x, u) = x + u;

julia> @system(x⁺ = f(x, u), x ∈ X, u ∈ U, dim: (2,2))
ConstrainedBlackBoxControlDiscreteSystem{typeof(f), BallInf{Float64, Vector{Float64}}, BallInf{Float64, Vector{Float64}}}(f, 2, 2, BallInf{Float64, Vector{Float64}}([0.0, 0.0], 10.0), BallInf{Float64, Vector{Float64}}([0.0], 2.0))
source
MathematicalSystems.@ivpMacro
ivp(expr...)

Return an instance of the initial-value problem type corresponding to the given expressions.

Input

  • expr – expressions separated by commas which define the dynamic equation, the constraint sets or the dimensionality of the system, and the set of initial states (required)

Output

An initial-value problem that best matches the given expressions.

Notes

This macro behaves like the @system macro, the sole difference being that in @ivp the constraint on the set of initial states is mandatory. For the technical details we refer to the documentation of @system.

The macro can also be called with a system argument of type AbstractSystem in the form @ivp(system, state(0) ∈ initial_set).

Examples

julia> p = @ivp(x' = -x, x(0) ∈ [1.0]);

julia> typeof(p)
InitialValueProblem{LinearContinuousSystem{Float64, IdentityMultiple{Float64}}, Vector{Float64}}

julia> initial_state(p)
1-element Vector{Float64}:
 1.0

julia> sys = @system(x' = [1 0; 0 1] * x);

julia> @ivp(sys, x(0) ∈ [-1, 1])
InitialValueProblem{LinearContinuousSystem{Int64, Matrix{Int64}}, Vector{Int64}}(LinearContinuousSystem{Int64, Matrix{Int64}}([1 0; 0 1]), [-1, 1])
source
MathematicalSystems.@mapMacro
map(ex, args)

Return an instance of the map type corresponding to the given expression.

Input

  • ex – an expression defining the map, in the form of an anonymous function
  • args – additional optional arguments

Output

A map that best matches the given expression.

Examples

Let us first create a linear map using this macro:

julia> @map x -> [1 0; 0 0]*x
LinearMap{Int64, Matrix{Int64}}([1 0; 0 0])

We can create an affine system as well:

julia> @map x -> [1 0; 0 0]*x + [2, 0]
AffineMap{Int64, Matrix{Int64}, Vector{Int64}}([1 0; 0 0], [2, 0])

Additional arguments can be passed to @map using the function-call form, i.e. separating the arguments by commas, and using parentheses around the macro call. For example, an identity map of dimension 5 can be defined as:

julia> @map(x -> x, dim=5)
IdentityMap(5)

A state constraint on such map can be specified passing the additional argument x ∈ X.

An identity map can alternatively be created by giving a the size of the identity matrix as Id(n), for example:

julia> @map x -> Id(5)*x
IdentityMap(5)
source