Skip to content

Commit e264893

Browse files
committed
Implement block elimination
1 parent f582320 commit e264893

File tree

2 files changed

+74
-3
lines changed

2 files changed

+74
-3
lines changed

src/liftedrep.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,17 @@ end
1818
FullDim(rep::LiftedHRepresentation) = size(rep.A, 2) - 1
1919

2020
similar_type(::Type{LiftedHRepresentation{S, MT}}, ::FullDim, ::Type{T}) where {S, T, MT} = LiftedHRepresentation{T, similar_type(MT, T)}
21-
hvectortype(p::Type{LiftedHRepresentation{T, MT}}) where {T, MT} = vectortype(MT)
21+
hvectortype(::Type{LiftedHRepresentation{T, MT}}) where {T, MT} = vectortype(MT)
22+
fulltype(::Type{LiftedHRepresentation{T,MT}}) where {T,MT} = LiftedHRepresentation{T,MT}
23+
dualtype(::Type{LiftedHRepresentation{T,MT}}) where {T,MT} = LiftedVRepresentation{T,MT}
24+
function dualfullspace(::LiftedHRepresentation, d::FullDim, ::Type{T}) where {T}
25+
N = fulldim(d)
26+
return LiftedVRepresentation{T}(
27+
[SparseArrays.spzeros(T, N) one(T) * I],
28+
BitSet(1:N),
29+
)
30+
end
31+
2232

2333
LiftedHRepresentation{T}(A::AbstractMatrix{T}, linset::BitSet=BitSet()) where {T} = LiftedHRepresentation{T, typeof(A)}(A, linset)
2434
LiftedHRepresentation{T}(A::AbstractMatrix, linset::BitSet=BitSet()) where {T} = LiftedHRepresentation{T}(AbstractMatrix{T}(A), linset)

src/projection.jl

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,56 @@ struct FourierMotzkin <: EliminationAlgorithm end
2020
BlockElimination
2121
2222
Computation of the projection by computing the H-representation and applying the block elimination algorithm to it.
23+
24+
The idea is as follows.
25+
Consider a H-representation given by ``Ax + By \\le c``.
26+
For any ``d``, the projection on the `x` variables has
27+
belongs to the halfspace ``d^\\top x \\le \\delta`` where ``\\delta``
28+
is
29+
```math
30+
\\begin{aligned}
31+
\\max \\; & d^\\top x \\
32+
\\text{s.t.} & A x + By \\le c \\
33+
\\end{aligned}
34+
```
35+
By duality, this is equal to
36+
```math
37+
\\begin{aligned}
38+
\\min \\; & c^\\top \\nu \\
39+
\\text{s.t.} & A^\\top \\nu = d \\
40+
& B^\\top \\nu = 0 \\
41+
& \\nu \\ge 0
42+
\\end{aligned}
43+
```
44+
Let `R` be the matrix for which the columns are the extreme rays of the
45+
polyhedron with defined by
46+
``B^\\top \\nu = 0, \\nu \\ge 0``.
47+
The program can be rewritten as
48+
```math
49+
\\begin{aligned}
50+
\\min \\; & c^\\top \\nu \\
51+
\\text{s.t.} & A^\\top \\nu = d \\
52+
& \\nu = R\\lambda \\
53+
& \\lambda \\ge 0
54+
\\end{aligned}
55+
```
56+
which is equivalent to
57+
```math
58+
\\begin{aligned}
59+
\\min \\; & c^\\top R \\lambda \\
60+
\\text{s.t.} & A^\\top R \\lambda = d \\
61+
& \\lambda \\ge 0
62+
\\end{aligned}
63+
```
64+
Dualizing, we obtain
65+
```math
66+
\\begin{aligned}
67+
\\max \\; & d^\\top x \\
68+
\\text{s.t.} & R^\\top A x \\le R^\\top c \\
69+
\\end{aligned}
70+
```
71+
where we see that ``R^\\top A x \\le R^\\top c``
72+
is the H-representation of the polyhedron.
2373
"""
2474
struct BlockElimination <: EliminationAlgorithm end
2575

@@ -49,8 +99,19 @@ project(p::Polyhedron, pset, algo) = eliminate(p, setdiff(1:fulldim(p), pset), a
4999

50100
supportselimination(p::Polyhedron, ::FourierMotzkin) = false
51101
eliminate(p::Polyhedron, delset, ::FourierMotzkin) = error("Fourier-Motzkin elimination not implemented for $(typeof(p))")
52-
supportselimination(p::Polyhedron, ::BlockElimination) = false
53-
eliminate(p::Polyhedron, delset, ::BlockElimination) = error("Block elimination not implemented for $(typeof(p))")
102+
supportselimination(p::Polyhedron, ::BlockElimination) = true
103+
104+
struct ProjectionMatrix <: AbstractMatrix{Bool}
105+
indices::Vector{Int}
106+
n::Int
107+
end
108+
Base.size()
109+
Base.adjoint(P::ProjectionMatrix) = transpose(P)
110+
111+
function eliminate(p::Polyhedron, delset, ::BlockElimination)
112+
h_eliminate = ProjectionMatrix(sort(collect(delset)), fulldim(p)) \ hrep(p)
113+
return h_eliminate
114+
end
54115

55116
eliminate(p::Polyhedron, algo::EliminationAlgorithm) = eliminate(p, BitSet(fulldim(p)), algo)
56117

0 commit comments

Comments
 (0)