@@ -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 > 10 epsilon && dual_gap > 10 epsilon
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 > 10 epsilon && dual_gap > 10 epsilon
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