Skip to content

Commit 49d9e85

Browse files
committed
print & info modify for better README
1 parent 645ac13 commit 49d9e85

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

src/callback.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ function build_callback(trajectory_arr, epsilon, max_active, shortcut, shortcut_
113113
noise_print_update = false
114114

115115
if length(active_set) > max_active
116-
verbose > 0 && @info "active set is too large"
116+
# verbose > 0 && @info "active set is too large"
117117
return false
118118
end
119119

120120
if noise_mixture
121121
if rp[] > 1 # stop if the noise is fully added
122-
verbose > 0 && @info "noise is fully added"
122+
# verbose > 0 && @info "noise is fully added"
123123
return false
124124
end
125125
noise_update_count += 1
@@ -147,12 +147,12 @@ function build_callback(trajectory_arr, epsilon, max_active, shortcut, shortcut_
147147
end
148148

149149
if !noise_mixture && shortcut && state.primal / state.dual_gap > shortcut_scale # when gap is large enough -> entangled, stop. (remove if we not use it)
150-
verbose > 0 && @info "shortcut"
150+
# verbose > 0 && @info "shortcut"
151151
return false
152152
end
153153

154154
if state.primal < epsilon # stop if the primal is small enough (main stopping criterion)
155-
verbose > 0 && @info "primal is small enough"
155+
# verbose > 0 && @info "primal is small enough"
156156
return false
157157
end
158158

src/separability_certification.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ function separability_certification(C::Array{T, N},
88
noise[1] = T(1)
99
r_list = T[]
1010
ϵ_list = T[]
11-
@show r_th = separable_ball_radius(T, lmo)
11+
r_th = separable_ball_radius(T, lmo)
1212
res = (active_set = active_set, primal = zero(T))
1313
for _ in 1:certify_test
1414
C_rec = (1+ϵ) * C - ϵ * noise
1515
res = separable_distance(C_rec, lmo; active_set = res.active_set, kwargs...)
1616
δ = sqrt(res.primal)
17-
@show r = δ / ϵ
17+
r = δ / ϵ
1818
if r < r_th
19-
println(r, " < ", r_th)
19+
# println(r, " < ", r_th)
2020
return (sep = true, res = res)
2121
else
2222
ϵ =+ ϵ_1) / 2

src/separable_distance.jl

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
separable_distance(ρ::AbstractMatrix{CT}; dims, measure, fw_algorithm, kwargs...)
2+
separable_distance(ρ::AbstractMatrix{CT}, dims::NTuple{N, Int}, lmo::LMO=AlternatingSeparableLMO(float(real(CT)), dims); measure, fw_algorithm, kwargs...)
33
separable_distance(C::Array{T, N}; matrix_basis, measure, fw_algorithm, kwargs...)
44
55
Computes the distance between the quantum density matrix `ρ` and the separable space under a specific `measure` via a specific `fw_algorithm`:
@@ -60,9 +60,9 @@ function separable_distance(
6060
epsilon = 1e-6,
6161
lazy = true,
6262
max_iteration = 10^5,
63-
verbose = 0,
63+
verbose = 1,
6464
logfile = nothing,
65-
callback_iter = 10^3,
65+
callback_iter = 10^4,
6666
shortcut = false, # primal > 10 dual_gap stopping criterion
6767
shortcut_scale = 10,
6868
kwargs...
@@ -189,6 +189,19 @@ function separable_distance(
189189
lpad(lmo.fwdata.lmo_counts[1], 7)
190190
)
191191
end
192+
if verbose > 0
193+
if length(active_set) > max_active
194+
@info "Stop: active set too large"
195+
elseif noise_mixture && rp[] > 1
196+
@info "Stop: noise fully added"
197+
elseif !noise_mixture && shortcut && primal / dual_gap > shortcut_scale
198+
@info "Stop: primal great larger than dual gap (shortcut)"
199+
elseif primal < epsilon
200+
@info "Stop: primal small enough"
201+
else
202+
@info "Stop: maximum iteration reached"
203+
end
204+
end
192205
flush(logfile)
193206
return (x = x, v = v, primal = primal, noise_level = rp[], active_set = active_set, lmo = lmo, traj_data = traj_data)
194207
end

0 commit comments

Comments
 (0)