Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Clustering Algorithm for Spawnpoints #132

Merged
merged 33 commits into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a36d326
another clustering algorithm
TurtIeSocks Apr 3, 2023
baa8a55
add standardized scoring system to stats log
TurtIeSocks Apr 3, 2023
0707e83
change to bool value in distance matrix
TurtIeSocks Apr 3, 2023
4386faa
speed & stats improvements
TurtIeSocks Apr 3, 2023
07a5c76
Merge branch 'main' into another-clustering-algo
TurtIeSocks Apr 7, 2023
dace849
fixes
TurtIeSocks Apr 7, 2023
908a80e
Merge branch 'main' into another-clustering-algo
TurtIeSocks Apr 8, 2023
5ea8447
calculate children from client
TurtIeSocks Apr 8, 2023
ae0e022
better btn names
TurtIeSocks Apr 9, 2023
844fb19
Merge branch 'main' into another-clustering-algo
TurtIeSocks Apr 9, 2023
2c59bcb
Merge branch 'main' into another-clustering-algo
TurtIeSocks Apr 10, 2023
7a2dbfb
Merge branch 'main' into another-clustering-algo
TurtIeSocks Apr 11, 2023
158433a
custom name in assign step
TurtIeSocks Apr 11, 2023
88beded
save dkmur
TurtIeSocks Apr 11, 2023
8c58222
Merge branch 'main' into another-clustering-algo
TurtIeSocks Apr 12, 2023
e4f64ad
Update bruteforce.rs
TurtIeSocks Apr 12, 2023
d5a616a
Merge branch 'main' into another-clustering-algo
TurtIeSocks Apr 12, 2023
1084f3a
Update bruteforce.rs
TurtIeSocks Apr 12, 2023
54ffd42
fix null values from db properties in geofence expand
TurtIeSocks Apr 13, 2023
3df7576
move some logic to c++
TurtIeSocks Apr 13, 2023
92c73a1
Update tsp.rs
TurtIeSocks Apr 13, 2023
ce1826d
Update bruteforce.rs
TurtIeSocks Apr 13, 2023
ed9ad5c
prevent reloading markers while clustering/routing
TurtIeSocks Apr 13, 2023
95d359d
Update Polygon.tsx
TurtIeSocks Apr 13, 2023
fd865e7
Merge branch 'main' into another-clustering-algo
TurtIeSocks Apr 13, 2023
ae35cd0
Merge branch 'main' into another-clustering-algo
TurtIeSocks Apr 14, 2023
29db700
push to api by project
TurtIeSocks Apr 15, 2023
260a375
Merge branch 'main' into another-clustering-algo
TurtIeSocks Apr 16, 2023
fad31c9
Merge branch 'main' into another-clustering-algo
TurtIeSocks Apr 19, 2023
dddfe72
Update bruteforce.rs
TurtIeSocks Apr 20, 2023
3544d14
Merge branch 'main' into another-clustering-algo
TurtIeSocks Apr 22, 2023
4555208
Merge branch 'main' into another-clustering-algo
TurtIeSocks Apr 22, 2023
8e6c6cf
Merge branch 'main' into another-clustering-algo
TurtIeSocks Apr 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"editor.autoClosingBrackets": "always",
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"editor.formatOnSave": true
}
"editor.formatOnSave": true,
"rust-analyzer.showUnlinkedFileNotification": false
}
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "koji",
"version": "1.0.1",
"version": "1.1.0",
"description": "Tool to make RDM routes",
"main": "server/dist/index.js",
"author": "TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>",
Expand Down
16 changes: 12 additions & 4 deletions client/src/components/drawer/Routing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Toggle from './inputs/Toggle'
export default function RoutingTab() {
const mode = usePersist((s) => s.mode)
const category = usePersist((s) => s.category)
const fast = usePersist((s) => s.fast)
const cluster_mode = usePersist((s) => s.cluster_mode)
const calculation_mode = usePersist((s) => s.calculation_mode)

const [updateButton, scannerType, isEditing] = useStatic((s) => [
Expand Down Expand Up @@ -93,12 +93,20 @@ export default function RoutingTab() {
<Divider sx={{ my: 2 }} />
<ListSubheader>Clustering</ListSubheader>
<NumInput field="min_points" />
<Toggle field="fast" />
<Collapse in={!fast}>
<MultiOptionList
field="cluster_mode"
hideLabel
buttons={['Fast', 'Balanced', 'BruteForce']}
type="select"
/>
<Collapse in={cluster_mode === 'BruteForce'}>
<NumInput field="cluster_split_level" min={1} max={30} />
</Collapse>
<Collapse in={cluster_mode === 'Balanced'}>
<Toggle field="only_unique" />
</Collapse>
</Collapse>
<Collapse in={mode === 'cluster' && !fast}>
<Collapse in={mode === 'cluster' && cluster_mode === 'Balanced'}>
<MultiOptionList
field="sort_by"
buttons={['GeoHash', 'ClusterCount', 'Random']}
Expand Down
6 changes: 5 additions & 1 deletion client/src/hooks/usePersist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface UsePersist {

// Clustering
category: Category | 'fort'
cluster_mode: 'Fast' | 'Balanced' | 'BruteForce'
tth: 'All' | 'Known' | 'Unknown'
lineColorRules: { distance: number; color: string }[]
mode: 'bootstrap' | 'route' | 'cluster'
Expand All @@ -53,6 +54,7 @@ export interface UsePersist {
min_points: number | ''
only_unique: boolean
route_split_level: number | ''
cluster_split_level: number | ''
save_to_db: boolean
save_to_scanner: boolean
skipRendering: boolean
Expand Down Expand Up @@ -82,6 +84,7 @@ export const usePersist = create(
location: [0, 0],
zoom: 18,
category: 'pokestop',
cluster_mode: 'Fast',
lineColorRules: [
{ distance: 500, color: '#197E13' },
{ distance: 1000, color: '#FFFF0C' },
Expand All @@ -103,7 +106,8 @@ export const usePersist = create(
s2FillMode: 'simple',
radius: 70,
route_split_level: 1,
routing_chunk_size: 0,
cluster_split_level: 10,
// routing_chunk_size: 0,
calculation_mode: 'Radius',
s2_level: 15,
s2_size: 9,
Expand Down
5 changes: 4 additions & 1 deletion client/src/pages/map/popups/Polygon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type {
import { useShapes } from '@hooks/useShapes'
import { useStatic } from '@hooks/useStatic'
import { useDbCache } from '@hooks/useDbCache'
import { fetchWrapper } from '@services/fetches'
import { clusteringRouting, fetchWrapper } from '@services/fetches'
import {
removeAllOthers,
removeThisPolygon,
Expand Down Expand Up @@ -191,6 +191,9 @@ export function PolygonPopup({
</Typography>
</Grid2>
<Divider flexItem sx={{ my: 1, color: 'black', width: '90%' }} />
<Grid2 xs={12}>
<Button onClick={() => clusteringRouting(feature)}>Recluster</Button>
</Grid2>
<Grid2 xs={12}>
<ButtonGroup>
<Button
Expand Down
10 changes: 8 additions & 2 deletions client/src/services/fetches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,18 @@ export async function getFullCache() {
)
}

export async function clusteringRouting(): Promise<FeatureCollection> {
export async function clusteringRouting(
feature?: Feature,
): Promise<FeatureCollection> {
const {
mode,
radius,
cluster_mode,
category: rawCategory,
min_points,
fast,
route_split_level,
cluster_split_level,
only_unique,
save_to_db,
save_to_scanner,
Expand All @@ -130,7 +134,7 @@ export async function clusteringRouting(): Promise<FeatureCollection> {
const { add, activeRoute } = useShapes.getState().setters
const { getFromKojiKey, getRouteByCategory } = useDbCache.getState()

const areas = (geojson?.features || []).filter((x) =>
const areas = ((feature ? [feature] : geojson?.features) || []).filter((x) =>
x.geometry.type.includes('Polygon'),
)
const last_seen = typeof raw === 'string' ? new Date(raw) : raw
Expand Down Expand Up @@ -216,11 +220,13 @@ export async function clusteringRouting(): Promise<FeatureCollection> {
last_seen: Math.floor((last_seen?.getTime?.() || 0) / 1000),
radius,
min_points,
cluster_mode,
fast,
only_unique,
save_to_db,
save_to_scanner,
route_split_level,
cluster_split_level,
sort_by,
tth,
calculation_mode,
Expand Down
74 changes: 70 additions & 4 deletions server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "koji"
version = "1.0.0"
version = "1.1.0"
edition = "2021"

[workspace]
Expand Down
3 changes: 2 additions & 1 deletion server/algorithms/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "algorithms"
version = "1.0.0"
version = "1.1.0"
edition = "2021"
publish = false

Expand All @@ -16,6 +16,7 @@ log = "0.4.17"
map_3d = "0.1.5"
model = { path = "../model" }
rand = "0.8.5"
rayon = "1.7.0"
rstar = "0.10.0"
s2 = "0.0.12"
serde = { version = "1.0.136", features = ["derive"] }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

use crate::clustering::brute::helpers::Helpers;
use crate::clustering::balanced::helpers::Helpers;

pub fn run(
point_map: &HashMap<String, PointInfo>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{clustering::brute::helpers::Helpers, utils};
use crate::{clustering::balanced::helpers::Helpers, utils};

use super::*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

use crate::clustering::brute::helpers::Helpers;
use crate::clustering::balanced::helpers::Helpers;

pub fn run(
point_map: &mut HashMap<String, PointInfo>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

use crate::clustering::brute::helpers::Helpers;
use crate::clustering::balanced::helpers::Helpers;

pub fn run(
circle_map: &mut HashMap<String, CircleInfo>,
Expand Down
Loading