Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ geometry = { input_file = "edges-geometries-enumerated.txt.gz" }
tolerance.distance = 15.0
# mapping threshold distance unit
tolerance.unit = "meters"
# allow queries without destinations, for shortest path tree results
# allow queries without destinations, for shortest path results
queries_without_destinations = true
# whether we match queries via "point", "vertex_id", or "edge_id" (or arrays of combinations)
matching_type = "point"
Expand Down
6 changes: 3 additions & 3 deletions rust/routee-compass-codegen/src/generator/traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ pub fn model_template(pascal_case_name: &str, extensions: Option<&TraversalExten
{super_import}

use routee_compass_core::{{
algorithm::search::SearchTree,
algorithm::search::SearchGraph,
model::{{
network::{{Edge, Vertex}},
state::{{InputFeature, StateModel, StateVariable, StateVariableConfig}},
Expand All @@ -471,7 +471,7 @@ pub fn model_template(pascal_case_name: &str, extensions: Option<&TraversalExten
&self,
_trajectory: (&Vertex, &Edge, &Vertex),
_state: &mut Vec<StateVariable>,
_tree: &SearchTree,
_tree: &SearchGraph,
_state_model: &StateModel,
) -> Result<(), TraversalModelError> {{
todo!()
Expand All @@ -481,7 +481,7 @@ pub fn model_template(pascal_case_name: &str, extensions: Option<&TraversalExten
&self,
_od: (&Vertex, &Vertex),
_state: &mut Vec<StateVariable>,
_tree: &SearchTree,
_tree: &SearchGraph,
_state_model: &StateModel,
) -> Result<(), TraversalModelError> {{
todo!()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use thiserror::Error;

use crate::algorithm::search::{SearchError, SearchTreeError};
use crate::algorithm::search::{SearchError, SearchGraphError};
use crate::model::map::MapError;

/// Error types for map matching operations.
Expand All @@ -24,8 +24,8 @@ pub enum MapMatchingError {
#[error("search error: {0}")]
SearchError(#[from] SearchError),

#[error("search tree error: {0}")]
SearchTreeError(#[from] SearchTreeError),
#[error("search graph error: {0}")]
SearchGraphError(#[from] SearchGraphError),

#[error("internal error: {0}")]
InternalError(String),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub(crate) fn run_shortest_path(
.collect();
Ok(edge_ids)
}
Err(e) => Err(MapMatchingError::SearchTreeError(e)),
Err(e) => Err(MapMatchingError::SearchGraphError(e)),
},
Err(SearchError::NoPathExistsBetweenVertices(_, _, _)) => Ok(Vec::new()),
Err(e) => Err(MapMatchingError::SearchError(e)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use crate::algorithm::search::a_star::frontier_instance::FrontierInstance;
use crate::algorithm::search::Direction;
use crate::algorithm::search::EdgeTraversal;
use crate::algorithm::search::SearchError;
use crate::algorithm::search::SearchGraph;
use crate::algorithm::search::SearchInstance;
use crate::algorithm::search::SearchResult;
use crate::algorithm::search::SearchTree;
use crate::model::cost::TraversalCost;
use crate::model::label::Label;
use crate::model::network::EdgeListId;
Expand Down Expand Up @@ -37,14 +37,14 @@ pub fn run_vertex_oriented(
let initial_label =
si.label_model
.label_from_state(source, &initial_state, &si.state_model)?;
let tree = SearchTree::with_root(initial_label, *direction);
return Ok(SearchResult::completed(tree, 0));
let graph = SearchGraph::with_root(initial_label, *direction);
return Ok(SearchResult::completed(graph, 0));
}

// context for the search (graph, search functions, frontier priority queue)
let mut frontier: InternalPriorityQueue<Label, ReverseCost> = InternalPriorityQueue::default();
let mut traversal_costs: HashMap<Label, Cost> = HashMap::new();
let mut solution = SearchTree::new(*direction);
let mut solution = SearchGraph::new(*direction);

// setup initial search state
let initial_state = si.state_model.initial_state(None)?;
Expand Down Expand Up @@ -200,8 +200,8 @@ pub fn run_edge_oriented(
let initial_label =
si.label_model
.label_from_state(e1_dst, &initial_state, &si.state_model)?;
let tree = SearchTree::with_root(initial_label, *direction);
Ok(SearchResult::completed(tree, 0))
let graph = SearchGraph::with_root(initial_label, *direction);
Ok(SearchResult::completed(graph, 0))
} else {
run_vertex_oriented(e1_dst, Some(e2_src), direction, a_star, si)
}
Expand All @@ -215,7 +215,7 @@ pub fn estimate_traversal_cost(
src: VertexId,
dst: VertexId,
state: &[StateVariable],
tree: &SearchTree,
graph: &SearchGraph,
si: &SearchInstance,
) -> Result<TraversalCost, SearchError> {
let src = si.graph.get_vertex(&src)?;
Expand All @@ -225,7 +225,7 @@ pub fn estimate_traversal_cost(
si.get_traversal_estimation_model().estimate_traversal(
(src, dst),
&mut dst_state,
tree,
graph,
&si.state_model,
)?;
let cost_estimate = si.cost_model.estimate_cost(&dst_state, &si.state_model)?;
Expand Down Expand Up @@ -463,7 +463,7 @@ mod tests {
let si = build_search_instance(graph.clone());

// execute the route search
let result: Vec<Result<SearchTree, SearchError>> = queries
let result: Vec<Result<SearchGraph, SearchError>> = queries
.clone()
.into_par_iter()
.map(|(o, d, _expected)| {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
algorithm::search::{SearchError, SearchTree},
algorithm::search::{SearchError, SearchGraph},
model::{
label::Label,
network::{EdgeId, EdgeListId, VertexId},
Expand Down Expand Up @@ -39,7 +39,7 @@ impl FrontierInstance {
frontier: &mut InternalPriorityQueue<Label, ReverseCost>,
source: VertexId,
target: Option<VertexId>,
solution: &SearchTree,
solution: &SearchGraph,
initial_state: &[StateVariable],
) -> Result<Option<FrontierInstance>, SearchError> {
loop {
Expand Down Expand Up @@ -101,7 +101,7 @@ mod tests {
#[test]
fn test_pop_new_empty_queue() {
let mut frontier = InternalPriorityQueue::default();
let solution = SearchTree::new(Direction::Forward);
let solution = SearchGraph::new(Direction::Forward);
let initial_state = vec![StateVariable::ZERO];
let result =
FrontierInstance::pop_new(&mut frontier, VertexId(0), None, &solution, &initial_state)
Expand All @@ -112,7 +112,7 @@ mod tests {
#[test]
fn test_pop_new_no_path_exists() {
let mut frontier = InternalPriorityQueue::default();
let solution = SearchTree::new(Direction::Forward);
let solution = SearchGraph::new(Direction::Forward);
let initial_state = vec![StateVariable::ZERO];
let result = FrontierInstance::pop_new(
&mut frontier,
Expand All @@ -129,7 +129,7 @@ mod tests {
let mut frontier = InternalPriorityQueue::default();
let label = Label::Vertex(VertexId(0));
frontier.push(label.clone(), ReverseCost::from(Cost::ZERO));
let solution = SearchTree::new(Direction::Forward);
let solution = SearchGraph::new(Direction::Forward);
let initial_state = vec![StateVariable::ZERO];
let result =
FrontierInstance::pop_new(&mut frontier, VertexId(0), None, &solution, &initial_state)
Expand All @@ -148,7 +148,7 @@ mod tests {
frontier.push(l2.clone(), ReverseCost::from(Cost::new(5.0)));
frontier.push(l1.clone(), ReverseCost::from(Cost::new(10.0)));

let mut solution = SearchTree::new(Direction::Forward);
let mut solution = SearchGraph::new(Direction::Forward);
let root = Label::Vertex(VertexId(0));
solution.set_root(root.clone());

Expand Down Expand Up @@ -184,7 +184,7 @@ mod tests {
let label = Label::Vertex(target);
frontier.push(label, ReverseCost::from(Cost::ZERO));

let solution = SearchTree::new(Direction::Forward);
let solution = SearchGraph::new(Direction::Forward);
let initial_state = vec![StateVariable::ZERO];

// Reaching target vertex should return Ok(None)
Expand Down Expand Up @@ -217,7 +217,7 @@ mod tests {
frontier.push(l2.clone(), ReverseCost::from(Cost::new(5.0)));
frontier.push(l1.clone(), ReverseCost::from(Cost::new(10.0)));

let mut solution = SearchTree::new(Direction::Forward);
let mut solution = SearchGraph::new(Direction::Forward);
let root = Label::Vertex(VertexId(0));
solution.set_root(root.clone());

Expand Down
12 changes: 6 additions & 6 deletions rust/routee-compass-core/src/algorithm/search/edge_traversal.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::search_error::SearchError;
use super::SearchInstance;
use crate::algorithm::search::SearchTree;
use crate::algorithm::search::SearchGraph;
use crate::model::cost::{CostModel, TraversalCost};
use crate::model::network::{Edge, EdgeId, EdgeListId, Vertex};
use crate::model::state::{StateModel, StateVariable};
Expand Down Expand Up @@ -53,7 +53,7 @@ impl EdgeTraversal {
/// An edge traversal summarizing the costs and result state of accessing and traversing the next edge.
pub fn new(
next_edge: (EdgeListId, EdgeId),
tree: &SearchTree,
graph: &SearchGraph,
prev_state: &[StateVariable],
si: &SearchInstance,
) -> Result<EdgeTraversal, SearchError> {
Expand All @@ -63,7 +63,7 @@ impl EdgeTraversal {
let tm = si.get_traversal_model(&edge_list_id)?;
Self::new_local(
trajectory,
tree,
graph,
prev_state,
&si.state_model.clone(),
tm.clone().as_ref(),
Expand All @@ -78,7 +78,7 @@ impl EdgeTraversal {
/// method and does not require [`Arc`]-wrapped types.
pub fn new_local(
trajectory: (&Vertex, &Edge, &Vertex),
tree: &SearchTree,
graph: &SearchGraph,
prev_state: &[StateVariable],
state_model: &StateModel,
traversal_model: &dyn TraversalModel,
Expand All @@ -87,10 +87,10 @@ impl EdgeTraversal {
let (_, edge, _) = trajectory;
let mut result_state = state_model.initial_state(Some(prev_state))?;

traversal_model.traverse_edge(trajectory, &mut result_state, tree, state_model)?;
traversal_model.traverse_edge(trajectory, &mut result_state, graph, state_model)?;

let cost =
cost_model.traversal_cost(trajectory, prev_state, &result_state, tree, state_model)?;
cost_model.traversal_cost(trajectory, prev_state, &result_state, graph, state_model)?;

let result = EdgeTraversal {
edge_list_id: edge.edge_list_id,
Expand Down
10 changes: 5 additions & 5 deletions rust/routee-compass-core/src/algorithm/search/ksp/svp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
algorithm::search::{
a_star::a_star_ops, direction::Direction, edge_traversal::EdgeTraversal,
search_algorithm::SearchAlgorithm, search_algorithm_result::SearchAlgorithmResult,
search_error::SearchError, util::RouteSimilarityFunction, SearchInstance, SearchTreeNode,
search_error::SearchError, util::RouteSimilarityFunction, SearchGraphNode, SearchInstance,
},
model::{network::VertexId, unit::ReverseCost},
util::priority_queue::InternalPriorityQueue,
Expand All @@ -21,7 +21,7 @@ pub fn run(
) -> Result<SearchAlgorithmResult, SearchError> {
// run forward and reverse search
let SearchAlgorithmResult {
trees: fwd_trees,
graphs: fwd_trees,
routes: _,
iterations: fwd_iterations,
terminated: fwd_terminated,
Expand All @@ -33,7 +33,7 @@ pub fn run(
si,
)?;
let SearchAlgorithmResult {
trees: rev_trees,
graphs: rev_trees,
routes: _,
iterations: rev_iterations,
terminated: rev_terminated,
Expand Down Expand Up @@ -79,7 +79,7 @@ pub fn run(
None => continue,
Some(et) => et,
};
if let Some(SearchTreeNode::Branch { incoming_edge, .. }) = rev_labels.get(label) {
if let Some(SearchGraphNode::Branch { incoming_edge, .. }) = rev_labels.get(label) {
if rev_labels.contains_key(&label) {
let total_cost = fwd_et.cost.total_cost + incoming_edge.cost.total_cost;
intersection_queue.push(*label.vertex_id(), total_cost.into());
Expand Down Expand Up @@ -158,7 +158,7 @@ pub fn run(

// combine all data into this result
let result = SearchAlgorithmResult {
trees: vec![fwd_tree.clone(), rev_tree.clone()], // todo: figure out how to avoid this clone
graphs: vec![fwd_tree.clone(), rev_tree.clone()], // todo: figure out how to avoid this clone
routes,
iterations: fwd_iterations + rev_iterations + ksp_it, // todo: figure out how to report individually
terminated,
Expand Down
2 changes: 1 addition & 1 deletion rust/routee-compass-core/src/algorithm/search/ksp/yens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub fn run(
}

let result = SearchAlgorithmResult {
trees: shortest.trees,
graphs: shortest.graphs,
routes: accepted,
iterations,
terminated: None,
Expand Down
8 changes: 4 additions & 4 deletions rust/routee-compass-core/src/algorithm/search/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ mod search_algorithm;
mod search_algorithm_config;
mod search_algorithm_result;
mod search_error;
mod search_graph;
mod search_graph_node;
mod search_instance;
mod search_result;
mod search_tree;
mod search_tree_node;
mod termination_behavior;

pub mod a_star;
Expand All @@ -20,8 +20,8 @@ pub use search_algorithm::SearchAlgorithm;
pub use search_algorithm_config::SearchAlgorithmConfig;
pub use search_algorithm_result::SearchAlgorithmResult;
pub use search_error::SearchError;
pub use search_graph::{SearchGraph, SearchGraphError};
pub use search_graph_node::SearchGraphNode;
pub use search_instance::SearchInstance;
pub use search_result::SearchResult;
pub use search_tree::{SearchTree, SearchTreeError};
pub use search_tree_node::SearchTreeNode;
pub use termination_behavior::TerminationFailurePolicy;
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl SearchAlgorithm {
}
};
Ok(SearchAlgorithmResult {
trees: vec![search_result.tree],
graphs: vec![search_result.tree],
routes,
iterations: search_result.iterations,
terminated: search_result.terminated.clone(),
Expand Down Expand Up @@ -144,7 +144,7 @@ impl SearchAlgorithm {
}
};
Ok(SearchAlgorithmResult {
trees: vec![search_result.tree],
graphs: vec![search_result.tree],
routes,
iterations: search_result.iterations,
terminated: search_result.terminated.clone(),
Expand Down Expand Up @@ -244,7 +244,7 @@ pub fn run_edge_oriented(
match target {
None => {
let SearchAlgorithmResult {
mut trees,
graphs: mut trees,
mut routes,
iterations,
terminated,
Expand All @@ -268,7 +268,7 @@ pub fn run_edge_oriented(
route.insert(0, src_et.clone());
}
let updated = SearchAlgorithmResult {
trees,
graphs: trees,
routes,
iterations: iterations + 1,
terminated,
Expand All @@ -283,11 +283,11 @@ pub fn run_edge_oriented(
}

// removed specialized case that depended on creating EdgeTraversals mechanically. broken
// (without substantial refactor) with the inclusion of the SearchTree abstraction.
// (without substantial refactor) with the inclusion of the SearchGraph abstraction.

// run a search and append source/target edges to result
let SearchAlgorithmResult {
trees,
graphs: trees,
mut routes,
iterations,
terminated,
Expand Down Expand Up @@ -315,7 +315,7 @@ pub fn run_edge_oriented(
}

let result = SearchAlgorithmResult {
trees,
graphs: trees,
routes,
iterations: iterations + 2,
terminated,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use allocative::Allocative;

use super::edge_traversal::EdgeTraversal;
use crate::algorithm::search::SearchTree;
use crate::algorithm::search::SearchGraph;

#[derive(Default, Allocative)]
pub struct SearchAlgorithmResult {
pub trees: Vec<SearchTree>,
pub graphs: Vec<SearchGraph>,
pub routes: Vec<Vec<EdgeTraversal>>,
pub iterations: u64,
pub terminated: Option<String>,
Expand Down
Loading