From ae526a196037d727a950de9544dfb88751be82b5 Mon Sep 17 00:00:00 2001 From: schillic Date: Mon, 26 Feb 2024 22:43:24 +0100 Subject: [PATCH] remove calls to uniqueID (done in constructor) --- src/convert.jl | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/convert.jl b/src/convert.jl index c230c4a8d7..97a45893cb 100644 --- a/src/convert.jl +++ b/src/convert.jl @@ -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. @@ -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 @@ -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. @@ -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)