44Compute the nonlocality threshold of the probability/correlation tensor `p`.
55
66Returns:
7- - `lower_bound`: a lower bound on the nonlocality threshold under the measurements provided in input ,
7+ - `lower_bound`: a (exact up to analyticity step) lower bound on the nonlocality threshold of `p` ,
88 - `upper_bound`: a (heuristic) upper bound on the nonlocality threshold of `p`
9- - `local_model`: a decomposition of the tensor `p` with visibility `lower_bound`,
9+ - `local_model`: a decomposition of the tensor `p` with visibility `lower_bound` (up to a distance `2√epsilon`) ,
1010 - `bell_inequality`: a (heuristic) Bell inequality corresponding to `upper_bound`.
1111
1212Optional arguments:
13+ - ``
1314 - `precision`: number of digits of `lower_bound`, 4 by default,
1415 - for the other optional arguments, see `bell_frank_wolfe`.
1516"""
1617function nonlocality_threshold (
1718 p:: Array{T, N} ,
1819 lower_bound = zero (T),
1920 upper_bound = one (T);
21+ upper:: Bool = true ,
2022 precision = 4 ,
2123 prob:: Bool = false ,
2224 marg:: Bool = false ,
23- v0 = one (T),
2425 epsilon = Base. rtoldefault (T),
2526 o = nothing ,
2627 sym = nothing ,
2728 deflate = identity,
2829 inflate = identity,
2930 verbose = 0 ,
3031 active_set = nothing ,
31- shortcut = 10 ,
32+ shortcut = 4 ,
3233 kwargs... ,
3334 ) where {T <: Number , N}
35+ expand_permutedims = sym === nothing
3436 _, _, _, o, sym, deflate, inflate = _bfw_init (p, 0 , prob, marg, o, sym, deflate, inflate, verbose > 0 )
35- local_model = nothing
37+ expand_permutedims &= sym
38+ v0 = upper ? upper_bound : lower_bound
39+ ass = nothing
3640 bell_inequality = nothing
37- while log10 (upper_bound - lower_bound) > - precision
41+ while round ( log10 (upper_bound - lower_bound); digits = 4 ) > - precision
3842 res = bell_frank_wolfe (p; v0, epsilon, prob, marg, o, sym, deflate, inflate, verbose, verbose_init = false , active_set, shortcut, mode_last = - 1 , kwargs... )
3943 x, ds, primal, dual_gap, active_set, M, β = res
4044 if dual_gap ≥ primal && primal > 10 epsilon && dual_gap > 10 epsilon
@@ -55,13 +59,13 @@ function nonlocality_threshold(
5559 end
5660 else
5761 lower_bound = v0
58- local_model = ActiveSetStorage (active_set) # in-place mess otherwise
62+ ass = ActiveSetStorage (active_set)
5963 if upper_bound < lower_bound
6064 upper_bound = round (v0 + 2 * 10.0 ^ (- precision); digits = precision)
6165 end
6266 v0 = (lower_bound + upper_bound) / 2
6367 end
6468 end
65- return lower_bound, upper_bound, load_active_set ( local_model, T ; deflate), bell_inequality
69+ return lower_bound, upper_bound, local_model (ass ; deflate, expand_permutedims ), bell_inequality
6670end
6771export nonlocality_threshold
0 commit comments