From 18f26585ac6d1456d6b1717eba04a54019d07074 Mon Sep 17 00:00:00 2001 From: schillic Date: Fri, 12 Jul 2024 08:25:10 +0200 Subject: [PATCH 1/6] move helper function --- src/Interfaces/AbstractPolynomialZonotope.jl | 23 +++++++++++++++++++ src/LazySets.jl | 1 - .../SimpleSparsePolynomialZonotopeModule.jl | 2 +- .../remove_redundant_generators.jl | 23 ------------------- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/Interfaces/AbstractPolynomialZonotope.jl b/src/Interfaces/AbstractPolynomialZonotope.jl index 5377dd1f3d..ca42d2cad6 100644 --- a/src/Interfaces/AbstractPolynomialZonotope.jl +++ b/src/Interfaces/AbstractPolynomialZonotope.jl @@ -138,3 +138,26 @@ Return the ambient dimension of a polynomial zonotope. An integer representing the ambient dimension of the polynomial zonotope. """ dim(PZ::AbstractPolynomialZonotope) = length(center(PZ)) + +function _remove_redundant_generators_polyzono(c, G, E) + Gnew = Matrix{eltype(G)}(undef, size(G, 1), 0) + Enew = Matrix{eltype(E)}(undef, size(E, 1), 0) + cnew = copy(c) + + visited_exps = Dict{Vector{Int},Int}() + @inbounds for (gi, ei) in zip(eachcol(G), eachcol(E)) + all(isapproxzero, gi) && continue + if iszero(ei) + cnew += gi + elseif haskey(visited_exps, ei) # repeated exponent + idx = visited_exps[ei] + Gnew[:, idx] += gi + else + Gnew = hcat(Gnew, gi) + Enew = hcat(Enew, ei) + visited_exps[ei] = size(Enew, 2) + end + end + + return cnew, Gnew, Enew +end diff --git a/src/LazySets.jl b/src/LazySets.jl index 27c757cc4a..851f683b29 100644 --- a/src/LazySets.jl +++ b/src/LazySets.jl @@ -145,7 +145,6 @@ include("Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModul @reexport using ..SimpleSparsePolynomialZonotopeModule: SimpleSparsePolynomialZonotope, SSPZ, quadratic_map -using ..SimpleSparsePolynomialZonotopeModule: _remove_redundant_generators_polyzono """ PolynomialZonotope = SimpleSparsePolynomialZonotope diff --git a/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl b/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl index e24110b0f9..84d9ccd628 100644 --- a/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl +++ b/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl @@ -2,7 +2,7 @@ module SimpleSparsePolynomialZonotopeModule using Reexport -using ..LazySets: AbstractPolynomialZonotope +using ..LazySets: AbstractPolynomialZonotope, _remove_redundant_generators_polyzono using Random: AbstractRNG, GLOBAL_RNG using ReachabilityBase.Distribution: reseed! using ReachabilityBase.Comparison: isapproxzero diff --git a/src/Sets/SimpleSparsePolynomialZonotope/remove_redundant_generators.jl b/src/Sets/SimpleSparsePolynomialZonotope/remove_redundant_generators.jl index ebe230281b..21d89cbcb6 100644 --- a/src/Sets/SimpleSparsePolynomialZonotope/remove_redundant_generators.jl +++ b/src/Sets/SimpleSparsePolynomialZonotope/remove_redundant_generators.jl @@ -32,26 +32,3 @@ function remove_redundant_generators(S::SimpleSparsePolynomialZonotope) return SimpleSparsePolynomialZonotope(c, G, E) end - -function _remove_redundant_generators_polyzono(c, G, E) - Gnew = Matrix{eltype(G)}(undef, size(G, 1), 0) - Enew = Matrix{eltype(E)}(undef, size(E, 1), 0) - cnew = copy(c) - - visited_exps = Dict{Vector{Int},Int}() - @inbounds for (gi, ei) in zip(eachcol(G), eachcol(E)) - all(isapproxzero, gi) && continue - if iszero(ei) - cnew += gi - elseif haskey(visited_exps, ei) # repeated exponent - idx = visited_exps[ei] - Gnew[:, idx] += gi - else - Gnew = hcat(Gnew, gi) - Enew = hcat(Enew, ei) - visited_exps[ei] = size(Enew, 2) - end - end - - return cnew, Gnew, Enew -end From 89afe5d343cf56bc9a1bbc3627519758c82f1518 Mon Sep 17 00:00:00 2001 From: schillic Date: Fri, 12 Jul 2024 08:32:40 +0200 Subject: [PATCH 2/6] add ndeps_* for SSPZ and revise interface requirements --- src/Interfaces/AbstractPolynomialZonotope.jl | 11 +++++++++-- .../SimpleSparsePolynomialZonotopeModule.jl | 2 ++ src/Sets/SimpleSparsePolynomialZonotope/ngens.jl | 2 +- src/Sets/SimpleSparsePolynomialZonotope/ngens_dep.jl | 1 + .../SimpleSparsePolynomialZonotope/ngens_indep.jl | 1 + 5 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 src/Sets/SimpleSparsePolynomialZonotope/ngens_dep.jl create mode 100644 src/Sets/SimpleSparsePolynomialZonotope/ngens_indep.jl diff --git a/src/Interfaces/AbstractPolynomialZonotope.jl b/src/Interfaces/AbstractPolynomialZonotope.jl index ca42d2cad6..f9db32c5e1 100644 --- a/src/Interfaces/AbstractPolynomialZonotope.jl +++ b/src/Interfaces/AbstractPolynomialZonotope.jl @@ -19,14 +19,21 @@ Every concrete `AbstractPolynomialZonotope` must define the following functions: - `center(::AbstractPolynomialZonotope)` -- return the center -- `order(::AbstractPolynomialZonotope)` -- return the order - - `polynomial_order(::AbstractPolynomialZonotope)` -- return the polynomial order +By defining the functions + - `ngens_dep` -- return the number of dependent generators - `ngens_indep` -- return the number of independent generators +the following functions are also available (alternatively, these functions can +be defined directly): + +- `order(::AbstractPolynomialZonotope)` -- return the order + +- `ngens(::AbstractPolynomialZonotope)` -- return the total number of generators + ```jldoctest; setup = :(using LazySets: subtypes) julia> subtypes(AbstractPolynomialZonotope) 3-element Vector{Any}: diff --git a/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl b/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl index 84d9ccd628..185fbfc9ff 100644 --- a/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl +++ b/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl @@ -27,6 +27,8 @@ include("convex_hull.jl") include("genmat.jl") include("isoperationtype.jl") include("ngens.jl") +include("ngens_dep.jl") +include("ngens_indep.jl") include("polynomial_order.jl") include("remove_redundant_generators.jl") include("expmat.jl") diff --git a/src/Sets/SimpleSparsePolynomialZonotope/ngens.jl b/src/Sets/SimpleSparsePolynomialZonotope/ngens.jl index 33a848285f..965f2a88ca 100644 --- a/src/Sets/SimpleSparsePolynomialZonotope/ngens.jl +++ b/src/Sets/SimpleSparsePolynomialZonotope/ngens.jl @@ -16,4 +16,4 @@ The number of generators of `P`. This number corresponds to the number of monomials in the polynomial representation of `P`. """ -ngens(P::SSPZ) = size(P.G, 2) +ngens(P::SSPZ) = ngens_dep(P) diff --git a/src/Sets/SimpleSparsePolynomialZonotope/ngens_dep.jl b/src/Sets/SimpleSparsePolynomialZonotope/ngens_dep.jl new file mode 100644 index 0000000000..df8bf8f506 --- /dev/null +++ b/src/Sets/SimpleSparsePolynomialZonotope/ngens_dep.jl @@ -0,0 +1 @@ +ngens_dep(P::SSPZ) = size(P.G, 2) diff --git a/src/Sets/SimpleSparsePolynomialZonotope/ngens_indep.jl b/src/Sets/SimpleSparsePolynomialZonotope/ngens_indep.jl new file mode 100644 index 0000000000..14b0739759 --- /dev/null +++ b/src/Sets/SimpleSparsePolynomialZonotope/ngens_indep.jl @@ -0,0 +1 @@ +ngens_indep(::SSPZ) = 0 From fb4a081ff9b4a715001b8c4212877d3d1fdc8e1a Mon Sep 17 00:00:00 2001 From: schillic Date: Fri, 12 Jul 2024 09:08:03 +0200 Subject: [PATCH 3/6] make 'expmat' an interface function for AbstractPolynomialZonotope --- .../interfaces/AbstractPolynomialZonotope.md | 1 + src/Interfaces/AbstractPolynomialZonotope.jl | 23 +++++++++++++++++++ src/Sets/SparsePolynomialZonotope.jl | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/src/lib/interfaces/AbstractPolynomialZonotope.md b/docs/src/lib/interfaces/AbstractPolynomialZonotope.md index 237f60201b..919e85f570 100644 --- a/docs/src/lib/interfaces/AbstractPolynomialZonotope.md +++ b/docs/src/lib/interfaces/AbstractPolynomialZonotope.md @@ -25,6 +25,7 @@ center(::LazySet) CurrentModule = LazySets ``` ```@docs +expmat(::AbstractPolynomialZonotope) ngens_dep(::AbstractPolynomialZonotope) ngens_indep(::AbstractPolynomialZonotope) polynomial_order(::AbstractPolynomialZonotope) diff --git a/src/Interfaces/AbstractPolynomialZonotope.jl b/src/Interfaces/AbstractPolynomialZonotope.jl index f9db32c5e1..a6cebbac78 100644 --- a/src/Interfaces/AbstractPolynomialZonotope.jl +++ b/src/Interfaces/AbstractPolynomialZonotope.jl @@ -1,5 +1,6 @@ export AbstractPolynomialZonotope, center, + expmat, polynomial_order, order, ngens, @@ -21,6 +22,8 @@ Every concrete `AbstractPolynomialZonotope` must define the following functions: - `polynomial_order(::AbstractPolynomialZonotope)` -- return the polynomial order +- `expmat(::AbstractPolynomialZonotope)` -- return the exponent matrix (sparse PZ only) + By defining the functions - `ngens_dep` -- return the number of dependent generators @@ -44,6 +47,26 @@ julia> subtypes(AbstractPolynomialZonotope) """ abstract type AbstractPolynomialZonotope{N} <: LazySet{N} end +""" + expmat(P::AbstractPolynomialZonotope) + +Return the matrix of exponents of a polynomial zonotope. + +### Input + +- `P` -- polynomial zonotope + +### Output + +The matrix of exponents, where each column is a multidegree. + +### Notes + +In the exponent matrix, each row corresponds to a parameter (``αₖ`` in the +definition) and each column corresponds to a monomial. +""" +function expmat(::AbstractPolynomialZonotope) end + """ polynomial_order(P::AbstractPolynomialZonotope) diff --git a/src/Sets/SparsePolynomialZonotope.jl b/src/Sets/SparsePolynomialZonotope.jl index 2072ec74c0..78504ca1ac 100644 --- a/src/Sets/SparsePolynomialZonotope.jl +++ b/src/Sets/SparsePolynomialZonotope.jl @@ -1,4 +1,4 @@ -export SparsePolynomialZonotope, expmat, nparams, +export SparsePolynomialZonotope, nparams, genmat_dep, genmat_indep, indexvector, quadratic_map, remove_redundant_generators, reduce_order From f9b749ce61c0b1bed6b2bdc5c21ac534cd2a7c55 Mon Sep 17 00:00:00 2001 From: schillic Date: Fri, 12 Jul 2024 09:08:25 +0200 Subject: [PATCH 4/6] define 'nparams' for AbstractPolynomialZonotope --- .../interfaces/AbstractPolynomialZonotope.md | 1 + .../sets/SimpleSparsePolynomialZonotope.md | 2 +- docs/src/lib/sets/SparsePolynomialZonotope.md | 2 +- src/Interfaces/AbstractPolynomialZonotope.jl | 29 ++++++++++++++++-- .../SimpleSparsePolynomialZonotopeModule.jl | 6 ++-- .../SimpleSparsePolynomialZonotope/nparams.jl | 30 ------------------- src/Sets/SparsePolynomialZonotope.jl | 22 +------------- 7 files changed, 33 insertions(+), 59 deletions(-) delete mode 100644 src/Sets/SimpleSparsePolynomialZonotope/nparams.jl diff --git a/docs/src/lib/interfaces/AbstractPolynomialZonotope.md b/docs/src/lib/interfaces/AbstractPolynomialZonotope.md index 919e85f570..287aa2b86b 100644 --- a/docs/src/lib/interfaces/AbstractPolynomialZonotope.md +++ b/docs/src/lib/interfaces/AbstractPolynomialZonotope.md @@ -36,6 +36,7 @@ This interface defines the following functions: ```@docs dim(::AbstractPolynomialZonotope) ngens(::AbstractPolynomialZonotope) +nparams(::AbstractPolynomialZonotope) order(::AbstractPolynomialZonotope) ``` diff --git a/docs/src/lib/sets/SimpleSparsePolynomialZonotope.md b/docs/src/lib/sets/SimpleSparsePolynomialZonotope.md index 9f2e72e7ea..6f4b777170 100644 --- a/docs/src/lib/sets/SimpleSparsePolynomialZonotope.md +++ b/docs/src/lib/sets/SimpleSparsePolynomialZonotope.md @@ -16,7 +16,6 @@ convex_hull(::SimpleSparsePolynomialZonotope) expmat(::SimpleSparsePolynomialZonotope) genmat(::SimpleSparsePolynomialZonotope) ngens(::SimpleSparsePolynomialZonotope) -nparams(::SimpleSparsePolynomialZonotope) rand(::Type{SimpleSparsePolynomialZonotope}) remove_redundant_generators(::SimpleSparsePolynomialZonotope) linear_map(::AbstractMatrix, ::SimpleSparsePolynomialZonotope) @@ -36,4 +35,5 @@ PolynomialZonotope Inherited from [`AbstractPolynomialZonotope`](@ref): * [`dim`](@ref dim(::AbstractPolynomialZonotope)) +* [`nparams`](@ref dim(::AbstractPolynomialZonotope)) * [`order`](@ref dim(::AbstractPolynomialZonotope)) diff --git a/docs/src/lib/sets/SparsePolynomialZonotope.md b/docs/src/lib/sets/SparsePolynomialZonotope.md index e26d758822..9413c6e7c9 100644 --- a/docs/src/lib/sets/SparsePolynomialZonotope.md +++ b/docs/src/lib/sets/SparsePolynomialZonotope.md @@ -13,7 +13,6 @@ genmat_indep(::SparsePolynomialZonotope) indexvector(::SparsePolynomialZonotope) ngens_dep(::SparsePolynomialZonotope) ngens_indep(::SparsePolynomialZonotope) -nparams(::SparsePolynomialZonotope) polynomial_order(::SparsePolynomialZonotope) rand(::Type{SparsePolynomialZonotope}) remove_redundant_generators(::SparsePolynomialZonotope) @@ -26,4 +25,5 @@ translate(::SparsePolynomialZonotope, ::AbstractVector) Inherited from [`AbstractPolynomialZonotope`](@ref): * [`dim`](@ref dim(::AbstractPolynomialZonotope)) +* [`nparams`](@ref dim(::AbstractPolynomialZonotope)) * [`order`](@ref dim(::AbstractPolynomialZonotope)) diff --git a/src/Interfaces/AbstractPolynomialZonotope.jl b/src/Interfaces/AbstractPolynomialZonotope.jl index a6cebbac78..5e521398b9 100644 --- a/src/Interfaces/AbstractPolynomialZonotope.jl +++ b/src/Interfaces/AbstractPolynomialZonotope.jl @@ -1,11 +1,12 @@ export AbstractPolynomialZonotope, center, expmat, - polynomial_order, - order, ngens, ngens_dep, - ngens_indep + ngens_indep, + nparams, + order, + polynomial_order """ AbstractPolynomialZonotope{N} <: LazySet{N} @@ -116,6 +117,28 @@ A nonnegative integer representing the number of independent generators. """ function ngens_indep(::AbstractPolynomialZonotope) end +""" + nparams(P::AbstractPolynomialZonotope) + +Return the number of dependent parameters in the polynomial representation of a +polynomial zonotope. + +### Input + +- `P` -- polynomial zonotope + +### Output + +The number of dependent parameters in the polynomial representation. + +### Notes + +This number corresponds to the number of rows in the exponent matrix. +""" +function nparams(P::AbstractPolynomialZonotope) + return size(expmat(P), 1) +end + """ ngens(P::AbstractPolynomialZonotope) diff --git a/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl b/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl index 185fbfc9ff..6466f7634a 100644 --- a/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl +++ b/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl @@ -2,14 +2,15 @@ module SimpleSparsePolynomialZonotopeModule using Reexport -using ..LazySets: AbstractPolynomialZonotope, _remove_redundant_generators_polyzono +using ..LazySets: AbstractPolynomialZonotope, nparams, + _remove_redundant_generators_polyzono using Random: AbstractRNG, GLOBAL_RNG using ReachabilityBase.Distribution: reseed! using ReachabilityBase.Comparison: isapproxzero using LinearAlgebra: dot @reexport import ..API: convex_hull, center, isoperationtype, rand, linear_map -@reexport import ..LazySets: expmat, genmat, ngens, nparams, polynomial_order, +@reexport import ..LazySets: expmat, genmat, ngens, polynomial_order, remove_redundant_generators @reexport using ..API @@ -32,7 +33,6 @@ include("ngens_indep.jl") include("polynomial_order.jl") include("remove_redundant_generators.jl") include("expmat.jl") -include("nparams.jl") include("quadratic_map.jl") include("rand.jl") include("linear_map.jl") diff --git a/src/Sets/SimpleSparsePolynomialZonotope/nparams.jl b/src/Sets/SimpleSparsePolynomialZonotope/nparams.jl deleted file mode 100644 index ffa6d6ad83..0000000000 --- a/src/Sets/SimpleSparsePolynomialZonotope/nparams.jl +++ /dev/null @@ -1,30 +0,0 @@ -""" - nparams(P::SimpleSparsePolynomialZonotope) - -Return the number of parameters in the polynomial representation of a simple -sparse polynomial zonotope. - -### Input - -- `P` -- simple sparse polynomial zonotope - -### Output - -The number of parameters in the polynomial representation of P. - -### Notes - -This number corresponds to the number of rows in the exponent matrix ``E`` (`p` -in the mathematical set definition). - -### Examples - -```jldoctest -julia> S = SimpleSparsePolynomialZonotope([2.0, 0], [1 2;2 2.], [1 4;1 2]) -SimpleSparsePolynomialZonotope{Float64, Vector{Float64}, Matrix{Float64}, Matrix{Int64}}([2.0, 0.0], [1.0 2.0; 2.0 2.0], [1 4; 1 2]) - -julia> nparams(S) -2 -``` -""" -nparams(P::SSPZ) = size(P.E, 1) diff --git a/src/Sets/SparsePolynomialZonotope.jl b/src/Sets/SparsePolynomialZonotope.jl index 78504ca1ac..17c09e371e 100644 --- a/src/Sets/SparsePolynomialZonotope.jl +++ b/src/Sets/SparsePolynomialZonotope.jl @@ -1,4 +1,4 @@ -export SparsePolynomialZonotope, nparams, +export SparsePolynomialZonotope, genmat_dep, genmat_indep, indexvector, quadratic_map, remove_redundant_generators, reduce_order @@ -113,26 +113,6 @@ The number of independent generators. """ ngens_indep(P::SPZ) = size(P.GI, 2) -""" - nparams(P::SparsePolynomialZonotope) - -Return the number of dependent parameters in the polynomial representation of a -sparse polynomial zonotope. - -### Input - -- `P` -- sparse polynomial zonotope - -### Output - -The number of dependent parameters in the polynomial representation. - -### Notes - -This number corresponds to the number of rows in the exponent matrix ``E``. -""" -nparams(P::SPZ) = size(P.E, 1) - """ center(P::SparsePolynomialZonotope) From 2d72ed2e9b333133ba2a524b646410005deec590 Mon Sep 17 00:00:00 2001 From: schillic Date: Fri, 12 Jul 2024 09:58:24 +0200 Subject: [PATCH 5/6] make genmat_* interface functions for AbstractPolynomialZonotope --- .../interfaces/AbstractPolynomialZonotope.md | 6 ++- .../sets/SimpleSparsePolynomialZonotope.md | 2 + docs/src/lib/sets/SparsePolynomialZonotope.md | 4 +- src/Interfaces/AbstractPolynomialZonotope.jl | 43 ++++++++++++++++--- .../SimpleSparsePolynomialZonotopeModule.jl | 9 ++-- .../genmat_dep.jl | 1 + .../genmat_indep.jl | 1 + .../ngens_dep.jl | 1 - src/Sets/SparsePolynomialZonotope.jl | 33 +------------- 9 files changed, 54 insertions(+), 46 deletions(-) create mode 100644 src/Sets/SimpleSparsePolynomialZonotope/genmat_dep.jl create mode 100644 src/Sets/SimpleSparsePolynomialZonotope/genmat_indep.jl delete mode 100644 src/Sets/SimpleSparsePolynomialZonotope/ngens_dep.jl diff --git a/docs/src/lib/interfaces/AbstractPolynomialZonotope.md b/docs/src/lib/interfaces/AbstractPolynomialZonotope.md index 287aa2b86b..34892871ee 100644 --- a/docs/src/lib/interfaces/AbstractPolynomialZonotope.md +++ b/docs/src/lib/interfaces/AbstractPolynomialZonotope.md @@ -26,8 +26,8 @@ CurrentModule = LazySets ``` ```@docs expmat(::AbstractPolynomialZonotope) -ngens_dep(::AbstractPolynomialZonotope) -ngens_indep(::AbstractPolynomialZonotope) +genmat_dep(::AbstractPolynomialZonotope) +genmat_indep(::AbstractPolynomialZonotope) polynomial_order(::AbstractPolynomialZonotope) ``` @@ -36,6 +36,8 @@ This interface defines the following functions: ```@docs dim(::AbstractPolynomialZonotope) ngens(::AbstractPolynomialZonotope) +ngens_dep(::AbstractPolynomialZonotope) +ngens_indep(::AbstractPolynomialZonotope) nparams(::AbstractPolynomialZonotope) order(::AbstractPolynomialZonotope) ``` diff --git a/docs/src/lib/sets/SimpleSparsePolynomialZonotope.md b/docs/src/lib/sets/SimpleSparsePolynomialZonotope.md index 6f4b777170..ff256a41e2 100644 --- a/docs/src/lib/sets/SimpleSparsePolynomialZonotope.md +++ b/docs/src/lib/sets/SimpleSparsePolynomialZonotope.md @@ -35,5 +35,7 @@ PolynomialZonotope Inherited from [`AbstractPolynomialZonotope`](@ref): * [`dim`](@ref dim(::AbstractPolynomialZonotope)) +* [`ngens_dep`](@ref ngens_dep(::AbstractPolynomialZonotope)) +* [`ngens_indep`](@ref ngens_indep(::AbstractPolynomialZonotope)) * [`nparams`](@ref dim(::AbstractPolynomialZonotope)) * [`order`](@ref dim(::AbstractPolynomialZonotope)) diff --git a/docs/src/lib/sets/SparsePolynomialZonotope.md b/docs/src/lib/sets/SparsePolynomialZonotope.md index 9413c6e7c9..d8665686e8 100644 --- a/docs/src/lib/sets/SparsePolynomialZonotope.md +++ b/docs/src/lib/sets/SparsePolynomialZonotope.md @@ -11,8 +11,6 @@ expmat(::SparsePolynomialZonotope) genmat_dep(::SparsePolynomialZonotope) genmat_indep(::SparsePolynomialZonotope) indexvector(::SparsePolynomialZonotope) -ngens_dep(::SparsePolynomialZonotope) -ngens_indep(::SparsePolynomialZonotope) polynomial_order(::SparsePolynomialZonotope) rand(::Type{SparsePolynomialZonotope}) remove_redundant_generators(::SparsePolynomialZonotope) @@ -25,5 +23,7 @@ translate(::SparsePolynomialZonotope, ::AbstractVector) Inherited from [`AbstractPolynomialZonotope`](@ref): * [`dim`](@ref dim(::AbstractPolynomialZonotope)) +* [`ngens_dep`](@ref ngens_dep(::AbstractPolynomialZonotope)) +* [`ngens_indep`](@ref ngens_indep(::AbstractPolynomialZonotope)) * [`nparams`](@ref dim(::AbstractPolynomialZonotope)) * [`order`](@ref dim(::AbstractPolynomialZonotope)) diff --git a/src/Interfaces/AbstractPolynomialZonotope.jl b/src/Interfaces/AbstractPolynomialZonotope.jl index 5e521398b9..7f251b84b5 100644 --- a/src/Interfaces/AbstractPolynomialZonotope.jl +++ b/src/Interfaces/AbstractPolynomialZonotope.jl @@ -1,9 +1,8 @@ export AbstractPolynomialZonotope, center, expmat, - ngens, - ngens_dep, - ngens_indep, + genmat_dep, genmat_indep, + ngens, ngens_dep, ngens_indep, nparams, order, polynomial_order @@ -68,6 +67,36 @@ definition) and each column corresponds to a monomial. """ function expmat(::AbstractPolynomialZonotope) end +""" + genmat_dep(P::AbstractPolynomialZonotope) + +Return the matrix of dependent generators of a polynomial zonotope. + +### Input + +- `P` -- polynomial zonotope + +### Output + +The matrix of dependent generators. +""" +function genmat_dep(::AbstractPolynomialZonotope) end + +""" + genmat_indep(P::AbstractPolynomialZonotope) + +Return the matrix of independent generators of a polynomial zonotope. + +### Input + +- `P` -- polynomial zonotope + +### Output + +The matrix of independent generators. +""" +function genmat_indep(::AbstractPolynomialZonotope) end + """ polynomial_order(P::AbstractPolynomialZonotope) @@ -100,7 +129,9 @@ Determine the number of dependent generators of a polynomial zonotope. A nonnegative integer representing the number of dependent generators. """ -function ngens_dep(::AbstractPolynomialZonotope) end +function ngens_dep(P::AbstractPolynomialZonotope) + return size(genmat_dep(P), 2) +end """ ngens_indep(P::AbstractPolynomialZonotope) @@ -115,7 +146,9 @@ Determine the number of independent generators of a polynomial zonotope. A nonnegative integer representing the number of independent generators. """ -function ngens_indep(::AbstractPolynomialZonotope) end +function ngens_indep(P::AbstractPolynomialZonotope) + return size(genmat_indep(P), 2) +end """ nparams(P::AbstractPolynomialZonotope) diff --git a/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl b/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl index 6466f7634a..a7372a9475 100644 --- a/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl +++ b/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl @@ -2,7 +2,7 @@ module SimpleSparsePolynomialZonotopeModule using Reexport -using ..LazySets: AbstractPolynomialZonotope, nparams, +using ..LazySets: AbstractPolynomialZonotope, ngens_dep, nparams, _remove_redundant_generators_polyzono using Random: AbstractRNG, GLOBAL_RNG using ReachabilityBase.Distribution: reseed! @@ -10,8 +10,8 @@ using ReachabilityBase.Comparison: isapproxzero using LinearAlgebra: dot @reexport import ..API: convex_hull, center, isoperationtype, rand, linear_map -@reexport import ..LazySets: expmat, genmat, ngens, polynomial_order, - remove_redundant_generators +@reexport import ..LazySets: expmat, genmat, genmat_dep, genmat_indep, ngens, + polynomial_order, remove_redundant_generators @reexport using ..API export SimpleSparsePolynomialZonotope, @@ -27,8 +27,9 @@ include("center.jl") include("convex_hull.jl") include("genmat.jl") include("isoperationtype.jl") +include("genmat_dep.jl") +include("genmat_indep.jl") include("ngens.jl") -include("ngens_dep.jl") include("ngens_indep.jl") include("polynomial_order.jl") include("remove_redundant_generators.jl") diff --git a/src/Sets/SimpleSparsePolynomialZonotope/genmat_dep.jl b/src/Sets/SimpleSparsePolynomialZonotope/genmat_dep.jl new file mode 100644 index 0000000000..3cb6566e5d --- /dev/null +++ b/src/Sets/SimpleSparsePolynomialZonotope/genmat_dep.jl @@ -0,0 +1 @@ +genmat_dep(P::SSPZ) = P.G diff --git a/src/Sets/SimpleSparsePolynomialZonotope/genmat_indep.jl b/src/Sets/SimpleSparsePolynomialZonotope/genmat_indep.jl new file mode 100644 index 0000000000..1329ac40c9 --- /dev/null +++ b/src/Sets/SimpleSparsePolynomialZonotope/genmat_indep.jl @@ -0,0 +1 @@ +genmat_indep(P::SSPZ{N}) where {N} = Matrix{N}(undef, dim(P), 0) diff --git a/src/Sets/SimpleSparsePolynomialZonotope/ngens_dep.jl b/src/Sets/SimpleSparsePolynomialZonotope/ngens_dep.jl deleted file mode 100644 index df8bf8f506..0000000000 --- a/src/Sets/SimpleSparsePolynomialZonotope/ngens_dep.jl +++ /dev/null @@ -1 +0,0 @@ -ngens_dep(P::SSPZ) = size(P.G, 2) diff --git a/src/Sets/SparsePolynomialZonotope.jl b/src/Sets/SparsePolynomialZonotope.jl index 17c09e371e..a335e35da1 100644 --- a/src/Sets/SparsePolynomialZonotope.jl +++ b/src/Sets/SparsePolynomialZonotope.jl @@ -1,6 +1,5 @@ export SparsePolynomialZonotope, - genmat_dep, genmat_indep, indexvector, quadratic_map, - remove_redundant_generators, reduce_order + indexvector """ SparsePolynomialZonotope{N, VN<:AbstractVector{N}, MN<:AbstractMatrix{N}, @@ -83,36 +82,6 @@ function isoperationtype(P::Type{<:SparsePolynomialZonotope}) return false end -""" - ngens_dep(P::SparsePolynomialZonotope) - -Return the number of dependent generators of a sparse polynomial zonotope. - -### Input - -- `P` -- sparse polynomial zonotope - -### Output - -The number of dependent generators. -""" -ngens_dep(P::SPZ) = size(P.G, 2) - -""" - ngens_indep(P::SparsePolynomialZonotope) - -Return the number of independent generators of a sparse polynomial zonotope. - -### Input - -- `P` -- sparse polynomial zonotope - -### Output - -The number of independent generators. -""" -ngens_indep(P::SPZ) = size(P.GI, 2) - """ center(P::SparsePolynomialZonotope) From a7cc39c13cde1f123af07c633e0c645e29fec1c9 Mon Sep 17 00:00:00 2001 From: schillic Date: Fri, 12 Jul 2024 10:23:09 +0200 Subject: [PATCH 6/6] add AbstractSparsePolynomialZonotope interface --- docs/make.jl | 1 + .../interfaces/AbstractPolynomialZonotope.md | 10 +- .../AbstractSparsePolynomialZonotope.md | 33 +++++ .../sets/SimpleSparsePolynomialZonotope.md | 6 +- docs/src/lib/sets/SparsePolynomialZonotope.md | 7 +- src/Interfaces/AbstractPolynomialZonotope.jl | 122 +--------------- .../AbstractSparsePolynomialZonotope.jl | 133 ++++++++++++++++++ src/LazySets.jl | 1 + .../SimpleSparsePolynomialZonotope.jl | 4 +- .../SimpleSparsePolynomialZonotopeModule.jl | 2 +- src/Sets/SparsePolynomialZonotope.jl | 4 +- 11 files changed, 189 insertions(+), 134 deletions(-) create mode 100644 docs/src/lib/interfaces/AbstractSparsePolynomialZonotope.md create mode 100644 src/Interfaces/AbstractSparsePolynomialZonotope.jl diff --git a/docs/make.jl b/docs/make.jl index ee512a14a0..9a368084d2 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -50,6 +50,7 @@ makedocs(; sitename="LazySets.jl", "lib/interfaces/AbstractSingleton.md", "lib/interfaces/AbstractAffineMap.md", "lib/interfaces/AbstractPolynomialZonotope.md", + "lib/interfaces/AbstractSparsePolynomialZonotope.md", "lib/interfaces/AbstractBallp.md" # ], diff --git a/docs/src/lib/interfaces/AbstractPolynomialZonotope.md b/docs/src/lib/interfaces/AbstractPolynomialZonotope.md index 34892871ee..914e5906b5 100644 --- a/docs/src/lib/interfaces/AbstractPolynomialZonotope.md +++ b/docs/src/lib/interfaces/AbstractPolynomialZonotope.md @@ -25,9 +25,8 @@ center(::LazySet) CurrentModule = LazySets ``` ```@docs -expmat(::AbstractPolynomialZonotope) -genmat_dep(::AbstractPolynomialZonotope) -genmat_indep(::AbstractPolynomialZonotope) +ngens_dep(::AbstractPolynomialZonotope) +ngens_indep(::AbstractPolynomialZonotope) polynomial_order(::AbstractPolynomialZonotope) ``` @@ -36,14 +35,9 @@ This interface defines the following functions: ```@docs dim(::AbstractPolynomialZonotope) ngens(::AbstractPolynomialZonotope) -ngens_dep(::AbstractPolynomialZonotope) -ngens_indep(::AbstractPolynomialZonotope) -nparams(::AbstractPolynomialZonotope) order(::AbstractPolynomialZonotope) ``` ## Implementations * [Dense polynomial zonotope (DensePolynomialZonotope)](@ref def_DensePolynomialZonotope) -* [Sparse polynomial zonotope (SparsePolynomialZonotope)](@ref def_SparsePolynomialZonotope) -* [Simplified sparse polynomial zonotope (SimpleSparsePolynomialZonotope)](@ref def_SimpleSparsePolynomialZonotope) diff --git a/docs/src/lib/interfaces/AbstractSparsePolynomialZonotope.md b/docs/src/lib/interfaces/AbstractSparsePolynomialZonotope.md new file mode 100644 index 0000000000..37d62c5c1e --- /dev/null +++ b/docs/src/lib/interfaces/AbstractSparsePolynomialZonotope.md @@ -0,0 +1,33 @@ +```@contents +Pages = ["AbstractSparsePolynomialZonotope.md"] +Depth = 3 +``` + +```@meta +CurrentModule = LazySets +``` + +# [Sparse polynomial zonotope sets (AbstractSparsePolynomialZonotope)](@id def_AbstractSparsePolynomialZonotope) + +```@docs +AbstractSparsePolynomialZonotope +``` + +This interface requires to implement the following functions: + +```@docs +expmat(::AbstractSparsePolynomialZonotope) +genmat_dep(::AbstractSparsePolynomialZonotope) +genmat_indep(::AbstractSparsePolynomialZonotope) +``` + +This interface defines the following functions: + +```@docs +nparams(::AbstractSparsePolynomialZonotope) +``` + +## Implementations + +* [Sparse polynomial zonotope (SparsePolynomialZonotope)](@ref def_SparsePolynomialZonotope) +* [Simplified sparse polynomial zonotope (SimpleSparsePolynomialZonotope)](@ref def_SimpleSparsePolynomialZonotope) diff --git a/docs/src/lib/sets/SimpleSparsePolynomialZonotope.md b/docs/src/lib/sets/SimpleSparsePolynomialZonotope.md index ff256a41e2..40594b0c21 100644 --- a/docs/src/lib/sets/SimpleSparsePolynomialZonotope.md +++ b/docs/src/lib/sets/SimpleSparsePolynomialZonotope.md @@ -35,7 +35,9 @@ PolynomialZonotope Inherited from [`AbstractPolynomialZonotope`](@ref): * [`dim`](@ref dim(::AbstractPolynomialZonotope)) +* [`order`](@ref order(::AbstractPolynomialZonotope)) + +Inherited from [`AbstractSparsePolynomialZonotope`](@ref): * [`ngens_dep`](@ref ngens_dep(::AbstractPolynomialZonotope)) * [`ngens_indep`](@ref ngens_indep(::AbstractPolynomialZonotope)) -* [`nparams`](@ref dim(::AbstractPolynomialZonotope)) -* [`order`](@ref dim(::AbstractPolynomialZonotope)) +* [`nparams`](@ref nparams(::AbstractPolynomialZonotope)) diff --git a/docs/src/lib/sets/SparsePolynomialZonotope.md b/docs/src/lib/sets/SparsePolynomialZonotope.md index d8665686e8..c651a4b82c 100644 --- a/docs/src/lib/sets/SparsePolynomialZonotope.md +++ b/docs/src/lib/sets/SparsePolynomialZonotope.md @@ -23,7 +23,10 @@ translate(::SparsePolynomialZonotope, ::AbstractVector) Inherited from [`AbstractPolynomialZonotope`](@ref): * [`dim`](@ref dim(::AbstractPolynomialZonotope)) +* [`ngens`](@ref ngens(::AbstractPolynomialZonotope)) +* [`order`](@ref order(::AbstractPolynomialZonotope)) + +Inherited from [`AbstractSparsePolynomialZonotope`](@ref): * [`ngens_dep`](@ref ngens_dep(::AbstractPolynomialZonotope)) * [`ngens_indep`](@ref ngens_indep(::AbstractPolynomialZonotope)) -* [`nparams`](@ref dim(::AbstractPolynomialZonotope)) -* [`order`](@ref dim(::AbstractPolynomialZonotope)) +* [`nparams`](@ref nparams(::AbstractPolynomialZonotope)) diff --git a/src/Interfaces/AbstractPolynomialZonotope.jl b/src/Interfaces/AbstractPolynomialZonotope.jl index 7f251b84b5..ba272071ea 100644 --- a/src/Interfaces/AbstractPolynomialZonotope.jl +++ b/src/Interfaces/AbstractPolynomialZonotope.jl @@ -1,9 +1,6 @@ export AbstractPolynomialZonotope, center, - expmat, - genmat_dep, genmat_indep, ngens, ngens_dep, ngens_indep, - nparams, order, polynomial_order @@ -22,81 +19,21 @@ Every concrete `AbstractPolynomialZonotope` must define the following functions: - `polynomial_order(::AbstractPolynomialZonotope)` -- return the polynomial order -- `expmat(::AbstractPolynomialZonotope)` -- return the exponent matrix (sparse PZ only) - -By defining the functions - - `ngens_dep` -- return the number of dependent generators - `ngens_indep` -- return the number of independent generators -the following functions are also available (alternatively, these functions can -be defined directly): - -- `order(::AbstractPolynomialZonotope)` -- return the order - -- `ngens(::AbstractPolynomialZonotope)` -- return the total number of generators +The subtypes of `AbstractPolynomialZonotope` (including abstract interfaces): ```jldoctest; setup = :(using LazySets: subtypes) julia> subtypes(AbstractPolynomialZonotope) -3-element Vector{Any}: +2-element Vector{Any}: + AbstractSparsePolynomialZonotope DensePolynomialZonotope - SimpleSparsePolynomialZonotope - SparsePolynomialZonotope ``` """ abstract type AbstractPolynomialZonotope{N} <: LazySet{N} end -""" - expmat(P::AbstractPolynomialZonotope) - -Return the matrix of exponents of a polynomial zonotope. - -### Input - -- `P` -- polynomial zonotope - -### Output - -The matrix of exponents, where each column is a multidegree. - -### Notes - -In the exponent matrix, each row corresponds to a parameter (``αₖ`` in the -definition) and each column corresponds to a monomial. -""" -function expmat(::AbstractPolynomialZonotope) end - -""" - genmat_dep(P::AbstractPolynomialZonotope) - -Return the matrix of dependent generators of a polynomial zonotope. - -### Input - -- `P` -- polynomial zonotope - -### Output - -The matrix of dependent generators. -""" -function genmat_dep(::AbstractPolynomialZonotope) end - -""" - genmat_indep(P::AbstractPolynomialZonotope) - -Return the matrix of independent generators of a polynomial zonotope. - -### Input - -- `P` -- polynomial zonotope - -### Output - -The matrix of independent generators. -""" -function genmat_indep(::AbstractPolynomialZonotope) end - """ polynomial_order(P::AbstractPolynomialZonotope) @@ -129,9 +66,7 @@ Determine the number of dependent generators of a polynomial zonotope. A nonnegative integer representing the number of dependent generators. """ -function ngens_dep(P::AbstractPolynomialZonotope) - return size(genmat_dep(P), 2) -end +function ngens_dep(::AbstractPolynomialZonotope) end """ ngens_indep(P::AbstractPolynomialZonotope) @@ -146,31 +81,7 @@ Determine the number of independent generators of a polynomial zonotope. A nonnegative integer representing the number of independent generators. """ -function ngens_indep(P::AbstractPolynomialZonotope) - return size(genmat_indep(P), 2) -end - -""" - nparams(P::AbstractPolynomialZonotope) - -Return the number of dependent parameters in the polynomial representation of a -polynomial zonotope. - -### Input - -- `P` -- polynomial zonotope - -### Output - -The number of dependent parameters in the polynomial representation. - -### Notes - -This number corresponds to the number of rows in the exponent matrix. -""" -function nparams(P::AbstractPolynomialZonotope) - return size(expmat(P), 1) -end +function ngens_indep(::AbstractPolynomialZonotope) end """ ngens(P::AbstractPolynomialZonotope) @@ -224,26 +135,3 @@ Return the ambient dimension of a polynomial zonotope. An integer representing the ambient dimension of the polynomial zonotope. """ dim(PZ::AbstractPolynomialZonotope) = length(center(PZ)) - -function _remove_redundant_generators_polyzono(c, G, E) - Gnew = Matrix{eltype(G)}(undef, size(G, 1), 0) - Enew = Matrix{eltype(E)}(undef, size(E, 1), 0) - cnew = copy(c) - - visited_exps = Dict{Vector{Int},Int}() - @inbounds for (gi, ei) in zip(eachcol(G), eachcol(E)) - all(isapproxzero, gi) && continue - if iszero(ei) - cnew += gi - elseif haskey(visited_exps, ei) # repeated exponent - idx = visited_exps[ei] - Gnew[:, idx] += gi - else - Gnew = hcat(Gnew, gi) - Enew = hcat(Enew, ei) - visited_exps[ei] = size(Enew, 2) - end - end - - return cnew, Gnew, Enew -end diff --git a/src/Interfaces/AbstractSparsePolynomialZonotope.jl b/src/Interfaces/AbstractSparsePolynomialZonotope.jl new file mode 100644 index 0000000000..ecd2cba2cb --- /dev/null +++ b/src/Interfaces/AbstractSparsePolynomialZonotope.jl @@ -0,0 +1,133 @@ +export AbstractSparsePolynomialZonotope, + expmat, + genmat_dep, genmat_indep, + nparams + +""" + AbstractSparsePolynomialZonotope{N} <: AbstractPolynomialZonotope{N} + +Abstract type for sparse polynomial zonotope sets. + +### Notes + +Every concrete `AbstractSparsePolynomialZonotope` must define the following functions: + +- `expmat(::AbstractSparsePolynomialZonotope)` -- return the exponent matrix (sparse PZ only) + +- `genmat_dep(::AbstractSparsePolynomialZonotope)` -- return the matrix of dependent generators + +- `genmat_indep(::AbstractSparsePolynomialZonotope)` -- return the matrix of independent generators + +The subtypes of `AbstractSparsePolynomialZonotope` (including abstract interfaces): + +```jldoctest; setup = :(using LazySets: subtypes) +julia> subtypes(AbstractSparsePolynomialZonotope) +2-element Vector{Any}: + SimpleSparsePolynomialZonotope + SparsePolynomialZonotope +``` +""" +abstract type AbstractSparsePolynomialZonotope{N} <: AbstractPolynomialZonotope{N} end + +""" + expmat(P::AbstractSparsePolynomialZonotope) + +Return the matrix of exponents of a sparse polynomial zonotope. + +### Input + +- `P` -- sparse polynomial zonotope + +### Output + +The matrix of exponents, where each column is a multidegree. + +### Notes + +In the exponent matrix, each row corresponds to a parameter (``αₖ`` in the +definition) and each column corresponds to a monomial. +""" +function expmat(::AbstractSparsePolynomialZonotope) end + +""" + genmat_dep(P::AbstractSparsePolynomialZonotope) + +Return the matrix of dependent generators of a sparse polynomial zonotope. + +### Input + +- `P` -- sparse polynomial zonotope + +### Output + +The matrix of dependent generators. +""" +function genmat_dep(::AbstractSparsePolynomialZonotope) end + +""" + genmat_indep(P::AbstractSparsePolynomialZonotope) + +Return the matrix of independent generators of a sparse polynomial zonotope. + +### Input + +- `P` -- sparse polynomial zonotope + +### Output + +The matrix of independent generators. +""" +function genmat_indep(::AbstractSparsePolynomialZonotope) end + +function ngens_dep(P::AbstractSparsePolynomialZonotope) + return size(genmat_dep(P), 2) +end + +function ngens_indep(P::AbstractSparsePolynomialZonotope) + return size(genmat_indep(P), 2) +end + +""" + nparams(P::AbstractSparsePolynomialZonotope) + +Return the number of dependent parameters in the polynomial representation of a +sparse polynomial zonotope. + +### Input + +- `P` -- sparse polynomial zonotope + +### Output + +The number of dependent parameters in the polynomial representation. + +### Notes + +This number corresponds to the number of rows in the exponent matrix. +""" +function nparams(P::AbstractSparsePolynomialZonotope) + return size(expmat(P), 1) +end + +function _remove_redundant_generators_polyzono(c, G, E) + Gnew = Matrix{eltype(G)}(undef, size(G, 1), 0) + Enew = Matrix{eltype(E)}(undef, size(E, 1), 0) + cnew = copy(c) + + visited_exps = Dict{Vector{Int},Int}() + @inbounds for (gi, ei) in zip(eachcol(G), eachcol(E)) + all(isapproxzero, gi) && continue + if iszero(ei) + cnew += gi + elseif haskey(visited_exps, ei) # repeated exponent + idx = visited_exps[ei] + Gnew[:, idx] += gi + else + Gnew = hcat(Gnew, gi) + Enew = hcat(Enew, ei) + visited_exps[ei] = size(Enew, 2) + end + end + + return cnew, Gnew, Enew +end diff --git a/src/LazySets.jl b/src/LazySets.jl index 851f683b29..c5146efdd5 100644 --- a/src/LazySets.jl +++ b/src/LazySets.jl @@ -76,6 +76,7 @@ include("Interfaces/LazySet.jl") include("Interfaces/ConvexSet.jl") # include("Interfaces/AbstractStar.jl") include("Interfaces/AbstractPolynomialZonotope.jl") +include("Interfaces/AbstractSparsePolynomialZonotope.jl") include("Interfaces/AbstractPolyhedron.jl") include("Sets/HalfSpace.jl") # must come before AbstractPolyhedron_functions include("Interfaces/AbstractPolyhedron_functions.jl") diff --git a/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotope.jl b/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotope.jl index 0a23af8736..76f3e036d4 100644 --- a/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotope.jl +++ b/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotope.jl @@ -2,7 +2,7 @@ SimpleSparsePolynomialZonotope{N, VN<:AbstractVector{N}, MN<:AbstractMatrix{N}, ME<:AbstractMatrix{Int}} - <: AbstractPolynomialZonotope{N} + <: AbstractSparsePolynomialZonotope{N} Type that represents a sparse polynomial zonotope that is *simple* in the sense that there is no distinction between independent and dependent generators. @@ -37,7 +37,7 @@ JuliaReach and JuliaIntervals Days 3, 2021. struct SimpleSparsePolynomialZonotope{N,VN<:AbstractVector{N}, MN<:AbstractMatrix{N}, ME<:AbstractMatrix{Int}} <: - AbstractPolynomialZonotope{N} + AbstractSparsePolynomialZonotope{N} c::VN G::MN E::ME diff --git a/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl b/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl index a7372a9475..832323985e 100644 --- a/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl +++ b/src/Sets/SimpleSparsePolynomialZonotope/SimpleSparsePolynomialZonotopeModule.jl @@ -2,7 +2,7 @@ module SimpleSparsePolynomialZonotopeModule using Reexport -using ..LazySets: AbstractPolynomialZonotope, ngens_dep, nparams, +using ..LazySets: AbstractSparsePolynomialZonotope, ngens_dep, nparams, _remove_redundant_generators_polyzono using Random: AbstractRNG, GLOBAL_RNG using ReachabilityBase.Distribution: reseed! diff --git a/src/Sets/SparsePolynomialZonotope.jl b/src/Sets/SparsePolynomialZonotope.jl index a335e35da1..085eace474 100644 --- a/src/Sets/SparsePolynomialZonotope.jl +++ b/src/Sets/SparsePolynomialZonotope.jl @@ -6,7 +6,7 @@ export SparsePolynomialZonotope, MNI<:AbstractMatrix{N}, ME<:AbstractMatrix{Int}, VI<:AbstractVector{Int}} - <: AbstractPolynomialZonotope{N} + <: AbstractSparsePolynomialZonotope{N} Type that represents a sparse polynomial zonotope. @@ -47,7 +47,7 @@ struct SparsePolynomialZonotope{N, MN<:AbstractMatrix{N}, MNI<:AbstractMatrix{N}, ME<:AbstractMatrix{Int}, - VI<:AbstractVector{Int}} <: AbstractPolynomialZonotope{N} + VI<:AbstractVector{Int}} <: AbstractSparsePolynomialZonotope{N} c::VN G::MN GI::MNI