vrp_scientific/common/
mod.rs1mod text_reader;
4
5pub(crate) use self::text_reader::*;
6use std::sync::Arc;
7
8mod text_writer;
9pub(crate) use self::text_writer::*;
10
11mod initial_reader;
12pub use self::initial_reader::read_init_solution;
13
14mod routing;
15
16pub use self::routing::{CoordIndex, CoordIndexExtraProperty};
17
18use vrp_core::models::Extras;
19use vrp_core::solver::{HeuristicFilterExtraProperty, HeuristicFilterFn};
20
21pub(crate) fn get_extras(coord_index: CoordIndex) -> Extras {
22 let mut extras = Extras::default();
23 let heuristic_filter_fn: HeuristicFilterFn = Arc::new(|name| name != "local_reschedule_departure");
24
25 extras.set_coord_index(Arc::new(coord_index));
26 extras.set_heuristic_filter(Arc::new(heuristic_filter_fn));
27
28 extras
29}
30
31pub(crate) trait TryCollect<T> {
34 fn try_collect_tuple(&mut self) -> Option<T>;
35}
36
37#[macro_export]
39macro_rules! impl_try_collect_tuple {
40 () => { };
41 ($A:ident $($I:ident)*) => {
42 impl_try_collect_tuple!($($I)*);
43
44 impl<$A: Iterator> TryCollect<($A::Item, $($I::Item),*)> for $A {
45 fn try_collect_tuple(&mut self) -> Option<($A::Item, $($I::Item),*)> {
46 let r = (try_opt!(self.next()),
47 $({ let a: $I::Item = try_opt!(self.next()); a}),* );
49 Some(r)
50 }
51 }
52 }
53}
54
55#[macro_export]
57macro_rules! try_opt {
58 ($e:expr) => {
59 match $e {
60 Some(e) => e,
61 None => return None,
62 }
63 };
64}
65
66impl_try_collect_tuple!(A A A A A A A A A A);