Types

Types

This section describes systems types implemented in MathematicalSystems.jl.

Abstract Systems

AbstractSystem

Abstract supertype for all system types.

source
AbstractContinuousSystem

Abstract supertype for all continuous system types.

source
AbstractDiscreteSystem

Abstract supertype for all discrete system types.

source

Continuous Systems

ContinuousIdentitySystem <: AbstractContinuousSystem

Trivial identity continuous-time system of the form:

\[ x' = 0.\]

Fields

  • statedim – number of state variables
source
ConstrainedContinuousIdentitySystem <: AbstractContinuousSystem

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

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

Fields

  • statedim – number of state variables
  • X – state constraints
source
LinearContinuousSystem

Continuous-time linear system of the form:

\[ x' = A x.\]

Fields

  • A – square matrix
source
AffineContinuousSystem

Continuous-time affine system of the form:

\[ x' = A x + b.\]

Fields

  • A – square matrix
  • b – vector
source
LinearControlContinuousSystem

Continuous-time linear control system of the form:

\[ x' = A x + B u.\]

Fields

  • A – square matrix
  • B – matrix
source
ConstrainedLinearContinuousSystem

Continuous-time linear system with state constraints of the form:

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

Fields

  • A – square matrix
  • X – state constraints
source
ConstrainedAffineContinuousSystem

Continuous-time affine system with state constraints of the form:

\[ x' = A x + b, x(t) ∈ \mathcal{X}.\]

Fields

  • A – square matrix
  • b – vector
  • X – state constraints
source
ConstrainedAffineControlContinuousSystem

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

\[ x' = A x + B u + c, x(t) ∈ \mathcal{X}, u(t) ∈ \mathcal{U} \text{ for all } t,\]

and $c$ a vector.

Fields

  • A – square matrix
  • B – matrix
  • c – vector
  • X – state constraints
  • U – input constraints
source
ConstrainedLinearControlContinuousSystem

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

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

Fields

  • A – square matrix
  • B – matrix
  • X – state constraints
  • U – input constraints
source
LinearAlgebraicContinuousSystem

Continuous-time linear algebraic system of the form:

\[ E x' = A x.\]

Fields

  • A – matrix
  • E – matrix, same size as A
source
ConstrainedLinearAlgebraicContinuousSystem

Continuous-time linear system with state constraints of the form:

\[ E x' = A x, x(t) ∈ \mathcal{X}.\]

Fields

  • A – matrix
  • E – matrix, same size as A
  • X – state constraints
source
PolynomialContinuousSystem

Continuous-time polynomial system of the form:

\[ x' = p(x).\]

Fields

  • p – polynomial vector field
  • statedim – number of state variables
source
ConstrainedPolynomialContinuousSystem

Continuous-time polynomial system with state constraints:

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

Fields

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

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

\[ x' = f(x(t))\]

Fields

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

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

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

Fields

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

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

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

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

Discrete Systems

DiscreteIdentitySystem <: AbstractDiscreteSystem

Trivial identity discrete-time system of the form:

\[ x_{k+1} = x_k.\]

Fields

  • statedim – number of state variables
source
ConstrainedDiscreteIdentitySystem <: AbstractDiscreteSystem

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

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

Fields

  • statedim – number of state variables
  • X – state constraints
source
LinearDiscreteSystem

Discrete-time linear system of the form:

\[ x_{k+1} = A x_k.\]

Fields

  • A – square matrix
source
AffineDiscreteSystem

Discrete-time affine system of the form:

\[ x_{k+1} = A x_k + b.\]

Fields

  • A – square matrix
  • b – vector
source
LinearControlDiscreteSystem

Discrete-time linear control system of the form:

\[ x_{k+1} = A x_k + B u_k.\]

Fields

  • A – square matrix
  • B – matrix
source
ConstrainedLinearDiscreteSystem

Discrete-time linear system with state constraints of the form:

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

Fields

  • A – square matrix
  • X – state constraints
source
ConstrainedAffineDiscreteSystem

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

\[ x_{k+1} = A x_k + b, x_k ∈ \mathcal{X} \text{ for all } k.\]

Fields

  • A – square matrix
  • b – vector
  • X – state constraints
source
ConstrainedLinearControlDiscreteSystem

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

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

Fields

  • A – square matrix
  • B – matrix
  • X – state constraints
  • U – input constraints
source
ConstrainedAffineControlDiscreteSystem

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

\[ x_{k+1} = A x+k + B u_k + c, x_k ∈ \mathcal{X}, u_k ∈ \mathcal{U} \text{ for all } k,\]

and $c$ a vector.

Fields

  • A – square matrix
  • B – matrix
  • c – vector
  • X – state constraints
  • U – input constraints
source
LinearAlgebraicDiscreteSystem

Discrete-time linear algebraic system of the form:

\[ E x_{k+1} = A x_k.\]

Fields

  • A – matrix
  • E – matrix, same size as A
source
ConstrainedLinearAlgebraicDiscreteSystem

Discrete-time linear system with state constraints of the form:

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

Fields

  • A – matrix
  • E – matrix, same size as A
  • X – state constraints
source
PolynomialDiscreteSystem

Discrete-time polynomial system of the form:

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

Fields

  • p – polynomial vector field
  • statedim – number of state variables
source
ConstrainedPolynomialDiscreteSystem

Discrete-time polynomial system with state constraints:

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

Fields

  • p – polynomial
  • X – constraint set
  • statedim – number of state variables
source
BlackBoxDiscreteSystem <: AbstractDiscreteSystem

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

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

Fields

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

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

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

Fields

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

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

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

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

Identity operator

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 AbstractMatix, 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

The easiest way to create an identity multiple is to use the callable version of LinearAlgebra.I:

julia> using MathematicalSystems: IdentityMultiple

julia> I2 = I(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 numeric type (default Float64) can be passed as a second argument:

julia> I2r = I(2, Rational{Int})
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

To create the matrix with a value different from the default (1.0), there are two ways. Either pass the value through the callable I, as in

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

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

Or use the lower level constructor passing the UniformScaling (I):

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

Initial Value Problems

InitialValueProblem

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

Fields

  • s – system
  • x0 – initial state

Examples

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

julia> p = InitialValueProblem(LinearContinuousSystem([-1.0 0.0; 0.0 -1.0]), [-1/2, 1/2]);

julia> p.x0
2-element Array{Float64,1}:
 -0.5
  0.5

julia> statedim(p)
2

julia> inputdim(p)
0
source
IVP

IVP is an alias for InitialValueProblem.

source

Input Types

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
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 Array{Rational{Int64},1}:
 -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
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},Array{Rational{Int64},1}}(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},Array{Rational{Int64},1}}}

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

julia> collect(nextinput(v, 2))
2-element Array{Rational{Int64},1}:
 -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 Array{Rational{Int64},1}:
 -1//2
  1//2

julia> [2*vi for vi in v]
2-element Array{Rational{Int64},1}:
 -1//1
  1//1

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

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

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

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

Maps

AbstractMap

Abstract supertype for all map types.

source
IdentityMap

An identity map,

\[ x ↦ x.\]

Fields

  • dim – dimension
source
ConstrainedIdentityMap

An identity map with state constraints of the form:

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

Fields

  • dim – dimension
  • X – state constraints
source
LinearMap

A linear map,

\[ x ↦ Ax\]

Fields

  • A – matrix
source
ConstrainedLinearMap

A linear map with state constraints of the form:

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

Fields

  • A – matrix
  • X – state constraints
source
AffineMap

An affine map,

\[ x ↦ Ax + b.\]

Fields

  • A – matrix
  • b – vector
source
ConstrainedAffineMap

An affine map with state constraints of the form:

\[ x ↦ Ax + b, x(t) ∈ \mathcal{X}.\]

Fields

  • A – matrix
  • b – vector
  • X – state constraints
source
LinearControlMap

A linear control map,

\[ (x, u) ↦ Ax + Bu.\]

Fields

  • A – matrix
  • B – matrix
source
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
AffineControlMap

An affine control map,

\[ (x, u) ↦ Ax + Bu + c.\]

Fields

  • A – matrix
  • B – matrix
  • c – vector
source
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
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
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

Macros

map(ex, args)

Returns 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,Array{Int64,2}}([1 0; 0 0])

We can create an affine system as well:

julia> @map x -> [1 0; 0 0]*x + [2, 0]
AffineMap{Int64,Array{Int64,2},Array{Int64,1}}([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 exmple, an identity map of dimension 5 can be defined as:

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

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

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

Systems with output

SystemWithOutput{ST<:AbstractSystem, MT<:AbstractMap}

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
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
LTISystem

LTISystem is an alias for LinearTimeInvariantSystem.

source