Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#559 - Accept CA_S in normalization #560

Merged
merged 1 commit into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/Utils/normalization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,28 @@ for CLC_S in (:CLCCS, :CLCDS)
end
end

# x' = Ax + c, x ∈ X, u ∈ U in the continuous case
# x+ = Ax + c, x ∈ X, u ∈ U in the discrete case
for (CA_S, CLC_S) in ((:CACS, :CLCCS), (:CADS, :CLCDS))
@eval begin
function normalize(system::$CA_S{N, AN, VN, XT}) where {N, AN<:AbstractMatrix{N}, VN<:AbstractVector{N}, XT<:XNCF{N}}
n = statedim(system)
X = _wrap_invariant(system.X, n)
U = _wrap_inputs(system.b)
$CLC_S(system.A, I(n, N), X, U)
end
end
end

# x' = Ax + Bu + c, x ∈ X, u ∈ U in the continuous case
# x+ = Ax + Bu + c, x ∈ X, u ∈ U in the discrete case
for CAC_S in (:CACCS, :CACDS)
for (CAC_S, CLC_S) in ((:CACCS, :CLCCS), (:CACDS, :CLCDS))
@eval begin
function normalize(system::$CAC_S{N, AN, BN, VN, XT, UT}) where {N, AN<:AbstractMatrix{N}, BN<:AbstractMatrix{N}, VN<:AbstractVector{N}, XT<:XNCF{N}, UT<:UNCF{N}}
n = statedim(system)
X = _wrap_invariant(system.X, n)
U = _wrap_inputs(system.U, system.B, system.c)
$CAC_S(system.A, I(n, N), X, U)
$CLC_S(system.A, I(n, N), X, U)
end
end
end
Expand Down Expand Up @@ -134,6 +147,8 @@ _wrap_inputs(U::LazySet, B::AbstractMatrix, c::AbstractVector) = ConstantInput(B
_wrap_inputs(U::Vector{<:LazySet}, B::IdentityMultiple, c::AbstractVector) = isidentity(B) ? VaryingInput(map(u -> u ⊕ c, U)) : VaryingInput(map(u -> B*u ⊕ c, U))
_wrap_inputs(U::Vector{<:LazySet}, B::AbstractMatrix, c::AbstractVector) = VaryingInput(map(u -> B*u ⊕ c, U))

_wrap_inputs(c::AbstractVector) = ConstantInput(Singleton(c))

"""
distribute_initial_set(system::InitialValueProblem{<:HybridSystem, <:LazySet)

Expand Down
2 changes: 2 additions & 0 deletions src/Utils/systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const CLCCS = ConstrainedLinearControlContinuousSystem
const CLCDS = ConstrainedLinearControlDiscreteSystem
const CACCS = ConstrainedAffineControlContinuousSystem
const CACDS = ConstrainedAffineControlDiscreteSystem
const CACS = ConstrainedAffineContinuousSystem
const CADS = ConstrainedAffineDiscreteSystem

export LCS, LDS, CLCS, CLDS, CLCCS, CLCDS, CACCS, CACDS, IVP

Expand Down
2 changes: 1 addition & 1 deletion src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ discrete or continuous system.
A continuous post operator with default options.
"""
function default_operator(system::InitialValueProblem)
if islinear(system)
if isaffine(system)
op = BFFPSV18()
else
error("no default reachability algorithm available for system of " *
Expand Down
13 changes: 13 additions & 0 deletions test/Reachability/solve_continuous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,16 @@ s = Reachability.solve(IVP(CLCCS(A, B, X, U), X0), Options(:T=>Inf))
s = solve(IVP(LCS(A), X0), :T=>Inf, :mode=>"check", :property=>property)
s = solve(IVP(CLCCS(A, B, X, U), X0),
:T=>Inf, :mode=>"check", :property=>property)

# =================================================================
# Affine ODE with a nondeterministic input, x' = Ax + b, no inputs
# =================================================================
A = [ 0.0509836 0.168159 0.95246 0.33644
0.42377 0.67972 0.129232 0.126662
0.518654 0.981313 0.489854 0.588326
0.38318 0.616014 0.518412 0.778765]
b = [1.0, -1, 0, 1.]
X = HalfSpace([-1.0, 0.0, 0.0, 0.0], 0.0)
X0 = BallInf(zeros(4), 0.5)
p = IVP(ConstrainedAffineContinuousSystem(A, b, X), X0)
sol = solve(p, :T=>0.1)