-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
outsource convert methods to set modules
- Loading branch information
Showing
32 changed files
with
373 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
convert(::Type{HParallelotope}, Z::AbstractZonotope{N}) where {N} | ||
Convert a zonotopic set of order one to a parallelotope in constraint | ||
representation. | ||
### Input | ||
- `HParallelotope` -- target type | ||
- `Z` -- zonotopic set of order one | ||
### Output | ||
A parallelotope in constraint representation. | ||
### Notes | ||
This function requires that the list of constraints of `Z` are obtained in | ||
the particular order returned from the `constraints_list` function of a | ||
`Zonotope`. Hence it first converts `Z` to a `Zonotope`. | ||
""" | ||
function convert(::Type{HParallelotope}, Z::AbstractZonotope{N}) where {N} | ||
@assert order(Z) == 1 "cannot convert a zonotope that is not of order 1 " * | ||
"to a parallelotope" | ||
n = dim(Z) | ||
|
||
constraints = _constraints_list_zonotope(Z) | ||
|
||
D = Matrix{N}(undef, n, n) | ||
c = Vector{N}(undef, 2n) | ||
j = 1 | ||
@inbounds for i in 1:n | ||
D[i, :] = constraints[j].a | ||
c[i] = constraints[j].b | ||
c[i + n] = constraints[j + 1].b | ||
j += 2 | ||
end | ||
return HParallelotope(D, c; check_consistency=false) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
convert(::Type{HPolyhedron}, X::LazySet) | ||
Convert a polyhedral set to a polyhedron in constraint representation. | ||
### Input | ||
- `HPolyhedron` -- target type | ||
- `X` -- polyhedral set | ||
### Output | ||
The given set represented as a polyhedron in constraint representation. | ||
### Algorithm | ||
This method uses `constraints_list`. | ||
""" | ||
function convert(::Type{HPolyhedron}, X::LazySet) | ||
if !is_polyhedral(X) | ||
error("conversion to `HPolyhedron` requires a polyhedral set") | ||
end | ||
return HPolyhedron(constraints_list(X)) | ||
end | ||
|
||
convert(::Type{HPolyhedron{N,VT}}, P::HPolyhedron{N,VT}) where {N,VT} = P | ||
|
||
function convert(::Type{HPolyhedron{N,VT}}, X::LazySet) where {N,VT} | ||
if !is_polyhedral(X) | ||
error("conversion to `HPolyhedron` requires a polyhedral set") | ||
end | ||
return HPolyhedron([HalfSpace(VT(c.a), N(c.b)) for c in constraints(X)]) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
convert(::Type{HPolytope}, X::LazySet) | ||
Convert a polytopic set to a polytope in constraint representation. | ||
### Input | ||
- `HPolytope` -- target type | ||
- `X` -- polytopic set | ||
### Output | ||
The given polytope represented as a polytope in constraint representation. | ||
### Algorithm | ||
This method uses `constraints_list`. | ||
""" | ||
function convert(::Type{HPolytope}, X::LazySet) | ||
if !isboundedtype(typeof(X)) || !is_polyhedral(X) | ||
error("conversion to `HPolytope` requires a polytopic set") | ||
end | ||
return HPolytope(constraints_list(X)) | ||
end | ||
|
||
convert(::Type{HPolytope{N,VT}}, P::HPolytope{N,VT}) where {N,VT} = P | ||
|
||
function convert(::Type{HPolytope{N,VT}}, X::LazySet) where {N,VT} | ||
if !isboundedtype(typeof(X)) || !is_polyhedral(X) | ||
error("conversion to `HPolytope` requires a polytopic set") | ||
end | ||
return HPolytope([HalfSpace(VT(c.a), N(c.b)) for c in constraints_list(X)]) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# convert to concrete Vector representation | ||
function convert(::Type{HalfSpace{N,Vector{N}}}, | ||
hs::HalfSpace{N,<:AbstractVector{N}}) where {N} | ||
return HalfSpace(Vector(hs.a), hs.b) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.