Skip to main content

SearchInstance

Struct SearchInstance 

Source
pub struct SearchInstance {
    pub graph: Arc<Graph>,
    pub constraint_models: Vec<Arc<dyn ConstraintModel>>,
    pub traversal_models: Vec<Arc<dyn TraversalModel>>,
    pub map_model: Arc<MapModel>,
    pub state_model: Arc<StateModel>,
    pub cost_model: Arc<CostModel>,
    pub termination_model: Arc<TerminationModel>,
    pub label_model: Arc<dyn LabelModel>,
    pub default_edge_list: Option<usize>,
}
Expand description

A SearchInstance represents the collection of read-only models and data required to execute a search query. It encapsulates the graph, constraints, traversal logic, cost calculations, and termination criteria, providing a unified interface for search algorithms to interact with the underlying network and models.

Fields§

§graph: Arc<Graph>§constraint_models: Vec<Arc<dyn ConstraintModel>>§traversal_models: Vec<Arc<dyn TraversalModel>>§map_model: Arc<MapModel>§state_model: Arc<StateModel>§cost_model: Arc<CostModel>§termination_model: Arc<TerminationModel>§label_model: Arc<dyn LabelModel>§default_edge_list: Option<usize>

Implementations§

Source§

impl SearchInstance

Source

pub fn get_traversal_estimation_model(&self) -> Arc<dyn TraversalModel>

Retrieves the traversal model that should be used for traversal estimation when no specific edge is being traversed (e.g., at the start of a search or when calculating heuristics). It falls back to the default edge list’s model.

Source

pub fn get_constraint_model( &self, edge_list_id: &EdgeListId, ) -> Result<Arc<dyn ConstraintModel>, SearchError>

Retrieves the constraint model associated with a specific edge list.

§Arguments
  • edge_list_id - The ID of the edge list to get the constraint model for.
§Returns

A reference to the constraint model, or an error if the ID is not found.

Source

pub fn get_traversal_model( &self, edge_list_id: &EdgeListId, ) -> Result<Arc<dyn TraversalModel>, SearchError>

Retrieves the traversal model associated with a specific edge list.

§Arguments
  • edge_list_id - The ID of the edge list to get the traversal model for.
§Returns

A reference to the traversal model, or an error if the ID is not found.

Source

pub fn compute_path( &self, path: &[(EdgeListId, EdgeId)], ) -> Result<Vec<EdgeTraversal>, SearchError>

Computes the sequence of EdgeTraversal objects for a given path of edge IDs.

This method is essential for reconstructing the full state (costs, state transitions) along a path that was generated by an external process, such as map matching, which typically only returns a sequence of edge identifiers.

§Implementation Note: Vector Index Tracking

When building the internal SearchTree for the path, this method uses “indexed labels” (Label::VertexWithIntState) where the state is the current index in the path.

We must track the vector index of each insertion for the following reasons:

  1. Path Cycles: A path may visit the same vertex multiple times (e.g., in complex intersections or specific routing constraints). If we used plain Label::Vertex, subsequent visits to the same vertex would overwrite previous entries in the SearchTree’s internal map, breaking the tree structure.
  2. Backtracking: The SearchTree depends on unique labels to correctly backtrack from a destination to the root. By indexing each step, we ensure that every node in the path is a unique entity in the tree, even if they share the same physical vertex.
  3. State Consistency: It ensures that the state at each step of the path is linearly associated with its predecessor, avoiding any ambiguity that could arise if multiple paths through the same vertex were present in the tree.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool