Skip to content

Commit

Permalink
updating dependencies and fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bdoolittle committed Dec 5, 2023
1 parent 0e177ba commit 05a898f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ docs/Manifest.toml

porta_tmp
porta.log
Highs.log
9 changes: 7 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ JuMP = "1"
Polyhedra = "0.7"
QBase = "0.2"
SCS = "2"
XPORTA = "0.1"
XPORTA = "0.1.3"
julia = "1"

[extras]
Polyhedra = "67491407-f73d-577b-9b50-8179a7c68029"
QBase = "e52e8ede-12bf-4731-8af7-b01f6064cb11"
SCS = "c946c3f1-0d1f-5ce8-9dea-7daa1f7e2d13"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
XPORTA = "8c143463-af6f-456f-8aed-72447cb569d2"

[targets]
test = ["Test"]
test = ["Test", "SafeTestsets", "Polyhedra", "XPORTA", "QBase", "SCS"]
7 changes: 3 additions & 4 deletions src/Nonlocality/optimize_measurements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ function optimize_measurement(
# add the objective
objective = maximize(real(tr(sum(Π_vars[1:end-1] .* H_y))), constraints)

# optimize model
solve!(objective, SCS.Optimizer(verbose=0))
solve!(objective, SCS.Optimizer())

# parse/return results
score = objective.optval
Expand Down Expand Up @@ -172,7 +171,7 @@ function _optimize_measurement_B(
end

# optimize model
solve!(problem, SCS.Optimizer(verbose=0))
solve!(problem, SCS.Optimizer())

# parse/return results
score = problem.optval
Expand Down Expand Up @@ -239,7 +238,7 @@ function _optimize_measurement_A(
end

# optimize model
solve!(problem, SCS.Optimizer(verbose=0))
solve!(problem, SCS.Optimizer())

# parse/return results
score = problem.optval
Expand Down
4 changes: 2 additions & 2 deletions test/unit/LocalPolytope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using BellScenario
@testset "LocalPolytope.vrep()" begin
@testset "no arguments" begin
scenario = LocalSignaling(3,3,2)
local_poly = vrep(scenario)
local_poly = LocalPolytope.vrep(scenario)

@test local_poly isa XPORTA.Polyhedron
@test npoints(local_poly) == 21
Expand All @@ -20,7 +20,7 @@ using BellScenario

@testset "passing arguments" begin
scenario = LocalSignaling(3,3,2)
local_poly = vrep(scenario, rank_d_only=true)
local_poly = LocalPolytope.vrep(scenario, rank_d_only=true)

@test local_poly isa XPORTA.Polyhedron
@test npoints(local_poly) == 18
Expand Down
2 changes: 1 addition & 1 deletion test/unit/LocalPolytope/facets.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Test, Polyhedra
using Test, XPORTA

@testset "./src/LocalPolytope/facets.jl" begin

Expand Down
30 changes: 15 additions & 15 deletions test/unit/Nonlocality/optimize_measurements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ using BellScenario

dict = Nonlocality.optimize_measurement(scenario, game, ρ_states)

@test isapprox(dict["violation"], 0.0, atol=1e-6)
@test dict["povm"] [[1 0;0 0],[0 0;0 0.5],[0 0;0 0.5]]
@test isapprox(dict["violation"], 0.0, atol=1e-4)
@test isapprox(dict["povm"], [[1 0;0 0],[0 0;0 0.5],[0 0;0 0.5]], atol=1e-4)
end

@testset "trine states" begin
Expand All @@ -23,10 +23,10 @@ using BellScenario

dict = Nonlocality.optimize_measurement(scenario, game, ρ_states)

@test isapprox(dict["violation"], 0.0, atol=1e-6)
@test all(isapprox.(dict["povm"][1], 2/3*ρ_states[1], atol=1e-6))
@test all(isapprox.(dict["povm"][2], 2/3*ρ_states[2], atol=1e-6))
@test all(isapprox.(dict["povm"][3], 2/3*ρ_states[3], atol=1e-6))
@test isapprox(dict["violation"], 0.0, atol=1e-5)
@test all(isapprox.(dict["povm"][1], 2/3*ρ_states[1], atol=1e-5))
@test all(isapprox.(dict["povm"][2], 2/3*ρ_states[2], atol=1e-5))
@test all(isapprox.(dict["povm"][3], 2/3*ρ_states[3], atol=1e-5))

@test dict["states"] == ρ_states
@test dict["game"] == game
Expand All @@ -40,7 +40,7 @@ using BellScenario

dict = Nonlocality.optimize_measurement(scenario, game, ρ_states)

@test isapprox(dict["violation"], 0.0, atol=1e-6)
@test isapprox(dict["violation"], 0.0, atol=1e-5)
@test all(isapprox.(dict["povm"][1], 1/2*ρ_states[1], atol=1e-3))
@test all(isapprox.(dict["povm"][2], 1/2*ρ_states[2], atol=1e-3))
@test all(isapprox.(dict["povm"][3], 1/2*ρ_states[3], atol=1e-3))
Expand Down Expand Up @@ -91,13 +91,13 @@ end
opt_dictA = Nonlocality.optimize_measurement(scenario, game, ρ_AB, A_POVMs=POVMs)
opt_dictB = Nonlocality.optimize_measurement(scenario, game, ρ_AB, B_POVMs=POVMs)

@test opt_dictA["score"] 2.20710279
@test opt_dictA["violation"] 0.207102796
@test isapprox(opt_dictA["score"], 2.20710279, atol=1e-5)
@test isapprox(opt_dictA["violation"], 0.207102796, atol=1e-5)
@test opt_dictA["A_POVMs"] isa Vector{<:POVM}
@test opt_dictA["state"] isa State

@test opt_dictB["score"] 2.20710279
@test opt_dictB["violation"] 0.207102796
@test isapprox(opt_dictB["score"], 2.20710279, atol=1e-5)
@test isapprox(opt_dictB["violation"], 0.207102796, atol=1e-5)
@test opt_dictB["B_POVMs"] isa Vector{<:POVM}
@test opt_dictB["state"] isa State
end
Expand All @@ -120,8 +120,8 @@ end
@test opt_dictA["scenario"] == scenario
@test opt_dictA["game"] == game
@test opt_dictA["game"].β == 2
@test opt_dictA["score"] 2.20710279
@test opt_dictA["violation"] 0.207102796
@test isapprox(opt_dictA["score"], 2.20710279, atol=1e-5)
@test isapprox(opt_dictA["violation"], 0.207102796, atol=1e-5)
@test opt_dictA["state"] == ρ_AB
@test opt_dictA["A_POVMs"] == POVMs
@test isapprox(
Expand All @@ -137,8 +137,8 @@ end
@test opt_dictB["scenario"] == scenario
@test opt_dictB["game"] == game
@test opt_dictB["game"].β == 2
@test opt_dictB["score"] 2.2071028
@test opt_dictB["violation"] 0.207102796
@test isapprox(opt_dictB["score"], 2.2071028, atol=1e-5)
@test isapprox(opt_dictB["violation"], 0.207102796, atol=1e-5)
@test opt_dictB["state"] == ρ_AB
@test opt_dictB["B_POVMs"] == POVMs
@test isapprox(
Expand Down

0 comments on commit 05a898f

Please sign in to comment.