In [1]:
using Laplacians
In [7]:
include("../src/akpw.jl")
Out[7]:
In [6]:
# this should produce 22.9374025974026
srand(1)
a = grid2(1100)
t = akpwU(a)
sum(compStretches(t,a))/nnz(a)
Out[6]:
In [7]:
# this should produce 32.47723881214327
#a = grid2(1100)
t = akpw(a)
sum(compStretches(t,a))/nnz(a)
Out[7]:
In [8]:
#= this should produce
0.835222 seconds (3.65 M allocations: 272.523 MB, 17.63% gc time)
0.900887 seconds (5.59 M allocations: 365.142 MB, 22.07% gc time)
Out[7]:
1x2 Array{Float64,2}:
6.76587 6.80419
=#
a = wtedChimera(60100,22)
f(t) = sum(compStretches(t,a))/nnz(a)
@time t5 = akpw(a);
@time t2 = akpw(a, ver=2);
[f(t5) f(t2)]
Out[8]:
In [206]:
a = wtedChimera(100200,96)
#a=a*a
(ai,aj,av) = findnz(a)
ijva = IJVindList(ai,aj,av);
ijva = ijva[randperm(length(ijva))];
In [207]:
@time l2 = sortIJVind2(ijva);
In [208]:
@time l1 = sortIJVind(ijva);
In [216]:
@time l3 = sortIJVind3(ijva);
In [191]:
mean(l3 .== l1)
Out[191]:
In [196]:
byi(x::IJVind) = x.v
o = ord(isless, byi, false, Forward)
sort!(l3, 1, 6, InsertionSort, o)
l3[1:10]
Out[196]:
In [ ]:
In [24]:
include("testTrees.jl")
Out[24]:
In [27]:
out = testTrees3(500,100);
In [198]:
for i in 1:10000
a = wtedChimera(10,i)
tr = akpwish(a,ver=5)
if !isConnected(tr)
println(i)
break
end
end
In [154]:
vstat = function(x)
x = sort(x)
n = length(x)
n5 = div(n,5)
[mean(x) minimum(x) x[n5:n5:(4*n5)]' maximum(x)]
end
vstat(x)
Out[154]:
In [157]:
include("testTrees.jl")
out = testTrees2(401,400)
Out[157]:
In [149]:
@time a = wtedChimera(601000,20)
f(t) = sum(compStretches(t,a))/nnz(a)
@time t6 = akpwish(a,ver=6)
@time t5 = akpwish(a,ver=5)
@time t2 = akpwish(a,ver=2)
println([f(t6) f(t5) f(t2)])
In [127]:
@time a = wtedChimera(601000,20)
f(t) = sum(compStretches(t,a))/nnz(a)
@time t5 = akpwish(a,ver=5)
@time t4 = akpwish(a,ver=4)
@time t2 = akpwish(a,ver=2)
@time t3 = akpwish(a,ver=3)
@time tp = randishPrim(a)
@time tk = randishKruskal(a)
@time told = akpw(a)
println([f(t5) f(t4) f(t2) f(t3) f(tp) f(tk) f(told)])
In [98]:
n = 300
st0 = Array(Float64,0)
st2 = Array(Float64,0)
st4 = Array(Float64,0)
st5 = Array(Float64,0)
stp = Array(Float64,0)
stk = Array(Float64,0)
stold = Array(Float64,0)
t0 = Array(Float64,0)
t2 = Array(Float64,0)
t4 = Array(Float64,0)
t5 = Array(Float64,0)
tp = Array(Float64,0)
tk = Array(Float64,0)
told = Array(Float64,0)
for i in 1:10
a = wtedChimera(n,i)
f(t) = sum(compStretches(t,a))/nnz(a)
try
tic()
tr = akpwish(a,ver=0)
at0 = toq()
ast0 = f(tr)
tic()
tr = akpwish(a,ver=2)
at2 = toq()
ast2 = f(tr)
tic()
tr = randishKruskal(a)
atk = toq()
astk = f(tr)
print(n, " ", i, " : ")
print(ast0, " ")
push!(t0,at0)
push!(st0,ast0)
print(ast2, " ")
push!(t2,at2)
push!(st2,ast2)
print(astk, " ")
push!(tk,atk)
push!(stk,astk)
catch
println("bad on wtedChimera ", n, " ", i)
end
end
mist = minimum([st0 st2 stk],2)
f = 1.3
stats(v) = [mean(v./mist) median(v./mist) maximum(v./mist) mean(v .== mist) mean(v .> f*mist)]
println(stats(st0))
println(stats(st2))
println(stats(stk))
In [99]:
st0 = Array(Float64,0)
st2 = Array(Float64,0)
st4 = Array(Float64,0)
st5 = Array(Float64,0)
stp = Array(Float64,0)
stk = Array(Float64,0)
stold = Array(Float64,0)
t0 = Array(Float64,0)
t2 = Array(Float64,0)
t4 = Array(Float64,0)
t5 = Array(Float64,0)
tp = Array(Float64,0)
tk = Array(Float64,0)
told = Array(Float64,0)
Out[99]:
In [101]:
a = wtedChimera(301,8)
f(t) = sum(compStretches(t,a))/nnz(a)
tic()
tr = akpwish(a,ver=0)
at0 = toq()
ast0 = f(tr)
tic()
tr = akpwish(a,ver=2)
at2 = toq()
ast2 = f(tr)
tic()
tr = akpwish(a,ver=4)
at4 = toq()
ast4 = f(tr)
tic()
tr = akpwish(a,ver=5)
at5 = toq()
ast5 = f(tr)
tic()
tr = randishKruskal(a)
atk = toq()
astk = f(tr)
tic()
tr = randishPrim(a)
atp = toq()
astp = f(tr)
tic()
tr = akpw(a)
atold = toq()
astold = f(tr)
In [17]:
st1 = Array(Float64,0)
st2 = Array(Float64,0)
st3 = Array(Float64,0)
stold = Array(Float64,0)
tic()
for i in 1:100
a = chimera(9003,i)
t1 = akpwU(a)
push!(st1, sum(compStretches(t1,a)) / nnz(a) )
t2 = akpwU(a,x->(1/(log(x+1))))
push!(st2, sum(compStretches(t2,a)) / nnz(a) )
t3 = akpwU(a,x->(1/(2*exp(sqrt(log(x))))))
push!(st3, sum(compStretches(t3,a)) / nnz(a) )
told = akpw(a)
push!(stold, sum(compStretches(told,a)) / nnz(a) )
end
toc()
mi = minimum([st1 st2 st3 stold],2)
f = 1.3
stats(v) = [mean(v./mi) median(v./mi) maximum(v./mi) mean(v .== mi) mean(v .> f*mi)]
println(stats(st1))
println(stats(st2))
println(stats(st3))
println(stats(stold))
In [45]:
st5 = Array(Float64,0)
tic()
for i in 1:1000
a = chimera(90001,i)
t5 = akpwU(a,x->(1/(2*log(x))))
push!(st5, sum(compStretches(t5,a)) / nnz(a) )
end
toc()
mi = minimum([st1 st2 st3 st4 stold],2)
f = 1.3
stats(v) = [mean(v./mi) median(v./mi) maximum(v./mi) sum(v .== mi) sum(v .> f*mi)]
println(stats(st5))
In [265]:
stnew = Array(Float64,0)
stp = Array(Float64,0)
stold = Array(Float64,0)
timenew = 0
timep = 0
timeold = 0
tic()
for i in 1:10000
a = wtedChimera(100,i)
tic()
tnew = akpwish(a)
timenew += toq()
push!(stnew, sum(compStretches(tnew,a)) / nnz(a) )
tic()
tp = randishPrim(a)
timep += toq()
push!(stp, sum(compStretches(tp,a)) / nnz(a) )
tic()
told = akpw(a)
timeold += toq()
push!(stold, sum(compStretches(told,a)) / nnz(a) )
end
toc()
mi = minimum([stnew stp stold],2)
f = 1.3
stats(v) = [mean(v./mi) median(v./mi) maximum(v./mi) mean(v .== mi) mean(v .> f*mi)]
println(stats(stnew))
println(stats(stp))
println(stats(stold))
@show timenew
#@show timep
@show timeold
Out[265]:
In [228]:
findmax(stnew./stold)
Out[228]:
In [270]:
function complsst(sz::Int, nruns::Int)
stnew = Array(Float64,0)
stp = Array(Float64,0)
stold = Array(Float64,0)
timenew = 0
timep = 0
timeold = 0
tic()
for i in 1:nruns
a = wtedChimera(sz,i)
tic()
tnew = akpwish(a)
timenew += toq()
push!(stnew, sum(compStretches(tnew,a)) / nnz(a) )
tic()
tp = randishPrim(a)
timep += toq()
push!(stp, sum(compStretches(tp,a)) / nnz(a) )
tic()
told = akpw(a)
timeold += toq()
push!(stold, sum(compStretches(told,a)) / nnz(a) )
end
toc()
mi = minimum([stnew stp stold],2)
f = 1.3
stats(v) = [mean(v./mi) median(v./mi) maximum(v./mi) mean(v .== mi) mean(v .> f*mi)]
println(stats(stnew))
println(stats(stp))
println(stats(stold))
@show timenew
@show timep
@show timeold
end
Out[270]:
In [271]:
complsst(1000,1001)
Out[271]:
In [272]:
complsst(10010,101)
Out[272]:
In [274]:
Profile.clear()
In [22]:
a = chimera(1000000,2);
In [27]:
include("../src/akpw.jl")
tnew = akpwish(chimera(50,1))
@time tnew = akpwish(a)
sum(compStretches(tnew,a)) / nnz(a)
Out[27]:
In [23]:
include("../src/akpw.jl")
tnew = akpwish(chimera(50,1))
@time tnew = akpwish(a)
sum(compStretches(tnew,a)) / nnz(a)
Out[23]:
In [24]:
told = akpw(chimera(50,1))
@time told = akpw(a)
sum(compStretches(told,a)) / nnz(a)
Out[24]:
In [25]:
tp = akpw(chimera(50,1))
@time tp = randishPrim(a)
sum(compStretches(tp,a)) / nnz(a)
Out[25]: