Skip to content

Commit

Permalink
feat: algorithm mostly working with 2-degree contraction
Browse files Browse the repository at this point in the history
  • Loading branch information
CalliEve committed Oct 8, 2024
1 parent 25ccc1e commit c98222c
Show file tree
Hide file tree
Showing 23 changed files with 1,181 additions and 155 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ csscolorparser = "0.7"
rand = "0.8"
priority-queue = "2.1"
ordered-float = "4.3"
itertools = "0.13"

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
Expand Down
11 changes: 6 additions & 5 deletions benches/map_algo_benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,21 @@ pub fn full_recalculation_simple_benchmark(c: &mut Criterion) {
});
}

pub fn full_recalculation_sydney_benchmark(c: &mut Criterion) {
// TODO: change back to berlin
pub fn full_recalculation_karlsruhe_benchmark(c: &mut Criterion) {
let mut canvas = CanvasState::new();
canvas.set_square_size(7);
canvas.set_size((700, 1600)); // Without enlarging the canvas, some stations will overlap due to map size

let test_file_content = std::fs::read_to_string("existing_maps/sydney.graphml") // TODO: change back to berlin
let test_file_content = std::fs::read_to_string("existing_maps/karlsruhe.graphml")
.expect("test data file does not exist");
let map = graphml::decode_map(&test_file_content, canvas).expect("failed to decode graphml");

let mut state = MapState::new(map.clone());
state.calculate_algorithm_settings();
let settings = state.get_algorithm_settings();

c.bench_function("full_recalculation_berlin", |b| {
c.bench_function("full_recalculation_karlsruhe", |b| {
b.iter(|| {
let mut map = map.clone();
recalculate_map(black_box(settings), black_box(&mut map))
Expand All @@ -73,8 +74,8 @@ pub fn full_recalculation_sydney_benchmark(c: &mut Criterion) {

criterion_group!(
name = full_recalculation_benches;
config = Criterion::default().measurement_time(Duration::from_secs(30)).sample_size(20);
targets = full_recalculation_simple_benchmark, full_recalculation_berlin_benchmark
config = Criterion::default().measurement_time(Duration::from_secs(60)).sample_size(20);
targets = full_recalculation_simple_benchmark, full_recalculation_karlsruhe_benchmark
);
criterion_group!(a_star_benches, a_star_benchmark);
criterion_main!(
Expand Down
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
doc-valid-idents = ["GraphML", ".."]
too-many-arguments-threshold = 8 # default is 7 but we have a lot of functions with 8 arguments
Loading

0 comments on commit c98222c

Please sign in to comment.