Fix issue #25#30
Conversation
also fixing first of the performance problems.
| using Distances: euclidean | ||
|
|
||
| Coord = SVector{2,Int} | ||
| const Coord = SVector{2,Int} |
| view(grid, TL[1]:BR[1], TL[2]:BR[2]) .= Ref(first(sites)) | ||
| else | ||
| # Otherwise we check if all corners have the same closest site | ||
| # Otherwise we check if all corners have the same closest site ... |
There was a problem hiding this comment.
This part I don't understand
There was a problem hiding this comment.
If you modify the code here like
if all(zip(mins, dists)) do ((min_dist, _), dist)
dist > min_dist
end
grid[TL[1]:BR[1], TL[2]:BR[2]] .= Ref(min_site)
return nothing
else
@show (distance, mins, dists)
# grid[TL[1]:BR[1], TL[2]:BR[2]] .= Ref(min_site)
return nothing
end
you'll see the non unique sites and if you also set the rectangle to the the site you'll see the test failures for Chebyshev distance. BTW we could also drop the whole code sequence, because filtering is good enough (see the benchmark for different find and filter combinations in legacy).
| function centre_anchor_condition(site, sites, TL, BR; distance=euclidean) | ||
| centre = @. TL + BR / 2 | ||
| anchor = find_closest_site(centre, sites) | ||
| anchor = find_closest_site(centre, sites; distance=distance) |
There was a problem hiding this comment.
Good find, didn't realise this was bugged
| return nothing | ||
| end | ||
|
|
||
| function unstable_partition!(f, A) |
There was a problem hiding this comment.
Can you benchmark the use of unstable_partition vs EarlyStopper? I'm up for switching because it's simpler, but performance is important.
There was a problem hiding this comment.
Benchmark added. To improve the last test cases we probably need something like preset_voronoi from the legacy branch.
Results from my system with 1.8.2
(n, s) = (400, 20)
jfa_voronoi!
41.130 ms (0 allocations: 0 bytes)
dac_voronoi!
3.201 ms (0 allocations: 0 bytes)
redac_voronoi!
exact_aux = DiscreteVoronoi.exact_aux
1.085 ms (0 allocations: 0 bytes)
centre_anchor_aux = DiscreteVoronoi.centre_anchor_aux
1.056 ms (0 allocations: 0 bytes)
redac_voronoi_es!
exact_aux_es = DiscreteVoronoi.exact_aux_es
979.600 μs (0 allocations: 0 bytes)
centre_anchor_aux_es = DiscreteVoronoi.centre_anchor_aux_es
946.800 μs (0 allocations: 0 bytes)
(n, s) = (400, 400)
jfa_voronoi!
48.407 ms (0 allocations: 0 bytes)
dac_voronoi!
254.303 ms (0 allocations: 0 bytes)
redac_voronoi!
exact_aux = DiscreteVoronoi.exact_aux
7.985 ms (0 allocations: 0 bytes)
centre_anchor_aux = DiscreteVoronoi.centre_anchor_aux
6.368 ms (0 allocations: 0 bytes)
redac_voronoi_es!
exact_aux_es = DiscreteVoronoi.exact_aux_es
7.415 ms (0 allocations: 0 bytes)
centre_anchor_aux_es = DiscreteVoronoi.centre_anchor_aux_es
5.867 ms (0 allocations: 0 bytes)
(n, s) = (400, 8000)
jfa_voronoi!
64.304 ms (0 allocations: 0 bytes)
redac_voronoi!
exact_aux = DiscreteVoronoi.exact_aux
206.388 ms (0 allocations: 0 bytes)
centre_anchor_aux = DiscreteVoronoi.centre_anchor_aux
51.430 ms (0 allocations: 0 bytes)
redac_voronoi_es!
exact_aux_es = DiscreteVoronoi.exact_aux_es
199.030 ms (0 allocations: 0 bytes)
centre_anchor_aux_es = DiscreteVoronoi.centre_anchor_aux_es
50.399 ms (0 allocations: 0 bytes)
(n, s) = (400, 160000)
jfa_voronoi!
49.841 ms (0 allocations: 0 bytes)
redac_voronoi!
exact_aux = DiscreteVoronoi.exact_aux
7.645 s (0 allocations: 0 bytes)
centre_anchor_aux = DiscreteVoronoi.centre_anchor_aux
686.620 ms (0 allocations: 0 bytes)
redac_voronoi_es!
exact_aux_es = DiscreteVoronoi.exact_aux_es
7.466 s (0 allocations: 0 bytes)
centre_anchor_aux_es = DiscreteVoronoi.centre_anchor_aux_es
707.790 ms (0 allocations: 0 bytes)
There was a problem hiding this comment.
One more remark: to replace _findmin with Base.findmin, EarlyStopper needs to support a keys method. Do you know how to implement it?
|
My current benchmark numbers look fine now: We could include |
No description provided.