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

Remove calls to uniqueID (done in constructor) #3448

Merged
merged 1 commit into from
Mar 19, 2024
Merged
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
43 changes: 23 additions & 20 deletions src/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1064,13 +1064,11 @@ function convert(::Type{SimpleSparsePolynomialZonotope}, Z::AbstractZonotope)
G = genmat(Z)
n = ngens(Z)
E = Matrix(1 * I, n, n)

return SimpleSparsePolynomialZonotope(c, G, E)
end

"""
convert(::Type{SimpleSparsePolynomialZonotope},
SPZ::SparsePolynomialZonotope)
convert(::Type{SimpleSparsePolynomialZonotope}, SPZ::SparsePolynomialZonotope)

Convert a sparse polynomial zonotope to simple sparse polynomial zonotope.

Expand All @@ -1082,14 +1080,19 @@ Convert a sparse polynomial zonotope to simple sparse polynomial zonotope.
### Output

A simple sparse polynomial zonotope.

### Algorithm

The method implements Proposition 3.1.4 from [1].

[1] Kochdumper, Niklas. *Extensions of polynomial zonotopes and their application to
verification of cyber-physical systems.* PhD diss., Technische Universität München, 2022.
"""
function convert(::Type{SimpleSparsePolynomialZonotope},
SPZ::SparsePolynomialZonotope)
function convert(::Type{SimpleSparsePolynomialZonotope}, SPZ::SparsePolynomialZonotope)
c = center(SPZ)
G = hcat(genmat_dep(SPZ), genmat_indep(SPZ))
n = ngens_indep(SPZ)
E = cat(expmat(SPZ), Matrix(1 * I, n, n); dims=(1, 2))

return SimpleSparsePolynomialZonotope(c, G, E)
end

Expand All @@ -1106,22 +1109,25 @@ Convert a zonotope to sparse polynomial zonotope.
### Output

A sparse polynomial zonotope.

### Algorithm

The method implements Proposition 3.1.9 from [1].

[1] Kochdumper, Niklas. *Extensions of polynomial zonotopes and their application to
verification of cyber-physical systems.* PhD diss., Technische Universität München, 2022.
"""
function convert(::Type{SparsePolynomialZonotope},
Z::AbstractZonotope{N}) where {N}
function convert(::Type{SparsePolynomialZonotope}, Z::AbstractZonotope{N}) where {N}
c = center(Z)
G = genmat(Z)
n = ngens(Z)
E = Matrix(1 * I, n, n)
idx = uniqueID(n)
p = ngens(Z)
E = Matrix(1 * I, p, p)
GI = zeros(N, dim(Z), 0)

return SparsePolynomialZonotope(c, G, GI, E, idx)
return SparsePolynomialZonotope(c, G, GI, E)
end

"""
convert(::Type{SparsePolynomialZonotope},
SSPZ::SimpleSparsePolynomialZonotope)
convert(::Type{SparsePolynomialZonotope}, SSPZ::SimpleSparsePolynomialZonotope)

Convert a simple sparse polynomial zonotope to a sparse polynomial zonotope.

Expand All @@ -1139,11 +1145,8 @@ function convert(::Type{SparsePolynomialZonotope},
c = center(SSPZ)
G = genmat(SSPZ)
E = expmat(SSPZ)
n = ngens(SSPZ)
idx = uniqueID(n)
GI = zeros(N, dim(SSPZ), 0)

return SparsePolynomialZonotope(c, G, GI, E, idx)
GI = Matrix{N}(undef, dim(SSPZ), 0)
return SparsePolynomialZonotope(c, G, GI, E)
end

function convert(::Type{VPolytope}, T::Tetrahedron)
Expand Down
Loading