2021-05-26 12:08:31 +02:00
|
|
|
using BenchmarkTools
|
|
|
|
using Test
|
|
|
|
|
|
|
|
using Groups
|
|
|
|
|
|
|
|
function wl_ball(F; radius::Integer)
|
|
|
|
g, state = iterate(F)
|
2023-03-22 21:44:33 +01:00
|
|
|
sizes = Int[]
|
|
|
|
while length(sizes) ≤ radius
|
2021-05-26 12:08:31 +02:00
|
|
|
res = iterate(F, state)
|
|
|
|
isnothing(res) && break
|
|
|
|
g, state = res
|
2023-03-22 21:44:33 +01:00
|
|
|
if length(word(g)) > length(sizes)
|
|
|
|
push!(sizes, length(state.seen) - 1)
|
|
|
|
end
|
2021-05-26 12:08:31 +02:00
|
|
|
end
|
|
|
|
elts = collect(state.seen)
|
2023-03-22 21:44:33 +01:00
|
|
|
resize!(elts, sizes[end] - 1)
|
|
|
|
return elts, sizes[2:end]
|
2021-05-26 12:08:31 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
@testset "Benchmarks" begin
|
|
|
|
N = 4
|
|
|
|
|
|
|
|
@testset "iteration: FreeGroup" begin
|
2021-06-21 18:45:10 +02:00
|
|
|
FN = FreeGroup(N)
|
2021-05-26 12:08:31 +02:00
|
|
|
R = 8
|
|
|
|
|
|
|
|
let G = FN
|
|
|
|
S = unique([gens(G); inv.(gens(G))])
|
|
|
|
|
2023-03-22 21:44:33 +01:00
|
|
|
sizes1 = last(Groups.wlmetric_ball(S; radius = R))
|
|
|
|
sizes2 = last(wl_ball(G; radius = R))
|
2021-05-26 12:08:31 +02:00
|
|
|
|
|
|
|
@test sizes1 == sizes2
|
|
|
|
|
2023-03-22 21:44:33 +01:00
|
|
|
@info "Ball of radius $R in $(parent(first(S)))" sizes = sizes1
|
2021-05-26 12:08:31 +02:00
|
|
|
@info "serial"
|
2023-03-22 21:44:33 +01:00
|
|
|
@time Groups.wlmetric_ball(S, radius = R)
|
2021-05-26 12:08:31 +02:00
|
|
|
@info "iteration"
|
2023-03-22 21:44:33 +01:00
|
|
|
@time wl_ball(G, radius = R)
|
2021-05-26 12:08:31 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@testset "iteration: SAut(F_n)" begin
|
|
|
|
R = 4
|
2021-06-21 18:45:10 +02:00
|
|
|
FN = FreeGroup(N)
|
2022-04-02 15:53:55 +02:00
|
|
|
SAutFN = SpecialAutomorphismGroup(FN)
|
2021-05-26 12:08:31 +02:00
|
|
|
|
|
|
|
let G = SAutFN
|
|
|
|
S = unique([gens(G); inv.(gens(G))])
|
|
|
|
|
2023-03-22 21:44:33 +01:00
|
|
|
sizes1 = last(Groups.wlmetric_ball(S; radius = R))
|
|
|
|
sizes2 = last(wl_ball(G; radius = R))
|
2021-05-26 12:08:31 +02:00
|
|
|
|
|
|
|
@test sizes1 == sizes2
|
|
|
|
|
2023-03-22 21:44:33 +01:00
|
|
|
@info "Ball of radius $R in $(parent(first(S)))" sizes = sizes1
|
2021-05-26 12:08:31 +02:00
|
|
|
@info "serial"
|
2023-03-22 21:44:33 +01:00
|
|
|
@time Groups.wlmetric_ball(S, radius = R)
|
2021-05-26 12:08:31 +02:00
|
|
|
@info "iteration"
|
2023-03-22 21:44:33 +01:00
|
|
|
@time wl_ball(G, radius = R)
|
2021-05-26 12:08:31 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|