MathematicalSystems.jl
MathematicalSystems.jl copied to clipboard
Handle systems with incomplete constraints
There are combinations of systems that are not available; my favorite example is a ConstrainedLinearControlContinuousSystem where the input is constrained but the state set is unconstrained.
Here are three alternatives:
-
Add a new system type with the corresponding variation, eg.
StateConstrainedLinearControlContinuousSystem
,InputConstrainedLinearControlContinuousSystem
(keepingConstrainedLinearControlContinuousSystem
to mean that both input and state sets are constrained). -
Create instances with
nothing
in the corresponding fields. -
Create instances with a universe using a thin layer:
MathematicalSets.UniversalSet
and adding type restrictions for the set constraints to be<: MathematicalSets.AbstractSet
.
From discussin on gitter, option 1 is a bit heavy on types because of the different combinations. Option 3 is the best (to me) but we would need to update MathematicalSets
so it is not immediate. So we would rather go with option 2. Note that downstream packages can dispatch on Nothing
in that case.
NB: why i think that 3 is better than 2 is that you don't need to bother with small unions, Union{Nothing, LazySet}
, since LazySets.Universe
will take the role of MathematicalSets.UniversalSet
. And also, generic algorithms do not have to consider the missing information as a special case becuase LazySets.Universe
behaves as a set ;)
NB: why i think that 3 is better than 2 is that you don't need to bother with small unions,
Union{Nothing, LazySet}
, sinceLazySets.Universe
will take the role ofMathematicalSets.UniversalSet
. And also, generic algorithms do not have to consider the missing information as a special case becuaseLazySets.Universe
behaves as a set ;)
Not every package uses LazySets
nor MathematicalSets
. I would not rely on those.
The difference between 2. and 3. is just in cases where we want to automatically create a system. A user who wants to create a system can always choose their representation of a Universe
. So I guess your motivation is the @system
macro. For that you can add a way to define a function that creates an n-dimensional universe. Then @system
can use that.
julia> my_universe(n) = LazySets.Universe(n); # example function
julia> @universe my_universe # assigns my_universe to an internal function _universe
julia> @system ... # internally calls _universe to create universes
Exactly, the idea of using MathematicalSets
was that it should provide the necessary functionality; then eg. LazySets implements the higher-level interface defining its universe
function.
I also would select either option 2 or 3.
Could we make MathematicalSets
or LazySets
an optional dependency that creates its own universe
function as soon as it is loaded which overwrites the default my_universe
function that returns nothing
?