Skip to content

Commit 59b305a

Browse files
Add warm start and fix rounding strategy
1 parent 0832fe9 commit 59b305a

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

examples/GHZ.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ measurements = [[(σ[1] - v[i, 1] * σ[2] - v[i, 2] * σ[3] - v[i, 3] * σ[4]) /
1919
p = tensor_correlation(rho, measurements, N; marg = false) # the marginals vanish in this cas
2020

2121
# Frank-Wolfe
22-
lower_bound, upper_bound, local_model, bell_inequality = nonlocality_threshold(p)
22+
@time lower_bound, upper_bound, local_model, bell_inequality = nonlocality_threshold(p; sym = false)
2323

2424
println("Correlation tensor")
2525
display(p[:, :, 1]) # only printing part of the tensor

src/nonlocality_threshold.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,37 @@ function nonlocality_threshold(
2525
deflate = identity,
2626
inflate = identity,
2727
verbose = 0,
28-
shortcut = 100,
28+
shortcut = 10,
2929
kwargs...,
3030
) where {T <: Number, N}
3131
_, _, _, o, sym, deflate, inflate = _bfw_init(p, 0, prob, marg, o, sym, deflate, inflate, verbose > 0)
3232
lower_bound = zero(T)
3333
upper_bound = one(T)
34+
active_set = nothing
3435
local_model = nothing
3536
bell_inequality = nothing
36-
while upper_bound - lower_bound > 10.0^(-precision)
37-
res = bell_frank_wolfe(p; v0, epsilon, marg, o, sym, deflate, inflate, verbose, verbose_init = false, shortcut, kwargs...)
38-
x, ds, primal, dual_gap, as, M, β = res
39-
if dual_gap * shortcut primal && primal > 10epsilon && dual_gap > 10epsilon
37+
while log10(upper_bound - lower_bound) > -precision
38+
res = bell_frank_wolfe(p; v0, epsilon, marg, o, sym, deflate, inflate, verbose, verbose_init = false, active_set, shortcut, mode_last = -1, kwargs...)
39+
x, ds, primal, dual_gap, active_set, M, β = res
40+
if dual_gap primal && primal > 10epsilon && dual_gap > 10epsilon
4041
@warn "Please increase nb or max_iteration"
4142
end
4243
if dual_gap < primal
4344
if β < upper_bound
44-
upper_bound = round(β; digits = precision)
45+
upper_bound = round, RoundUp; digits = precision)
4546
bell_inequality = M
46-
if v0 == round(β; digits = precision)
47-
v0 = round(β - 10.0^(-precision); digits = precision)
47+
if v0 == upper_bound
48+
v0 = round(upper_bound - 10.0^(-precision); digits = precision)
4849
else
49-
v0 = round(β; digits = precision)
50+
v0 = upper_bound
5051
end
5152
else
5253
@warn "Unexpected output"
5354
break
5455
end
5556
else
5657
lower_bound = v0
57-
local_model = as
58+
local_model = active_set
5859
if upper_bound < lower_bound
5960
upper_bound = round(v0 + 2 * 10.0^(-precision); digits = precision)
6061
end

0 commit comments

Comments
 (0)