-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexperiment-pr-vs-slq.jl
93 lines (88 loc) · 2.95 KB
/
experiment-pr-vs-slq.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
##
include("common.jl")
include("PageRank.jl")
include("SLQ.jl")
include("SLQcvx.jl")
##
gm,gn = 46, 32
A,xy = grid_graph(gm, gn)
seed = 32*16+15
##
using Plots
function myscatter!(xy, x; threshhold=1e-12,kwargs...)
nzset = x .> threshhold
scatter!(xy[nzset,1], xy[nzset,2], marker_z=log10.(x[nzset]);kwargs...)
end
## Show the Seed
scatter(xy[:,1],xy[:,2], label="", markerstrokewidth=0, markersize=2)
scatter!([xy[seed,1]], [xy[seed,2]], markersize=12, color=:darkred, label="")
##
scatter(xy[:,1],xy[:,2], label="", markerstrokewidth=0, markersize=2)
scatter!([xy[seed,1]], [xy[seed,2]], markersize=12, color=:darkred, label="")
x1, r1, iters = SLQ.slq_diffusion(SLQ.graph(A),[seed],
0.1, # gamma, the aug-graph regularization
0.001, # kappa, the sparsity regularizaiton
0.99, # rho, KKT approx
SLQ.TwoNormLoss{Float64}(),
; max_iters=1000000,
)
@show iters
myscatter!(xy, x1; label="")
##
scatter(xy[:,1],xy[:,2], label="", markerstrokewidth=0, markersize=2)
scatter!([xy[seed,1]], [xy[seed,2]], markersize=12, color=:darkred, label="")
xt, r1, iters = SLQ.slq_diffusion(SLQ.graph(A),[seed],
0.1, # gamma, the aug-graph regularization
0.001, # kappa, the sparsity regularizaiton
0.5, # rho, KKT approx
SLQ.TwoNormLoss{Float64}(),
; max_iters=1000000,
)
@show iters
myscatter!(xy, xt; label="")
contour(1:32, 1:46, xt, nlevels=15)
##
scatter(xy[:,1],xy[:,2], label="", markerstrokewidth=0, markersize=2)
scatter!([xy[seed,1]], [xy[seed,2]], markersize=12, color=:darkred, label="")
xacl = PageRank.acl_diffusion(SLQ.graph(A),[seed],
0.1, # gamma, the aug-graph regularization
0.001, # kappa, the sparsity regularizaiton
)
myscatter!(xy,xacl;label="")
##
contour(1:32, 1:46, xacl, nlevels=15)
##
scatter(xy[:,1],xy[:,2], label="", markerstrokewidth=0, markersize=2)
scatter!([xy[seed,1]], [xy[seed,2]], markersize=12, color=:darkred, label="")
xpr = PageRank.pr_diffusion(SLQ.graph(A),[seed],
0.1, # gamma, the aug-graph regularization
)
myscatter!(xy,xpr;label="")
##
scatter(xy[:,1],xy[:,2], label="", markerstrokewidth=0, markersize=2)
scatter!([xy[seed,1]], [xy[seed,2]], markersize=12, color=:darkred, label="")
#=
xt, r1, iters = SLQ.slq_diffusion(SLQ.graph(A),[seed],
0.1, # gamma, the aug-graph regularization
0.0001, # kappa, the sparsity regularizaiton
0.999, # rho, KKT approx
SLQ.QHuberLoss{Float64}(1.2,0.0),
; max_iters=1000000,
)
=#
# y = SLQcvx.slq_cvx(G, [2], 1.5, 0.1, 0.1, solver="ECOS")[1]
xt, dt = SLQcvx.slq_cvx(SLQ.graph(A), [seed],
1.5, # q
0.1, #gamma
0.1; solver="SCS") # kappa
@show iters
myscatter!(xy, xt; label="")
# figure out contour
function mycontour!(x,y,z;nlevels=10,threshhold=1e-12,kwargs...)
nzset = z .> threshhold
levels = quantile(z[nzset], range(0, 1-1/nlevels, length=nlevels))
pushfirst!(levels, 0.0)
contour!(x,y,z;levels=levels,kwargs...)
end
mycontour!(1:gm, 1:gn, xt, nlevels=5, linewidth=2, color=1)
plot!(aspect_ratio=:equal)