-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsuccessor.jl
116 lines (84 loc) · 3.51 KB
/
successor.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# =============================
# Successor for discrete system
# =============================
"""
successor(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`.
"""
function successor(system::DiscreteIdentitySystem, x::AbstractVector)
!_is_conformable_state(system, x) && _argument_error(:x)
return x
end
"""
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`.
"""
function successor(system::ConstrainedDiscreteIdentitySystem, x::AbstractVector;
check_constraints::Bool=true)
!_is_conformable_state(system, x) && _argument_error(:x)
if check_constraints
!_in_stateset(system, x) && _argument_error(:x,:X)
end
return x
end
"""
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; kwargs...) =
_instantiate(system, x; kwargs...)
"""
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, if `system`
is not controlled
- `check_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; kwargs...) =
_instantiate(system, x, u; kwargs...)
"""
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`.
"""
successor(system::AbstractDiscreteSystem, x::AbstractVector, u::AbstractVector, w::AbstractVector; kwargs...) =
_instantiate(system, x, u, w; kwargs...)