Skip to content

Commit

Permalink
Merge pull request #25 from blegat/mforets/redo_assignment
Browse files Browse the repository at this point in the history
Add resetmap getter
  • Loading branch information
blegat authored Feb 9, 2019
2 parents c6ac0b6 + 6d43466 commit ce9996e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
1 change: 1 addition & 0 deletions docs/src/lib/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ out_transitions
### Guards and Assignments

```@docs
resetmap
guard
assignment
```
46 changes: 30 additions & 16 deletions src/HybridSystems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,7 @@ abstract type AbstractHybridSystem <: MathematicalSystems.AbstractSystem end
"""
HybridSystem{A, S, R, W} <: AbstractHybridSystem
A hybrid system modelled as a hybrid automaton. The automaton `automaton` of
type `A` models the different discrete states and the allowed transitions with
corresponding labels.
The mode dynamic and domain are stored in a continuous dynamical system of type
`S` in the vector `modes`. They are indexed by the discrete states of the
automaton.
The reset maps and guards are given as discrete dynamical system or discrete map
of type `R` in the vector `resetmaps`. They are indexed by the labels of the
corresponding transition.
The switching of type `W` is given in the `switchings` vector,
indexed by the label of the transition.
Additional data can be stored in the `ext` field.
A hybrid system modelled as a hybrid automaton.
### Fields
Expand All @@ -43,7 +32,25 @@ Additional data can be stored in the `ext` field.
transition, see [`AbstractSwitching`](@ref).
- `ext` -- dictionary that can be used by extensions.
## Examples
### Notes
The automaton `automaton` of type `A` models the different discrete states and
the allowed transitions with corresponding labels.
The mode dynamic and domain are stored in a continuous dynamical system of type
`S` in the vector `modes`. They are indexed by the discrete states of the
automaton.
The reset maps and guards are given as a map or a discrete dynamical system of
type `R` in the vector `resetmaps`. They are indexed by the labels of the
corresponding transition.
The switching of type `W` is given in the `switchings` vector, indexed by the
label of the transition.
Additional data can be stored in the `ext` field.
### Examples
See [the Thermostat example](https://github.com/blegat/HybridSystems.jl/blob/master/examples/Thermostat.ipynb).
"""
Expand Down Expand Up @@ -78,7 +85,7 @@ for f in [:state_property_type, :transition_property_type]
end

# System
export statedim, stateset, inputdim, inputset, guard, assignment, target_mode
export statedim, stateset, inputdim, inputset, guard, assignment, target_mode, resetmap
"""
statedim(hs::HybridSystem, u::Int)
Expand All @@ -100,19 +107,26 @@ Returns the target mode for the transition `t`.
"""
target_mode(hs::HybridSystem, t) = hs.modes[target(hs, t)]

"""
resetmap(hs::HybridSystem, t)
Returns the reset map for the transition `t`.
"""
resetmap(hs::HybridSystem, t) = hs.resetmaps[symbol(hs, t)]

"""
assignment(hs::HybridSystem, t)
Returns the assignment for the transition `t`.
"""
assignment(hs::HybridSystem, t) = hs.resetmaps[symbol(hs, t)]
assignment(hs::HybridSystem{A,S,R,W}, t) where {A, S<:AbstractSystem, R<:AbstractMap, W} = (args...) -> apply(resetmap(hs, t), args...)

"""
guard(hs::HybridSystem, t)
Returns the guard for the transition `t`.
"""
guard(hs::HybridSystem, t) = stateset(assignment(hs, t))
guard(hs::HybridSystem, t) = stateset(resetmap(hs, t))

# for completeness, extend the stateset function from MathematicalSystems
# because guards are given as the state constraints of the reset map
Expand Down

0 comments on commit ce9996e

Please sign in to comment.