MathematicalSystems.jl icon indicating copy to clipboard operation
MathematicalSystems.jl copied to clipboard

Handle systems with incomplete constraints

Open mforets opened this issue 5 years ago • 3 comments

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:

  1. Add a new system type with the corresponding variation, eg. StateConstrainedLinearControlContinuousSystem, InputConstrainedLinearControlContinuousSystem (keeping ConstrainedLinearControlContinuousSystem to mean that both input and state sets are constrained).

  2. Create instances with nothing in the corresponding fields.

  3. 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 ;)

mforets avatar Feb 21 '20 14:02 mforets

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 ;)

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

schillic avatar Feb 21 '20 19:02 schillic

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.

mforets avatar Feb 21 '20 19:02 mforets

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?

ueliwechsler avatar Feb 22 '20 09:02 ueliwechsler