Skip to content

Commit

Permalink
printing number of constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
mariohsouto committed Apr 5, 2019
1 parent 28c0c41 commit 66ca688
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 43 deletions.
3 changes: 2 additions & 1 deletion src/pdhg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function chambolle_pock(affine_sets::AffineSets, conic_sets::ConicSets, opt)::CP
if opt.log_verbose
print_header_1()
print_parameters(opt, conic_sets)
print_constraints(affine_sets)
if length(conic_sets.socone) + length(conic_sets.sdpcone) > 0
print_prob_data(conic_sets)
end
Expand Down Expand Up @@ -147,7 +148,7 @@ function chambolle_pock(affine_sets::AffineSets, conic_sets::ConicSets, opt)::CP

# Adaptive reduce rank [warning: heuristic]
if opt.reduce_rank
if p.rank_update > 10 * p.window && comb_residual[k - p.window] > comb_residual[k]
if p.rank_update > 10 * p.window && comb_residual[k - p.window] >= comb_residual[k]
for (idx, sdp) in enumerate(conic_sets.sdpcone)
p.target_rank[idx] = min(p.target_rank[idx], sdp.sq_side, max(trunc(Int, p.target_rank[idx] / 2.), p.current_rank[idx] + 3))
end
Expand Down
26 changes: 24 additions & 2 deletions src/printing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,28 @@ function print_parameters(opt::Options, conic_sets::ConicSets)
println(" tol_primal $(opt.tol_primal) tol_dual $(opt.tol_dual) ")
end
println(" max_iter $(opt.max_iter) max_beta $(opt.max_beta) min_beta $(opt.min_beta)")

return nothing
end

function print_constraints(aff::AffineSets)
println(" Constraints:")
if aff.p >= 1 && aff.m >= 1
println(" $(aff.p) linear equalities and $(aff.m) linear inequalities")
elseif aff.p == 1 && aff.m >= 1
println(" $(aff.p) linear equality and $(aff.m) linear inequalities")
elseif aff.p >= 1 && aff.m == 1
println(" $(aff.p) linear equalities and $(aff.m) linear inequality")
elseif aff.p == 1
println(" $(aff.p) linear equality ")
elseif aff.p >= 1
println(" $(aff.p) linear equalities ")
elseif aff.m == 1
println(" $(aff.m) linear inequality ")
else
println(" $(aff.m) linear inequalities ")
end

return nothing
end

Expand Down Expand Up @@ -105,9 +127,9 @@ end
function print_result(convergence_flag::Bool, time_::Float64, prim_obj::Float64, dual_obj::Float64, gap::Float64, res_primal::Float64, res_dual::Float64)
println("----------------------------------------------------------------------")
if convergence_flag
println(" Optimal solution found in $(round(time_; digits = 2)) seconds.")
println(" Optimal solution found in $(round(time_; digits = 2)) seconds")
else
println(" ProxSDP failed to converge in $(round(time_; digits = 2)) seconds.")
println(" ProxSDP failed to converge in $(round(time_; digits = 2)) seconds")
end
println(" Primal objective = $(round(prim_obj; digits = 5))")
println(" Dual objective = $(round(dual_obj; digits = 5))")
Expand Down
2 changes: 1 addition & 1 deletion src/prox_operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function soc_projection!(v::ViewVector, s::ViewScalar)
elseif nv <= s[]
#do nothing
else
val = 0.5 * (1.0+s[]/nv)
val = .5 * (1. + s[] / nv)
v .*= val
s[] = val * nv
end
Expand Down
2 changes: 1 addition & 1 deletion src/structs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ mutable struct Options
opt.min_size_krylov_eigs = 100

# Reduce rank [warning: heuristic]
opt.reduce_rank = true
opt.reduce_rank = false

return opt
end
Expand Down
60 changes: 22 additions & 38 deletions time.log
Original file line number Diff line number Diff line change
@@ -1,52 +1,36 @@
──────────────────────────────────────────────────────────────────────────────
Time Allocations
────────────────────── ───────────────────────
Tot / % measured: 115s / 18.2% 152MiB / 74.3%
Tot / % measured: 1.54s / 0.61% 35.1MiB / 0.14%

Section ncalls time %tot avg alloc %tot avg
──────────────────────────────────────────────────────────────────────────────
Main 1 21.0s 100% 21.0s 113MiB 100% 113MiB
CP loop 1 20.9s 100% 20.9s 54.5MiB 48.4% 54.5MiB
primal 1.66k 15.3s 72.8% 9.22ms 53.6MiB 47.6% 33.2KiB
sdp proj 1.66k 14.4s 68.7% 8.70ms 53.6MiB 47.5% 33.2KiB
eigs 1.66k 13.1s 62.3% 7.89ms 53.3MiB 47.3% 33.0KiB
_AUPD! 1.66k 10.8s 51.6% 6.53ms 2.85MiB 2.53% 1.76KiB
_EUPD! 1.66k 290ms 1.38% 175μs 25.9KiB 0.02% 16.0B
_INIT! 1.66k 592μs 0.00% 358ns 517KiB 0.45% 320B
reshape1 1.66k 860ms 4.10% 520μs 0.00B 0.00% 0.00B
reshape2 1.66k 469ms 2.24% 283μs 0.00B 0.00% 0.00B
get min eig 1.66k 808μs 0.00% 489ns 0.00B 0.00% 0.00B
linesearch -1 1.66k 687ms 3.28% 415μs 0.00B 0.00% 0.00B
linesearch 3 12.7k 2.53s 12.1% 199μs 0.00B 0.00% 0.00B
linesearch 4 12.7k 1.69s 8.05% 133μs 0.00B 0.00% 0.00B
residual 1.66k 1.29s 6.14% 777μs 0.00B 0.00% 0.00B
linesearch 1 12.7k 8.66ms 0.04% 680ns 0.00B 0.00% 0.00B
linesearch 2 12.7k 8.13ms 0.04% 639ns 0.00B 0.00% 0.00B
Init 1 48.8ms 0.23% 48.8ms 47.6MiB 42.3% 47.6MiB
Main 1 9.30ms 100% 9.30ms 50.7KiB 100% 50.7KiB
CP loop 1 1.07ms 11.5% 1.07ms 28.8KiB 56.7% 28.8KiB
primal 51 55.1μs 0.59% 1.08μs 1.63KiB 3.20% 32.6B
linesearch -1 51 10.2μs 0.11% 200ns 0.00B 0.00% 0.00B
residual 51 35.3μs 0.38% 692ns 0.00B 0.00% 0.00B
linesearch 4 51 14.0μs 0.15% 275ns 0.00B 0.00% 0.00B
linesearch 2 51 12.9μs 0.14% 254ns 0.00B 0.00% 0.00B
linesearch 3 51 10.0μs 0.11% 197ns 0.00B 0.00% 0.00B
linesearch 1 51 9.63μs 0.10% 189ns 0.00B 0.00% 0.00B
Init 1 62.9μs 0.68% 62.9μs 12.3KiB 24.3% 12.3KiB
──────────────────────────────────────────────────────────────────────────────
────────────────────────────────────────────────────────────────────────
Time Allocations
────────────────────── ───────────────────────
Tot / % measured: 115s / 18.2% 152MiB / 74.2%
Tot / % measured: 1.55s / 0.60% 35.8MiB / 0.14%

Section ncalls time %tot avg alloc %tot avg
────────────────────────────────────────────────────────────────────────
Main 1 21.0s 100% 21.0s 113MiB 100% 113MiB
CP loop 1 20.9s 100% 20.9s 54.5MiB 48.4% 54.5MiB
primal 1.66k 15.3s 72.8% 9.22ms 53.6MiB 47.6% 33.2KiB
sdp proj 1.66k 14.4s 68.7% 8.70ms 53.6MiB 47.5% 33.2KiB
eigs 1.66k 13.1s 62.3% 7.89ms 53.3MiB 47.3% 33.0KiB
_AUPD! 1.66k 10.8s 51.6% 6.53ms 2.85MiB 2.53% 1.76KiB
linesearch 3 12.7k 2.53s 12.1% 199μs 0.00B 0.00% 0.00B
linesearch 4 12.7k 1.69s 8.05% 133μs 0.00B 0.00% 0.00B
residual 1.66k 1.29s 6.14% 777μs 0.00B 0.00% 0.00B
reshape1 1.66k 860ms 4.10% 520μs 0.00B 0.00% 0.00B
linesearch -1 1.66k 687ms 3.28% 415μs 0.00B 0.00% 0.00B
reshape2 1.66k 469ms 2.24% 283μs 0.00B 0.00% 0.00B
_EUPD! 1.66k 290ms 1.38% 175μs 25.9KiB 0.02% 16.0B
Init 1 48.8ms 0.23% 48.8ms 47.6MiB 42.3% 47.6MiB
linesearch 1 12.7k 8.66ms 0.04% 680ns 0.00B 0.00% 0.00B
linesearch 2 12.7k 8.13ms 0.04% 639ns 0.00B 0.00% 0.00B
get min eig 1.66k 808μs 0.00% 489ns 0.00B 0.00% 0.00B
_INIT! 1.66k 592μs 0.00% 358ns 517KiB 0.45% 320B
Main 1 9.30ms 100% 9.30ms 50.7KiB 100% 50.7KiB
CP loop 1 1.07ms 11.5% 1.07ms 28.8KiB 56.7% 28.8KiB
Init 1 62.9μs 0.68% 62.9μs 12.3KiB 24.3% 12.3KiB
primal 51 55.1μs 0.59% 1.08μs 1.63KiB 3.20% 32.6B
residual 51 35.3μs 0.38% 692ns 0.00B 0.00% 0.00B
linesearch 4 51 14.0μs 0.15% 275ns 0.00B 0.00% 0.00B
linesearch 2 51 12.9μs 0.14% 254ns 0.00B 0.00% 0.00B
linesearch -1 51 10.2μs 0.11% 200ns 0.00B 0.00% 0.00B
linesearch 3 51 10.0μs 0.11% 197ns 0.00B 0.00% 0.00B
linesearch 1 51 9.63μs 0.10% 189ns 0.00B 0.00% 0.00B
────────────────────────────────────────────────────────────────────────

0 comments on commit 66ca688

Please sign in to comment.