Skip to content

Commit

Permalink
Merge pull request #3132 from JuliaReach/schillic/linear_combination
Browse files Browse the repository at this point in the history
Revise linear_combination code
  • Loading branch information
schillic authored Oct 17, 2022
2 parents 93aa7bc + f61c370 commit d9678f4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/ConcreteOperations/linear_combination.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export linear_combination

"""
linear_combination(P1::SimpleSparsePolynomialZonotope, P2::SimpleSparsePolynomialZonotope)
linear_combination(P1::SimpleSparsePolynomialZonotope,
P2::SimpleSparsePolynomialZonotope)
Compute the linear combination of simple sparse polynomial zonotopes `P1` and `P2`.
Compute the linear combination of two simple sparse polynomial zonotopes.
### Input
Expand All @@ -21,14 +22,20 @@ The linear combination of two sets ``P₁`` and ``P₂`` is defined as
```math
\\{1/2(1+λ)p₁ + 1/2(1-λ)p₂ | p₁ ∈ P₁, p₂ ∈ P₂, λ ∈ [-1, 1]\\}.
```
This method implements the algorithm described in Proposition 3.1.25 of [1].
[1] N. Kochdumper. *Extensions of polynomial zonotopes and their application to
verification of cyber-physical systems*. 2021.
"""
function linear_combination(P1::SimpleSparsePolynomialZonotope, P2::SimpleSparsePolynomialZonotope)
function linear_combination(P1::SimpleSparsePolynomialZonotope,
P2::SimpleSparsePolynomialZonotope)
c1, c2 = center(P1), center(P2)
G1, G2 = genmat(P1), genmat(P2)
E1, E2 = expmat(P1), expmat(P2)

c = 0.5 * (c1 + c2)
G = 0.5 * hcat(c1 - c2, G1, G1, G2, -G2)
c = (c1 + c2) / 2
G = hcat(c1 - c2, G1, G1, G2, -G2) / 2

N = promote_type(eltype(E1), eltype(E2))
E = hcat(vcat(zeros(N, nparams(P1) + nparams(P2)), one(N)),
Expand Down

0 comments on commit d9678f4

Please sign in to comment.