Skip to content

Commit

Permalink
Merge pull request #204 from TurtIeSocks/algorithm-docs
Browse files Browse the repository at this point in the history
Algorithm notes & docs
  • Loading branch information
TurtIeSocks authored Nov 16, 2023
2 parents c69cc3c + 17bf902 commit 5052c52
Show file tree
Hide file tree
Showing 9 changed files with 575 additions and 10 deletions.
1 change: 1 addition & 0 deletions docs/pages/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"setup": "Setup",
"client": "Client",
"api-reference": "API Reference",
"algorithms": "Algorithms",
"integrations": "Integrations",
"development": "Development"
}
564 changes: 564 additions & 0 deletions docs/pages/algorithms/clustering.mdx

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/images/clustering/balanced.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/images/clustering/better.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/images/clustering/fast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/images/clustering/fastest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions server/algorithms/src/clustering/greedy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ impl<'a> Greedy {
let mut new_clusters = HashSet::<Cluster>::new();
let mut blocked_points = HashSet::<&Point>::new();

let mut highest = clusters_with_data.len() - 1;
let total_iterations = highest - self.min_points + 1;
let mut current = clusters_with_data.len() - 1;
let total_iterations = current - self.min_points + 1;
let mut current_iteration = 0;
let mut stdout = std::io::stdout();

Expand All @@ -291,12 +291,12 @@ impl<'a> Greedy {
let mut iterating_local_time = 0.;
let mut logging_time = 0.;

'greedy: while highest >= self.min_points && new_clusters.len() < self.max_clusters {
'greedy: while current >= self.min_points && new_clusters.len() < self.max_clusters {
let mut clusters_of_interest: Vec<&Cluster<'_>> = vec![];
current_iteration += 1;
let time = Instant::now();
for (max, clusters) in clusters_with_data.iter().enumerate() {
if max < highest {
for (index, clusters) in clusters_with_data.iter().enumerate() {
if index < current {
continue;
}
clusters_of_interest.extend(clusters);
Expand All @@ -318,7 +318,7 @@ impl<'a> Greedy {
}
})
.collect();
if points.len() < highest {
if points.len() < current {
None
} else {
points.sort_dedupe();
Expand All @@ -334,7 +334,7 @@ impl<'a> Greedy {
local_clusters_time += time.elapsed().as_secs_f32();

if local_clusters.is_empty() {
highest -= 1;
current -= 1;
continue;
}

Expand All @@ -353,7 +353,7 @@ impl<'a> Greedy {
if new_clusters.len() >= self.max_clusters {
break 'greedy;
}
if cluster.points.len() >= highest {
if cluster.points.len() >= current {
for point in cluster.points.iter() {
if blocked_points.contains(point) {
continue 'cluster;
Expand All @@ -368,7 +368,7 @@ impl<'a> Greedy {
iterating_local_time += time.elapsed().as_secs_f32();

let time = Instant::now();
if highest >= self.min_points {
if current >= self.min_points {
stdout
.write(
info_log(
Expand All @@ -386,7 +386,7 @@ impl<'a> Greedy {
}
logging_time += time.elapsed().as_secs_f32();

highest -= 1;
current -= 1;
}
stdout.write(format!("\n",).as_bytes()).unwrap();

Expand Down

1 comment on commit 5052c52

@vercel
Copy link

@vercel vercel bot commented on 5052c52 Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

koji – ./

koji.vercel.app
koji-git-main-turtiesocks.vercel.app
koji-turtiesocks.vercel.app

Please sign in to comment.