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
//! # fieldopt-core
//!
//! Field-survey design under real field cost. The crate provides the
//! computational pieces behind the R package `fieldopt`: travel matrices,
//! routing of field work (exact for small instances, hybrid genetic search
//! otherwise, with service times, stops and capacity limits),
//! spatially balanced sampling with the local pivotal method, balanced
//! sampling with the cube method and the Voronoi measure of spatial balance,
//! Horvitz-Thompson estimation with the local-mean variance estimator, and
//! cost-aware allocation across strata or frames, for one or several study
//! variables, in dual frames and in two stages. It has no dependencies and
//! every randomised step is reproducible from a seed.
//!
//! ```
//! use fieldopt_core::distance::euclidean_matrix;
//! use fieldopt_core::routing::{grasp_routes, GraspOptions, RouteLimits};
//! use fieldopt_core::sampling::{inclusion_probabilities, local_pivotal};
//!
//! // a 6 x 6 grid of segments plus a depot at the origin
//! let mut x = vec![0.0]; let mut y = vec![0.0];
//! for i in 0..36 { x.push(1.0 + (i % 6) as f64); y.push(1.0 + (i / 6) as f64); }
//! let m = euclidean_matrix(&x, &y).unwrap();
//!
//! // select 12 segments, spatially balanced, with equal probabilities
//! let coords: Vec<f64> = (1..37).flat_map(|i| vec![x[i], y[i]]).collect();
//! let pi = inclusion_probabilities(&vec![1.0; 36], 12).unwrap();
//! let sampled = local_pivotal(&coords, 2, &pi, 1).unwrap();
//! let units: Vec<usize> = (0..36).filter(|&i| sampled[i]).map(|i| i + 1).collect();
//!
//! // route the field work from the depot with at most 5 segments per day
//! let limits = RouteLimits { max_length: f64::INFINITY, max_stops: 5, capacity: f64::INFINITY };
//! let sol = grasp_routes(&m, 0, &units, limits, GraspOptions::default()).unwrap();
//! assert_eq!(sol.routes.iter().map(|r| r.len()).sum::<usize>(), 12);
//! assert!(sol.total >= sol.lower_bound);
//! ```
/// Version of this crate, for reports.
pub const VERSION: &str = env!;
pub
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;