Methods

This section describes systems methods implemented in MathematicalSystems.jl.

States

Inputs

MathematicalSystems.nextinputFunction
nextinput(input::ConstantInput, n::Int=1)

Returns the first n elements of this input.

Input

  • input – a constant input
  • n – (optional, default: 1) the number of desired elements

Output

A repeated iterator that generates n equal samples of this input.

source
nextinput(input::VaryingInput, n::Int=1)

Returns the first n elements of this input.

Input

  • input – varying input
  • n – (optional, default: 1) number of desired elements

Output

An iterator of type Base.Iterators.Take that represents at most the first n elements of this input.

source

Noises

Output

Traits

MathematicalSystems.islinearMethod
islinear(s::AbstractSystem)

Specifies if the dynamics of system s is specified by linear equations.

Notes

We adopt the notion from [Section 2.7, 1]. For example, the system with inputs $x' = f(t, x, u) = A x + B u$ is linear, since the function $f(t, ⋅, ⋅)$ is linear in $(x, u)$ for each $t ∈ \mathbb{R}$. On the other hand, $x' = f(t, x, u) = A x + B u + c$ is affine but not linear, since it is not linear in $(x, u)$.

The result of this function only depends on the system type, not the value, and can also be applied to typeof(s). So, if a system type allows an instance that is not linear, it returns false by default. For example, polynomial systems can be nonlinear; hence islinear returns false.

[1] Sontag, Eduardo D. Mathematical control theory: deterministic finite dimensional systems. Vol. 6. Springer Science & Business Media, 2013.

source
MathematicalSystems.islinearMethod
islinear(m::AbstractMap)

Specifies if the map m is linear or not.

Notes

A map is linear if it preserves the operations of scalar multiplication and vector addition.

source
MathematicalSystems.isaffineMethod
isaffine(s::AbstractSystem)

Specifies if the dynamics of system s is specified by affine equations.

Notes

An affine system is the composition of a linear system and a translation. See islinear(::AbstractSystem) for the notion of linear system adopted in this library.

The result of this function only depends on the system type, not the value, and can also be applied to typeof(s). So, if a system type allows an instance that is not affine, it returns false by default. For example, polynomial systems can be nonlinear; hence isaffine is false.

source
MathematicalSystems.ispolynomialMethod
ispolynomial(s::AbstractSystem)

Specifies if the dynamics of system s is specified by polynomial equations.

The result of this function only depends on the system type, not the value, and can also be applied to typeof(s). Hence, e.g. a LinearContinuousSystem is not considered to be of polynomial type.

source
MathematicalSystems.isblackboxMethod
isblackbox(s::AbstractSystem)

Specifies if no specific structure is assumed for the dynamics of system s.

The result of this function only depends on the system type, not the value, and can also be applied to typeof(s).

source
MathematicalSystems.isnoisyMethod
isnoisy(s::AbstractSystem)

Determines if the dynamics of system s contains a noise term w.

The result of this function only depends on the system type, not the value, and can also be applied to typeof(s).

source
MathematicalSystems.iscontrolledMethod
iscontrolled(s::AbstractSystem)

Determines if the dynamics of system s contains a control input u.

The result of this function only depends on the system type, not the value, and can also be applied to typeof(s).

source
MathematicalSystems.isconstrainedMethod
isconstrained(s::AbstractSystem)

Determines if the system s has constraints on the state, input and noise, respectively (those that are available).

The result of this function only depends on the system type, not the value, and can also be applied to typeof(s).

source
MathematicalSystems.state_matrixMethod
state_matrix(s::AbstractSystem)

Return the state matrix of an affine system.

Notes

The state matrix is the matrix proportional to the state, e.g. the matrix A in the linear continuous system $x' = Ax$.

source
MathematicalSystems.input_matrixMethod
input_matrix(s::AbstractSystem)

Return the input matrix of a system with linear input.

Notes

The input matrix is the matrix proportional to the input, e.g. the matrix B in the linear continuous system with input, $x' = Ax + Bu$.

source
MathematicalSystems.noise_matrixMethod
noise_matrix(s::AbstractSystem)

Return the noise matrix of a system with linear noise.

Notes

The noise matrix is the matrix proportional to the noise, e.g. the matrix D in the linear system with noise, $x' = Ax + Dw$.

source
MathematicalSystems.affine_termMethod
affine_term(s::AbstractSystem)

Return the affine term in an affine system.

Notes

The affine term is e.g. the vector $c$ in the affine system $x' = Ax + c$.

source

Maps

Successor

MathematicalSystems.successorFunction
successor(system::DiscreteIdentitySystem, x::AbstractVector)

Return the successor state of a DiscreteIdentitySystem.

Input

  • systemDiscreteIdentitySystem
  • x – state (it should be any vector type)

Output

The same state x.

source
successor(system::ConstrainedDiscreteIdentitySystem, x::AbstractVector;
          [check_constraints]=true)

Return the successor state of a ConstrainedDiscreteIdentitySystem.

Input

  • systemConstrainedDiscreteIdentitySystem
  • x – state (it should be any vector type)
  • check_constraints – (optional, default: true) check if the state belongs to the state set

Output

The same state x.

source
successor(system::AbstractDiscreteSystem, x::AbstractVector;
          [check_constraints]=true)

Return the successor state of an AbstractDiscreteSystem.

Input

  • systemAbstractDiscreteSystem
  • x – state (it should be any vector type)
  • check_constraints – (optional, default: true) check if the state belongs to the state set

Output

The result of applying the system to state x.

source
successor(system::AbstractDiscreteSystem, x::AbstractVector, u::AbstractVector;
          [check_constraints]=true)

Return the successor state of an AbstractDiscreteSystem.

Input

  • systemAbstractDiscreteSystem
  • x – state (it should be any vector type)
  • u – input (it should be any vector type) or noise, if system is not controlled
  • check_constraints – (optional, default: true) check if the state belongs to the state set

Output

The result of applying the system to state x and input u.

Notes

If the system is not controlled but noisy, the input u is interpreted as noise.

source
successor(system::AbstractDiscreteSystem,
          x::AbstractVector, u::AbstractVector, w::AbstractVector; [check_constraints]=true)

Return the successor state of an AbstractDiscreteSystem.

Input

  • systemAbstractDiscreteSystem
  • x – state (it should be any vector type)
  • u – input (it should be any vector type)
  • w – noise (it should be any vector type)
  • check_constraints – (optional, default: true) check if the state belongs to the state set

Output

The result of applying the system to state x, input u and noise w.

source

Vector Field

MathematicalSystems.vector_fieldFunction
vector_field(system::ContinuousIdentitySystem, x::AbstractVector)

Return the vector field state of a ContinuousIdentitySystem.

Input

  • systemContinuousIdentitySystem
  • x – state (it should be any vector type)

Output

A zeros vector of dimension statedim.

source
vector_field(system::ConstrainedContinuousIdentitySystem, x::AbstractVector;
          [check_constraints]=true)

Return the vector field state of a ConstrainedContinuousIdentitySystem.

Input

  • systemConstrainedContinuousIdentitySystem
  • x – state (it should be any vector type)
  • check_constraints – (optional, default: true) check if the state belongs to the state set

Output

A zeros vector of dimension statedim.

source
vector_field(system::AbstractContinuousSystem, x::AbstractVector;
          [check_constraints]=true)

Return the vector field state of an AbstractContinuousSystem.

Input

  • systemAbstractContinuousSystem
  • x – state (it should be any vector type)
  • check_constraints – (optional, default: true) check if the state belongs to the state set

Output

The vector field of the system at state x.

source
vector_field(system::AbstractContinuousSystem, x::AbstractVector, u::AbstractVector;
          [check_constraints]=true)

Return the vector field state of an AbstractContinuousSystem.

Input

  • systemAbstractContinuousSystem
  • x – state (it should be any vector type)
  • u – input (it should be any vector type) or noise, if system is not controlled
  • check_constraints – (optional, default: true) check if the state belongs to the state set

Output

The vector field of the system at state x and applying input u.

Notes

If the system is not controlled but noisy, the input u is interpreted as noise.

source
vector_field(system::AbstractContinuousSystem,
          x::AbstractVector, u::AbstractVector, w::AbstractVector; [check_constraints]=true)

Return the vector field state of an AbstractContinuousSystem.

Input

  • systemAbstractContinuousSystem
  • x – state (it should be any vector type)
  • u – input (it should be any vector type)
  • w – noise (it should be any vector type)
  • check_constraints – (optional, default: true) check if the state belongs to the state set

Output

The vector field of the system at state x and applying input u and noise w.

source

Discretization

MathematicalSystems.discretizeFunction
discretize(system::AbstractContinuousSystem, ΔT::Real,
           algorithm::AbstractDiscretizationAlgorithm=ExactDiscretization(),
           constructor=_default_complementary_constructor(system))

Discretization of a isaffine AbstractContinuousSystem to a AbstractDiscreteSystem with sampling time ΔT using the discretization method algorithm.

Input

  • system – an affine continuous system
  • ΔT – sampling time
  • algorithm – (optional, default: ExactDiscretization()) discretization algorithm
  • constructor – (optional, default: _default_complementary_constructor(system)) construction method

Output

Returns a discretization of the input system system with discretization method algorithm and sampling time ΔT.

source

Internal Methods

MathematicalSystems._discretizeFunction
_discretize(::AbstractDiscretizationAlgorithm, ΔT::Real
            A::AbstractMatrix, B::AbstractMatrix, c::AbstractVector, D::AbstractMatrix)

Implementation of the discretization algorithm defined by the first input argument with sampling time ΔT.

Input

  • `` – discretization algorithm, used for dispatch
  • ΔT – sampling time
  • A – state matrix
  • B – input matrix
  • c – vector
  • D – noise matrix

Output

Returns a vector containing the discretized input arguments A, B, c and D.

Notes

See discretize for more details.

source
_discretize(A::AbstractMatrix, ΔT::Real; algorithm=:exact)

Discretize the state matrix A with sampling time ΔT and discretization method algorithm.

Input

  • A – state matrix
  • ΔT – sampling time
  • algorithm – (optional, default: :exact) discretization algorithm

Output

Returns a vector containing the discretized input argument A.

Notes

See discretize for more details.

source
_discretize(algorithm::AbstractDiscretizationAlgorithm, ΔT::Real,
            A::AbstractMatrix, B::AbstractMatrix)

Discretize the state matrix A and input or noise matrix B with sampling time ΔT and discretization method algorithm.

Input

  • algorithm – discretization algorithm
  • ΔT – sampling time
  • A – state matrix
  • B – input or noise matrix

Output

Returns a vector containing the discretized input arguments A and B.

Notes

This method signature with two arguments of type AbstractMatrix works both for a noisy system with fields (:A,:D) and a controlled system with fields (:A,:B).

See discretize for more details.

source
_discretize(algorithm::AbstractDiscretizationAlgorithm, ΔT::Real,
            A::AbstractMatrix,c::AbstractVector)

Discretize the state matrix A and vector c with sampling time ΔT and discretization method algorithm.

Input

  • algorithm – discretization algorithm
  • ΔT – sampling time
  • A – state matrix
  • c – vector

Output

Returns a vector containing the discretized input arguments A and c.

Notes

See discretize for more details.

source
_discretize(algorithm::AbstractDiscretizationAlgorithm, ΔT::Real,
            A::AbstractMatrix, B::AbstractMatrix, c::AbstractVector)

Discretize the state matrix A, input matrix B and vector c with sampling time ΔT and discretization method algorithm.

Input

  • algorithm – discretization algorithm
  • ΔT – sampling time
  • A – state matrix
  • B – input matrix
  • c – vector

Output

Returns a vector containing the discretized input arguments A, B and c.

Notes

See discretize for more details.

source
_discretize(algorithm::AbstractDiscretizationAlgorithm, ΔT::Real,
            A::AbstractMatrix, B::AbstractMatrix, D::AbstractMatrix)

Discretize the state matrix A, input matrix B and noise matrix C with sampling time ΔT and discretization method algorithm.

Input

  • algorithm – discretization algorithm
  • ΔT – sampling time
  • A – state matrix
  • B – input matrix
  • D – noise matrix

Output

Returns a vector containing the discretized input arguments A, B and D.

Notes

See discretize for more details.

source
MathematicalSystems.typenameMethod
typename(system::AbstractSystem)

Returns the base type of system without parameter information.

Input

  • systemAbstractSystem

Output

The base type of system.

source
MathematicalSystems._complementary_typeMethod
_complementary_type(system_type::Type{<:AbstractSystem})

Return the complementary type of a system type system_type.

Input

  • system_type – type of AbstractSystem

Output

The complementary type of system_type.

Notes

There are two main subclasses of abstract types: continuous types and discrete types. A complementary type of system_type has the same fields as system_type but belongs to the other subclass, e.g. for a LinearContinuousSystem which is a subtype of AbstractContinuousSystem and has the field :A, the subtype of AbstractDiscreteSystem with the field :A, i.e. LinearDiscreteSystem, is returned.

To get the complementary type of system type, use _complementary_type(typename(system)).

source