cleaned up the benchmark programm
This commit is contained in:
parent
2aeb770b8f
commit
f11dda3939
1 changed files with 43 additions and 45 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use clap::Parser;
|
||||
use fapra_osm_2::alt::{LandmarkSet, LandmarkBestSet};
|
||||
use fapra_osm_2::astar::{estimate_haversine, estimate_latitude, AStar};
|
||||
use fapra_osm_2::alt::{LandmarkBestSet, LandmarkSet};
|
||||
use fapra_osm_2::astar::{estimate_haversine, AStar};
|
||||
use fapra_osm_2::gridgraph::{GridGraph, NodeId};
|
||||
use fapra_osm_2::utils::RoutingQuery;
|
||||
use serde_json;
|
||||
|
|
@ -20,9 +20,9 @@ struct Args {
|
|||
#[clap(short, long)]
|
||||
targets: String,
|
||||
|
||||
/// landmark file
|
||||
/// landmark file. ALT Benchmarks are only run, if this is given.
|
||||
#[clap(short, long)]
|
||||
landmarks: String,
|
||||
landmarks: Option<String>,
|
||||
|
||||
/// run dijkstra
|
||||
#[clap(long, action)]
|
||||
|
|
@ -32,9 +32,9 @@ struct Args {
|
|||
#[clap(long, action)]
|
||||
astar: bool,
|
||||
|
||||
/// run ALT
|
||||
#[clap(long, action)]
|
||||
alt: bool,
|
||||
/// How many of the given landmarks to select
|
||||
#[clap(long, action, default_value_t = 4)]
|
||||
alt_best_size: usize,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
@ -56,6 +56,8 @@ fn main() {
|
|||
}
|
||||
};
|
||||
|
||||
let astar = AStar { graph: &(*graph) };
|
||||
|
||||
let targets = match File::open(args.targets.clone()) {
|
||||
Ok(f) => f,
|
||||
Err(e) => {
|
||||
|
|
@ -66,12 +68,13 @@ fn main() {
|
|||
|
||||
let targets: Vec<RoutingQuery> = serde_json::from_reader(BufReader::new(targets)).unwrap();
|
||||
|
||||
let landmarks = match File::open(args.landmarks.clone()) {
|
||||
if let Some(landmark_path) = args.landmarks {
|
||||
let landmarks = match File::open(landmark_path.clone()) {
|
||||
Ok(f) => f,
|
||||
Err(e) => {
|
||||
println!(
|
||||
"Error while opening landmark file {}: {:?}",
|
||||
args.landmarks, e
|
||||
landmark_path, e
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -79,9 +82,30 @@ fn main() {
|
|||
|
||||
let landmarks: LandmarkSet = bincode::deserialize_from(BufReader::new(landmarks)).unwrap();
|
||||
|
||||
let astar = AStar { graph: &(*graph) };
|
||||
println!("running ALT");
|
||||
|
||||
println!("{:?}", args);
|
||||
let mut best_landmarks = LandmarkBestSet::new(args.alt_best_size, &landmarks);
|
||||
|
||||
let start = Instant::now();
|
||||
|
||||
for query in targets.iter() {
|
||||
// println!("working on {:?}", query);
|
||||
let source = astar.graph.nodes[query.source];
|
||||
let destination = astar.graph.nodes[query.destination];
|
||||
|
||||
best_landmarks.select_best(source.index as NodeId, destination.index as NodeId);
|
||||
|
||||
let _result = astar.shortest_path(&source, &destination, |src, dest| {
|
||||
best_landmarks.estimate(src.index as NodeId, dest.index as NodeId)
|
||||
});
|
||||
}
|
||||
|
||||
let elapsed = start.elapsed();
|
||||
|
||||
let time_per_route = elapsed.as_secs_f64() / (targets.len() as f64);
|
||||
|
||||
println!("It took {} seconds per route for ALT.", time_per_route);
|
||||
}
|
||||
|
||||
if args.astar {
|
||||
println!("running A*");
|
||||
|
|
@ -122,30 +146,4 @@ fn main() {
|
|||
let time_per_route = elapsed.as_secs_f64() / (targets.len() as f64);
|
||||
println!("It took {} seconds per round for Dijkstra.", time_per_route);
|
||||
}
|
||||
|
||||
if args.alt {
|
||||
println!("running ALT");
|
||||
|
||||
let mut best_landmarks = LandmarkBestSet::new(4, &landmarks);
|
||||
// Landmarks
|
||||
let start = Instant::now();
|
||||
|
||||
for query in targets.iter() {
|
||||
println!("working on {:?}", query);
|
||||
let source = astar.graph.nodes[query.source];
|
||||
let destination = astar.graph.nodes[query.destination];
|
||||
|
||||
best_landmarks.select_best(source.index as NodeId, destination.index as NodeId);
|
||||
|
||||
let _result = astar.shortest_path(&source, &destination, |src, dest| {
|
||||
best_landmarks.estimate(src.index as NodeId, dest.index as NodeId)
|
||||
});
|
||||
}
|
||||
|
||||
let elapsed = start.elapsed();
|
||||
|
||||
let time_per_route = elapsed.as_secs_f64() / (targets.len() as f64);
|
||||
|
||||
println!("It took {} seconds per route for ALT.", time_per_route);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue