1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! You may override individual costing strategies
//! in order to apply custom functionality to the
//! transition solver. See the [`Strategy`] trait.
//!
//! ## Structure
//! Strategies are joined onto the aggregate [`CostingStrategies`]
//! structure, which is then supplied to the relevant transition
//! graph constructor.
//!
//! ```rust
//! use routers::route::transition::CostingStrategies;
//! use routers::route::transition::graph::Transition;
//!
//! // Create default strategies
//! let costing = CostingStrategies::default();
//!
//! // Supply them to the relevant constructor
//! let transition = Transition::new(todo!(), todo!(), costing);
//!```
//!
//! To override the default strategies, simply apply your own
//! using [`CostingStrategies::new`]. You must create an [`EmissionStrategy`]
//! and [`TransitionStrategy`].
//!
//! ### Creating your own strategy / heuristic
//!
//! In order to make your own transition and emission strategies, you must
//! implement [`Strategy`] for your structure, with the context of the heuristic
//! you need to override.
//!
//! The higher-order traits, like [`TransitionStrategy`] are auto-derived for all
//! which implement [`Strategy<TransitionContext>`].
//!
//!```rust
//! use routers_network::Entry;
//! use routers::route::transition::{Strategy, TransitionContext};
//!
//! struct MyTransitionStrategy;
//!
//! // Implement the strategy with the correct context.
//! impl<'a, E> Strategy<TransitionContext<'a, E>> for MyTransitionStrategy where E: Entry {
//! type Cost = f64;
//!
//! const ZETA: f64 = 1.0;
//! const BETA: f64 = -50.0;
//!
//! fn calculate(&self, context: TransitionContext<'a, E>) -> Option<Self::Cost> {
//! todo!()
//! }
//! }
//! ```
//!
//! Note that each require consuming their own context. See below.
//!
//! ### Using Context
//! Each strategy accepts a context, defined in the
//! generic `Ctx` parameter of the [`Strategy`] trait.
//! Each context is defined statically:
//!
//! - [`TransitionContext`]
//! Used for the transition costing strategy,
//! supplies relevant information for the candidates
//! being routed between, and the optimal trip between them.
//!
//! - [`EmissionContext`]
//! Used to understand the cost associated with
//! the selection of a candidate, relative to an optimal
//! selection on the underlying routing data.
//!
//! There are two static heuristics which must have
//! a strategy defined for them in order to evaluate
//! the costing behind them. A default strategy for each
//! one is defined below.
//!
//! ### Default Strategies:
//! - [`DefaultTransitionCost`]: Transition Cost
//! - [`DefaultEmissionCost`]: Emission Cost
//!
pub use *;
pub use *;
pub use *;
pub use *;