vrp_core/lib.rs
1//! A core crate contains main buildings blocks for constructing heuristics and metaheuristic
2//! to solve rich [`Vehicle Routing Problem`](https://en.wikipedia.org/wiki/Vehicle_routing_problem).
3//!
4//! # Key points
5//!
6//! A basic idea of the core crate is to design a library which can be used to solve multiple
7//! variations of Vehicle Routing Problem (VRP) known also as a rich VRP. In order to achieve that,
8//! it defines essential domain models and implements default metaheuristic with preconfigured
9//! properties.
10//!
11//! Another goal is an intuitive design: it should be relatively easy to start using it without prior
12//! knowledge of the domain. That's why the API design does not try to generalize models and
13//! implementations in order to develop a general purpose metaheuristic.
14//! Check [rosomaxa](https://docs.rs/rosomaxa/latest) crate for more generic models/algorithms.
15//!
16//!
17//! Extra functionality, already developed on top of this crate, is available via following crates:
18//!
19//! - `vrp-scientific` crate supports VRP variations used in scientific benchmarks
20//! - `vrp-pragmatic` crate supports custom json format which can be used to model real world scenarios
21//! - `vrp-cli` crate provides a command line interface and static library with all available functionality
22//! provided by the project
23//!
24//! Meanwhile, the project tries to keep the list of dependencies relatively small, but "Not invented HERE"
25//! syndrome should be also avoided.
26//!
27//! The next sections explain some basic concepts such as types used to model VRP definition,
28//! constructive heuristics, metaheuristic, etc. Start exploring them, if you are curious about
29//! internal implementation or library extension. It you are looking just for user documentation,
30//! check the [`user guide`] documentation.
31//!
32//! [`user guide`]: https://reinterpretcat.github.io/vrp/
33//!
34//!
35//! # Modeling VRP
36//!
37//! Model definitions can be split into the following groups:
38//!
39//! - [`common`] group contains common models: time-specific, location, distance, etc.
40//! - [`problem`] group contains VRP definition models: job, vehicle, cost-specific, etc.
41//! - [`solution`] group contains models which used to represent a VRP solution: route, tour, activity, etc.
42//!
43//! Additionally, there are a key concepts such as `Feature` and `GoalContext`.
44//!
45//! Check corresponding modules for details.
46//!
47//! [`common`]: ./models/common/index.html
48//! [`problem`]: ./models/problem/index.html
49//! [`solution`]: ./models/solution/index.html
50//!
51//!
52//! # Constructive heuristic
53//!
54//! A constructive heuristic is a type of heuristic method which starts with an empty solution and
55//! repeatedly extends it until a complete solution is obtained.
56//!
57//! The crate implements various constructive heuristics in [`construction`] module.
58//!
59//! [`construction`]: ./construction/index.html
60//!
61//!
62//! # Metaheuristic
63//!
64//! A metaheuristic is a high-level algorithmic framework that provides a set of guidelines or strategies
65//! to develop heuristic optimization algorithms. One of its goals is to guide the search process towards
66//! optimal solution.
67//!
68//! See more details about it in `solver` module.
69//!
70//!
71//! # Examples
72//!
73//! Detailed examples for some of the VRP variants can be found in `examples` folder.
74//!
75//! Here, the example shows how to construct default configuration for the solver, override some
76//! of the default metaheuristic parameters using fluent interface methods, and run the solver:
77//!
78//! ```
79//! # use vrp_core::models::examples::create_example_problem;
80//! # use std::sync::Arc;
81//! use vrp_core::prelude::*;
82//!
83//! // create your VRP problem
84//! let problem: Arc<Problem> = create_example_problem();
85//! // build solver config using pre-build builder with defaults and then override some parameters
86//! let config = VrpConfigBuilder::new(problem.clone())
87//! .prebuild()?
88//! .with_max_time(Some(60))
89//! .with_max_generations(Some(100))
90//! .build()?;
91//!
92//! // run solver and get the best known solution.
93//! let solution = Solver::new(problem, config).solve()?;
94//!
95//! assert_eq!(solution.cost, 84.);
96//! assert_eq!(solution.routes.len(), 1);
97//! assert_eq!(solution.unassigned.len(), 0);
98//! # Ok::<(), GenericError>(())
99//! ```
100//!
101
102#![warn(missing_docs)]
103#![forbid(unsafe_code)]
104
105#[cfg(test)]
106#[path = "../tests/helpers/mod.rs"]
107#[macro_use]
108pub mod helpers;
109
110#[macro_use]
111pub mod macros;
112pub mod prelude;
113
114pub mod algorithms;
115pub mod construction;
116pub mod models;
117pub mod solver;
118pub mod utils;
119
120pub use rosomaxa;