Methods
This section describes systems methods implemented in MathematicalSystems.jl
.
States
MathematicalSystems.statedim
— Functionstatedim(s::AbstractSystem)
Returns the dimension of the state space of system s
.
MathematicalSystems.stateset
— Functionstateset(s::AbstractSystem)
Returns the set of allowed states of system s
.
Inputs
MathematicalSystems.inputdim
— Functioninputdim(s::AbstractSystem)
Returns the dimension of the input space of system s
.
MathematicalSystems.inputset
— Functioninputset(s::AbstractSystem)
Returns the set of allowed inputs of system s
.
MathematicalSystems.nextinput
— Functionnextinput(input::ConstantInput, n::Int=1)
Returns the first n
elements of this input.
Input
input
– a constant inputn
– (optional, default:1
) the number of desired elements
Output
A repeated iterator that generates n
equal samples of this input.
nextinput(input::VaryingInput, n::Int=1)
Returns the first n
elements of this input.
Input
input
– varying inputn
– (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.
Noises
MathematicalSystems.noisedim
— Functionnoisedim(s::AbstractSystem)
Returns the dimension of the noise space of system s
.
MathematicalSystems.noiseset
— Functionnoiseset(s::AbstractSystem)
Returns the set of allowed noises of system s
.
Output
MathematicalSystems.outputdim
— Functionoutputdim(m::AbstractMap)
Returns the dimension of the output space of the map m
.
MathematicalSystems.outputmap
— Functionoutputmap(s::AbstractSystem)
Returns the output map of a system with output.
Traits
MathematicalSystems.islinear
— Methodislinear(s::AbstractSystem)
Determines whether 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.
MathematicalSystems.islinear
— Methodislinear(m::AbstractMap)
Determines whether the map m
is linear or not.
Notes
A map is linear if it preserves the operations of scalar multiplication and vector addition.
MathematicalSystems.isaffine
— Methodisaffine(s::AbstractSystem)
Determines whether 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
.
MathematicalSystems.isaffine
— Methodisaffine(m::AbstractMap)
Determines whether the map m
is affine or not.
Notes
An affine map is the composition of a linear map and a translation. See also islinear(::AbstractMap)
.
MathematicalSystems.ispolynomial
— Methodispolynomial(s::AbstractSystem)
Determines whether 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.
MathematicalSystems.isblackbox
— Methodisblackbox(s::AbstractSystem)
Determines whether 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)
.
MathematicalSystems.isnoisy
— Methodisnoisy(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)
.
MathematicalSystems.iscontrolled
— Methodiscontrolled(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)
.
MathematicalSystems.isconstrained
— Methodisconstrained(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)
.
MathematicalSystems.state_matrix
— Methodstate_matrix(s::AbstractSystem)
Returns 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$.
MathematicalSystems.input_matrix
— Methodinput_matrix(s::AbstractSystem)
Returns 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$.
MathematicalSystems.noise_matrix
— Methodnoise_matrix(s::AbstractSystem)
Returns 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$.
MathematicalSystems.affine_term
— Methodaffine_term(s::AbstractSystem)
Returns the affine term in an affine system.
Notes
The affine term is e.g. the vector $c$ in the affine system $x' = Ax + c$.
MathematicalSystems.mapping
— Methodmapping(s::AbstractSystem)
Returns the mapping of a black-box system.
Maps
MathematicalSystems.apply
— Functionapply(m::AbstractMap, args...)
Apply the rule specified by the map to the given arguments.
Successor
MathematicalSystems.successor
— Functionsuccessor(system::DiscreteIdentitySystem, x::AbstractVector)
Return the successor state of a DiscreteIdentitySystem
.
Input
system
–DiscreteIdentitySystem
x
– state (it should be any vector type)
Output
The same state x
.
successor(system::ConstrainedDiscreteIdentitySystem, x::AbstractVector;
[check_constraints]=true)
Return the successor state of a ConstrainedDiscreteIdentitySystem
.
Input
system
–ConstrainedDiscreteIdentitySystem
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
.
successor(system::AbstractDiscreteSystem, x::AbstractVector;
[check_constraints]=true)
Return the successor state of an AbstractDiscreteSystem
.
Input
system
–AbstractDiscreteSystem
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
.
successor(system::AbstractDiscreteSystem, x::AbstractVector, u::AbstractVector;
[check_constraints]=true)
Return the successor state of an AbstractDiscreteSystem
.
Input
system
–AbstractDiscreteSystem
x
– state (it should be any vector type)u
– input (it should be any vector type) or noise, ifsystem
is not controlledcheck_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.
successor(system::AbstractDiscreteSystem,
x::AbstractVector, u::AbstractVector, w::AbstractVector; [check_constraints]=true)
Return the successor state of an AbstractDiscreteSystem
.
Input
system
–AbstractDiscreteSystem
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
.
Vector Field
MathematicalSystems.vector_field
— Functionvector_field(system::ContinuousIdentitySystem, x::AbstractVector)
Return the vector field state of a ContinuousIdentitySystem
.
Input
system
–ContinuousIdentitySystem
x
– state (it should be any vector type)
Output
A zeros vector of dimension statedim
.
vector_field(system::ConstrainedContinuousIdentitySystem, x::AbstractVector;
[check_constraints]=true)
Return the vector field state of a ConstrainedContinuousIdentitySystem
.
Input
system
–ConstrainedContinuousIdentitySystem
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
.
vector_field(system::AbstractContinuousSystem, x::AbstractVector;
[check_constraints]=true)
Return the vector field state of an AbstractContinuousSystem
.
Input
system
–AbstractContinuousSystem
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
.
vector_field(system::AbstractContinuousSystem, x::AbstractVector, u::AbstractVector;
[check_constraints]=true)
Return the vector field state of an AbstractContinuousSystem
.
Input
system
–AbstractContinuousSystem
x
– state (it should be any vector type)u
– input (it should be any vector type) or noise, ifsystem
is not controlledcheck_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.
vector_field(system::AbstractContinuousSystem,
x::AbstractVector, u::AbstractVector, w::AbstractVector; [check_constraints]=true)
Return the vector field state of an AbstractContinuousSystem
.
Input
system
–AbstractContinuousSystem
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
.
Discretization
MathematicalSystems.discretize
— Functiondiscretize(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 timealgorithm
– (optional, default:ExactDiscretization()
) discretization algorithmconstructor
– (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
.
Internal Methods
MathematicalSystems._discretize
— Function_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 timeA
– state matrixB
– input matrixc
– vectorD
– noise matrix
Output
Returns a vector containing the discretized input arguments A
, B
, c
and D
.
Notes
See discretize
for more details.
_discretize(algorithm::AbstractDiscretizationAlgorithm, ΔT::Real,
A::AbstractMatrix)
Discretize the state matrix A
with sampling time ΔT
and discretization method algorithm
.
Input
algorithm
– discretization algorithmΔT
– sampling timeA
– state matrix
Output
Returns a vector containing the discretized input argument A
.
Notes
See discretize
for more details.
_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 timeA
– state matrixB
– 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.
_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 timeA
– state matrixc
– vector
Output
Returns a vector containing the discretized input arguments A
and c
.
Notes
See discretize
for more details.
_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 timeA
– state matrixB
– input matrixc
– vector
Output
Returns a vector containing the discretized input arguments A
, B
and c
.
Notes
See discretize
for more details.
_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 timeA
– state matrixB
– input matrixD
– noise matrix
Output
Returns a vector containing the discretized input arguments A
, B
and D
.
Notes
See discretize
for more details.
MathematicalSystems.typename
— Methodtypename(system::AbstractSystem)
Returns the base type of system
without parameter information.
Input
system
–AbstractSystem
Output
The base type of system
.
MathematicalSystems._complementary_type
— Method_complementary_type(system_type::Type{<:AbstractSystem})
Return the complementary type of a system type system_type
.
Input
system_type
– type ofAbstractSystem
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))
.