Skip to main content

multiobjective_search/
lib.rs

1//! # Multi-objective search
2//!
3//! Multi-objective shortest paths over Pareto frontiers: BOA*, BOBA*, EMOA*, NAMOA*dr, A*pex
4//! and their approximate, anytime and parallel variants.
5//!
6//! Given a graph whose edges carry cost vectors, the algorithms find one path
7//! for every Pareto-optimal cost vector from a start state to a goal.
8//!
9//! ## Contents
10//!
11//! | Function | Objectives | Heuristic | Notes |
12//! |---|---|---|---|
13//! | [`boa_star`] | 2 | consistent | Fastest unidirectional choice for two objectives. |
14//! | [`boa_star_approx`] | 2 | consistent | BOA* with an additive tolerance on the second objective. |
15//! | [`boa_star_eps`] | 2 | consistent | BOA*ε: BOA* with a factor `1 + ε` on the second objective. |
16//! | [`boa_star_anytime`] | 2 | consistent | A-BOA*ε: anytime, ever better approximations down to the exact front; `_ws` adds weighted-sum pruning, `_basic` is the no-reuse baseline. |
17//! | [`pp_a_star_iterative`] | 2 | consistent | Iterative-PP-A*: PP-A* from scratch over a falling tolerance schedule, the anytime baseline. |
18//! | [`pp_a_star`] | 2 | consistent | PP-A*: path pairs, factors `1 + ε1` and `1 + ε2` on both objectives. |
19//! | [`apex_star`] | any `N` | consistent | A*pex: apex-path pairs, a factor `1 + ε_i` per objective. |
20//! | [`apex_star_anytime`] | any `N` | consistent | A-A*pex: A*pex over a falling tolerance schedule, reusing earlier solutions. |
21//! | [`boba_star`] | 2 | computed internally | Bidirectional; needs a [`ReverseGraph`] and a single goal. |
22//! | [`boba_star_with`] | 2 | consistent, both directions | [`boba_star`] with caller-supplied heuristics. |
23//! | [`emoa_star`] | any `N` | consistent | Lazy open list, truncated dominance; `O(log n)` checks for 3 objectives. |
24//! | [`emoa_star_tree`] | any `N` | consistent | EMOA* with the paper's balanced-tree frontiers. |
25//! | [`namoa_star_dr`] | any `N` | consistent | NAMOA* with dimensionality reduction. |
26//! | [`namoa_star_dr_mvh_lazy`] | any `N` | admissible, multi-valued | L-NAMOA*dr-mvh: NAMOA*dr with a [`MvHeuristic`] and lazy dimensionality reduction. |
27//! | [`namoa_star_dr_mvh`] | any `N` | consistent, multi-valued | NAMOA*dr-mvh: one label per estimate; a baseline, slower than the lazy variant. |
28//! | [`namoa_star`] | any `N` | admissible | Classic baseline; label-setting with [`ZeroHeuristic`]. |
29//! | [`minsum_maxmin`] | sum + bottleneck | consistent on the sum | Minimal cost, maximal bottleneck capacity (Martins 1984). |
30//! | [`minsum_maxmin_multi`] | `N` sums + `M` bottlenecks | consistent on the sums | Several maxmin objectives. |
31//! | [`min_cost_capacity_ratio`], [`quickest_path`] | sum + bottleneck | consistent on the sum | Ratio and quickest-path objectives read off the minsum–maxmin front. |
32//! | [`constrained_shortest_path`] | 2 | consistent | Cheapest path with the second cost within a budget. |
33//! | [`two_phase`](fn@two_phase) | 2 | consistent | Two-phase method: supported solutions by weighted sums ([`supported_solutions`]), then the rest. |
34//! | [`ReferencePoint`] | any `N` | admissible | Interactive: non-dominated solutions by Chebyshev distance to a movable reference point. |
35//! | [`fptas_constrained`] | 2 | none | FPTAS for the constrained shortest path: polynomially many labels, first cost within `1 + ε`. |
36//! | [`min_ratio_path`], [`min_cost_reliability_ratio`] | ratio | none | Linear fractional (Dinkelbach, exact signed arithmetic) and cost/reliability ratios. |
37//! | [`ranking`](fn@ranking) | 2 | consistent | The classic ranking method: loopless paths by first cost. |
38//! | [`disjoint_pair`] | scalar | none | Suurballe: the cheapest edge- or state-disjoint pair; [`supported_disjoint_pairs`] for two objectives, [`disjoint_pair_front`] for the full bi-objective front, [`maximally_disjoint_pairs`] for cost against shared edges, [`dissimilar_paths`] for k dissimilar paths. Needs an [`EdgeGraph`]. |
39//! | [`aggregated_search`] | `M` hidden, `K` solution | admissible in the hidden space | Objective-aggregation functions over hidden objectives, exact or ε-approximate. |
40//! | [`label_correcting`](fn@label_correcting) | any `N` | none | Multi-objective label correcting (Guerriero and Musmanno). |
41//! | [`DynamicSearch`] | any `N` | none | Dynamic MOS: incremental repair after edge changes on a [`DynamicGraph`]. |
42//! | [`pareto_spanning_trees`] | any `N` | none | Multi-objective minimum spanning trees; [`two_phase_spanning_trees`] for two objectives. |
43//! | [`tpa_paths`] | any `N` | admissible | TPA: exact anytime box splitting with augmented-Tchebycheff subproblems, well spread early; [`tpa`](fn@tpa) over any solver. |
44//! | [`brute_force`] | any `N` | none | Exhaustive reference for tests on small graphs. |
45//!
46//! Supporting types:
47//!
48//! - [`Front`] and [`BiFront`]: Pareto frontiers, `O(log n)` queries for two
49//!   objectives; [`TreeFront`]: a balanced-tree frontier for four or more.
50//! - [`Graph`] and [`ReverseGraph`]: the search-space interface.
51//! - [`Heuristic`], [`heuristic_fn`] and [`ZeroHeuristic`]: per-objective
52//!   lower bounds. The trait comes from `search-core` and takes `&mut self`;
53//!   algorithms take the heuristic by value, so pass `&mut h` to keep it.
54//! - [`MvHeuristic`], [`mv_heuristic_fn`] and [`SingleValued`]: multi-valued
55//!   heuristics, a set of lower bounds per state.
56//! - [`IdealPoint`] and [`DifferentialHeuristic`]: heuristic builders, the
57//!   ideal point from per-objective backward Dijkstras and landmark-based
58//!   differential heuristics.
59//! - [`Cost`] (from `search-core`) and [`Dominates`]: scalar costs and
60//!   Pareto dominance.
61//! - [`Output`]: solutions sorted lexicographically by cost, plus counters.
62//! - [`RoadGraph`]: a loader for 9th DIMACS Challenge road networks
63//!   (`.gr` distance and time files, `.co` coordinates).
64//! - [`KnapsackGraph`] and [`LabelCount`]: graphs that encode
65//!   multi-objective knapsacks and the minimum-label objective as additive
66//!   paths for every search.
67//! - [`BenchmarkGraph`] with [`random_grid`], [`netmaker`], [`guards_grid`]
68//!   and [`road_extended`]: the standardized benchmark suite of Peer et al.,
69//!   generated from its definitions.
70//! - [`Epsilon`]: a rational tolerance `ε = num / den` for the approximate
71//!   searches, tested with [`Cost::saturating_times`].
72//!
73//! ## Features
74//!
75//! - `std`: links `std`; no API of its own.
76//! - `parallel` (implies `std`): multi-threaded BOBA*,
77//!   `boba_star_parallel` and `boba_star_with_parallel`, and SIP-MOSP
78//!   (`sip_mosp`), an asynchronous parallel exact search for any `N`, and
79//!   parallel MOA* (`parallel_moa_star`), one search per objective order.
80//!
81//! Without features the crate is `no_std` with `alloc`.
82//!
83//! Repository: <https://github.com/sunsided/multiobjective-search>
84
85#![no_std]
86#![forbid(unsafe_code)]
87
88extern crate alloc;
89#[cfg(feature = "std")]
90extern crate std;
91
92mod aggregate;
93mod anytime_boa;
94mod apex;
95mod benchmarks;
96mod boa;
97mod boba;
98mod bottleneck;
99mod constrained;
100mod correlation;
101mod cost;
102mod dimacs;
103mod disjoint;
104mod dynamic;
105mod emoa;
106mod encode;
107mod epsilon;
108mod fptas;
109mod fractional;
110mod frontier_search;
111mod graph;
112mod heuristics;
113mod indicators;
114mod label_correcting;
115mod mvh;
116mod namoa;
117mod namoa_mvh;
118mod output;
119#[cfg(feature = "parallel")]
120mod parallel_moa;
121mod pareto;
122mod pp_a;
123mod ranking;
124mod reference;
125mod reference_point;
126#[cfg(feature = "parallel")]
127mod sip;
128mod spanning;
129mod tpa;
130mod two_phase;
131
132pub use aggregate::{Aggregated, Aggregation, aggregated_search};
133pub use anytime_boa::{
134    AnytimeFront, ApproxFactor, WeightedSum, boa_star_anytime, boa_star_anytime_basic,
135    boa_star_anytime_ws,
136};
137pub use apex::{
138    AnytimeApex, MergeRule, apex_star, apex_star_anytime, apex_star_anytime_with, apex_star_with,
139};
140pub use benchmarks::{
141    BenchmarkGraph, Query, guards_grid, netmaker, netmaker_queries, random_grid, road_extended,
142};
143pub use boa::{boa_star, boa_star_approx, boa_star_eps};
144pub use boba::{boba_star, boba_star_with};
145#[cfg(feature = "parallel")]
146pub use boba::{boba_star_parallel, boba_star_with_parallel};
147pub use bottleneck::{
148    Bottleneck, SumsAndWidths, WidePath, min_cost_capacity_ratio, minsum_maxmin,
149    minsum_maxmin_multi, quickest_path,
150};
151pub use constrained::constrained_shortest_path;
152pub use correlation::{Correlation, objective_correlation};
153pub use cost::{Dominates, add, weakly_dominates};
154pub use dimacs::{DimacsError, DimacsErrorKind, RoadGraph};
155pub use disjoint::{
156    CostedPair, Disjointness, PathPair, RankedPath, SharedPair, disjoint_pair, disjoint_pair_front,
157    dissimilar_paths, maximally_disjoint_pairs, supported_disjoint_pairs,
158};
159pub use dynamic::{DynamicGraph, DynamicSearch};
160pub use emoa::{emoa_star, emoa_star_tree};
161pub use encode::{KnapsackGraph, LabelCount};
162pub use epsilon::Epsilon;
163pub use fptas::fptas_constrained;
164pub use fractional::{ExactReliability, Reliability, min_cost_reliability_ratio, min_ratio_path};
165pub use graph::{EdgeGraph, Graph, ReverseGraph, ZeroHeuristic};
166pub use heuristics::{DifferentialHeuristic, IdealPoint, Towards};
167pub use indicators::hypervolume;
168pub use label_correcting::label_correcting;
169pub use mvh::{MvHeuristic, MvHeuristicFn, MvhTable, SingleValued, apex_mvh, mv_heuristic_fn};
170pub use namoa::{namoa_star, namoa_star_dr};
171pub use namoa_mvh::{namoa_star_dr_mvh, namoa_star_dr_mvh_lazy};
172pub use output::{Output, Solution, Stats};
173#[cfg(feature = "parallel")]
174pub use parallel_moa::parallel_moa_star;
175pub use pareto::{BiFront, Front, FrontIndex, IndexedFront, TreeFront};
176pub use pp_a::{pp_a_star, pp_a_star_iterative};
177pub use ranking::ranking;
178pub use reference::brute_force;
179pub use reference_point::{Achievement, ReferencePoint, achievement};
180pub use search_core::{Cost, Heuristic, HeuristicFn, heuristic_fn};
181#[cfg(feature = "parallel")]
182pub use sip::{SipConfig, sip_mosp};
183pub use spanning::{
184    Tree, TreeEdge, pareto_spanning_trees, supported_spanning_trees, two_phase_spanning_trees,
185};
186pub use tpa::{PathTchebycheff, Scalarization, TchebycheffSolver, TpaResult, tpa, tpa_paths};
187pub use two_phase::{supported_solutions, two_phase};
188
189/// Doctests for the code examples in README.md (not part of the API).
190#[cfg(doctest)]
191#[doc = include_str!("../README.md")]
192mod readme_doctests {}