Skip to content
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
11 changes: 10 additions & 1 deletion docs/src/lib/sets/DensePolynomialZonotope.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
```@meta
CurrentModule = LazySets
CurrentModule = LazySets.DensePolynomialZonotopeModule
```

# [Polynomial zonotope (DensePolynomialZonotope)](@id def_DensePolynomialZonotope)

```@docs
DensePolynomialZonotope
```

## Operations

```@docs
center(::DensePolynomialZonotope)
ngens_dep(::DensePolynomialZonotope)
ngens_indep(::DensePolynomialZonotope)
Expand All @@ -14,6 +19,10 @@ linear_map(::AbstractMatrix, ::DensePolynomialZonotope)
scale!(::Real, ::DensePolynomialZonotope)
```

```@meta
CurrentModule = LazySets
```

Inherited from [`AbstractPolynomialZonotope`](@ref):
* [`dim`](@ref dim(::AbstractPolynomialZonotope))
* [`order`](@ref dim(::AbstractPolynomialZonotope))
4 changes: 3 additions & 1 deletion src/LazySets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ include("Sets/Ballp/BallpModule.jl")
include("Sets/Ellipsoid/EllipsoidModule.jl")
@reexport using ..EllipsoidModule: Ellipsoid, shape_matrix

include("Sets/DensePolynomialZonotope.jl")
include("Sets/DensePolynomialZonotope/DensePolynomialZonotopeModule.jl")
@reexport using ..DensePolynomialZonotopeModule: DensePolynomialZonotope

include("Sets/HParallelotope.jl")
include("Sets/HPolygon.jl")
include("Sets/HPolygonOpt.jl")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export DensePolynomialZonotope

"""
DensePolynomialZonotope{N, VT, VMT, MT} <: AbstractPolynomialZonotope{N}

Expand Down Expand Up @@ -83,123 +81,3 @@ struct DensePolynomialZonotope{N,VT,VMT,MT} <: AbstractPolynomialZonotope{N}
return new{N,VT,VMT,MT}(c, E, F, G)
end
end

isoperationtype(::Type{<:DensePolynomialZonotope}) = false

"""
center(P::DensePolynomialZonotope)

Return the center of a polynomial zonotope.

### Input

- `P` -- polynomial zonotope

### Output

The center of `P`.
"""
center(P::DensePolynomialZonotope) = P.c

"""
polynomial_order(P::DensePolynomialZonotope)

Polynomial order of a polynomial zonotope.

### Input

- `P` -- polynomial zonotope

## Output

The polynomial order, defined as the maximal power of the scale factors ``β_i``.
It is usually denoted ``η``.
"""
polynomial_order(P::DensePolynomialZonotope) = length(P.E)

"""
ngens_indep(P::DensePolynomialZonotope)

Return the number of independent generators of a polynomial zonotope.

### Input

- `P` -- polynomial zonotope

### Output

The number of independent generators of `P`.
"""
ngens_indep(P::DensePolynomialZonotope) = size(P.G, 2)

"""
ngens_dep(P::DensePolynomialZonotope)

Return the number of dependent generators of a polynomial zonotope.

### Input

- `P` -- polynomial zonotope

### Output

The number of dependent generators of `P`.
"""
function ngens_dep(P::DensePolynomialZonotope)
η = polynomial_order(P) # polynomial order
p = size(P.E[1], 2) # number of dependent factors
return sum(i -> binomial(p + i - 1, i), 1:η)
end

"""
linear_map(M::AbstractMatrix, P::DensePolynomialZonotope)

Return the linear map of a polynomial zonotope.

### Input

- `M` -- matrix
- `P` -- polynomial zonotope

## Output

A polynomial zonotope.

### Algorithm

The result's starting point and generators are those of `P` multiplied by the
matrix `M`.
"""
function linear_map(M::AbstractMatrix, P::DensePolynomialZonotope)
c = M * P.c
E = [M * Ei for Ei in P.E]
F = [M * Fi for Fi in P.F]
G = M * P.G
return DensePolynomialZonotope(c, E, F, G)
end

"""
scale!(α::Real, P::DensePolynomialZonotope)

Scale a polynomial zonotope modified by a scale factor in-place.

### Input

- `α` -- scaling factor
- `P` -- polynomial zonotope

## Output

The modified polynomial zonotope.

### Algorithm

The center and generators are scaled by ``α``.
"""
function scale!(α::Real, P::DensePolynomialZonotope)
P.c .*= α
P.E .*= α
P.F .*= α
P.G .*= α
return P
end
24 changes: 24 additions & 0 deletions src/Sets/DensePolynomialZonotope/DensePolynomialZonotopeModule.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module DensePolynomialZonotopeModule

using Reexport

using ..LazySets: AbstractPolynomialZonotope

@reexport import ..API: center, isoperationtype, linear_map, scale!
@reexport import ..LazySets: ngens_dep, ngens_indep, polynomial_order
@reexport using ..API

export DensePolynomialZonotope

include("DensePolynomialZonotope.jl")

include("center.jl")
include("isoperationtype.jl")
include("linear_map.jl")
include("scale.jl")

include("ngens_dep.jl")
include("ngens_indep.jl")
include("polynomial_order.jl")

end # module
14 changes: 14 additions & 0 deletions src/Sets/DensePolynomialZonotope/center.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
center(P::DensePolynomialZonotope)

Return the center of a polynomial zonotope.

### Input

- `P` -- polynomial zonotope

### Output

The center of `P`.
"""
center(P::DensePolynomialZonotope) = P.c
1 change: 1 addition & 0 deletions src/Sets/DensePolynomialZonotope/isoperationtype.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
isoperationtype(::Type{<:DensePolynomialZonotope}) = false
26 changes: 26 additions & 0 deletions src/Sets/DensePolynomialZonotope/linear_map.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
linear_map(M::AbstractMatrix, P::DensePolynomialZonotope)

Return the linear map of a polynomial zonotope.

### Input

- `M` -- matrix
- `P` -- polynomial zonotope

## Output

A polynomial zonotope.

### Algorithm

The result's starting point and generators are those of `P` multiplied by the
matrix `M`.
"""
function linear_map(M::AbstractMatrix, P::DensePolynomialZonotope)
c = M * P.c
E = [M * Ei for Ei in P.E]
F = [M * Fi for Fi in P.F]
G = M * P.G
return DensePolynomialZonotope(c, E, F, G)
end
18 changes: 18 additions & 0 deletions src/Sets/DensePolynomialZonotope/ngens_dep.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
ngens_dep(P::DensePolynomialZonotope)

Return the number of dependent generators of a polynomial zonotope.

### Input

- `P` -- polynomial zonotope

### Output

The number of dependent generators of `P`.
"""
function ngens_dep(P::DensePolynomialZonotope)
η = polynomial_order(P) # polynomial order
p = size(P.E[1], 2) # number of dependent factors
return sum(i -> binomial(p + i - 1, i), 1:η)
end
14 changes: 14 additions & 0 deletions src/Sets/DensePolynomialZonotope/ngens_indep.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
ngens_indep(P::DensePolynomialZonotope)

Return the number of independent generators of a polynomial zonotope.

### Input

- `P` -- polynomial zonotope

### Output

The number of independent generators of `P`.
"""
ngens_indep(P::DensePolynomialZonotope) = size(P.G, 2)
15 changes: 15 additions & 0 deletions src/Sets/DensePolynomialZonotope/polynomial_order.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
polynomial_order(P::DensePolynomialZonotope)

Polynomial order of a polynomial zonotope.

### Input

- `P` -- polynomial zonotope

## Output

The polynomial order, defined as the maximal power of the scale factors ``β_i``.
It is usually denoted ``η``.
"""
polynomial_order(P::DensePolynomialZonotope) = length(P.E)
25 changes: 25 additions & 0 deletions src/Sets/DensePolynomialZonotope/scale.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
scale!(α::Real, P::DensePolynomialZonotope)

Scale a polynomial zonotope modified by a scale factor in-place.

### Input

- `α` -- scaling factor
- `P` -- polynomial zonotope

## Output

The modified polynomial zonotope.

### Algorithm

The center and generators are scaled by ``α``.
"""
function scale!(α::Real, P::DensePolynomialZonotope)
P.c .*= α
P.E .*= α
P.F .*= α
P.G .*= α
return P
end
3 changes: 3 additions & 0 deletions test/Sets/DensePolynomialZonotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ for N in [Float64, Float32, Rational{Int}]
z = Zonotope(N[1.0, 2.0], Matrix(N(1)I, 2, 2))
minkowski_sum(P, z)
minkowski_sum(z, P)

# isoperationtype
@test !isoperationtype(DensePolynomialZonotope)
end