Skip to content

Commit

Permalink
Update deprecations.
Browse files Browse the repository at this point in the history
  • Loading branch information
shizejin committed Jul 24, 2019
1 parent aeb326e commit 8c84d43
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/vertex_enumeration.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Polyhedra: hyperplane

function vertex_enumeration(g::NormalFormGame{2};
plib=getlibraryfor(2, Float64))
plib=SimplePolyhedraLibrary{Float64}())

c = Channel(0)
task = vertex_enumeration_task(c, g, plib)
Expand Down Expand Up @@ -37,12 +37,12 @@ function _vertex_enumeration_producer{T}(c::Channel,
ZERO_LABELING_BITS = (1 << (n+m)) - (1 << m)
COMPLETE_LABELING_BITS = 1 << (n+m) - 1

for v1 in vreps(V1)
for v1 in points(V1)
labelings_bits1 = labelings_bits(v1, H1)
if labelings_bits1 == ZERO_LABELING_BITS
continue
end
for v2 in vreps(V2)
for v2 in points(V2)
labelings_bits2 = labelings_bits(v2, H2)
if xor(labelings_bits1, labelings_bits2) == COMPLETE_LABELING_BITS
put!(c, (_get_mixed_action(v1),
Expand All @@ -64,9 +64,9 @@ function construction_BRP{T}(g::NormalFormGame{2, T}, plib)
b1 = Vector{T}(n+m)
b1[1:m] = one(T)
b1[m+1:end] = zero(T)
H1 = SimpleHRepresentation(C, b1)
H1 = hrep(C, b1)
p1 = polyhedron(H1, plib)
V1 = SimpleVRepresentation(p1)
V1 = vrep(p1)

# create Representation for player 2
D = Matrix{T}(n+m, m)
Expand All @@ -75,16 +75,16 @@ function construction_BRP{T}(g::NormalFormGame{2, T}, plib)
b2 = Vector{T}(n+m)
b2[1:m] = zero(T)
b2[m+1:end] = one(T)
H2 = SimpleHRepresentation(D, b2)
H2 = hrep(D, b2)
p2 = polyhedron(H2, plib)
V2 = SimpleVRepresentation(p2)
V2 = vrep(p2)

return H1, V1, H2, V2
end

function labelings_bits(v::VRepElement, p::HRep)
b = 0
for (i, h) in enumerate(hreps(p))
for (i, h) in enumerate(halfspaces(p))
if v in hyperplane(h)
b += 1 << (i-1)
end
Expand All @@ -95,3 +95,4 @@ end
function _get_mixed_action(a::Vector)
return a ./ sum(a)
end

0 comments on commit 8c84d43

Please sign in to comment.