evolutionary-planning 0.1.0

Evolutionary planning for no_std: genetic algorithms, evolution strategies, CMA-ES and multi-objective evolutionary search over plans, paths and trajectories
Documentation
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
//! A multi-robot intersection benchmark after Parque (2024): every robot crosses a four-way
//! intersection on a lattice roadmap built around its reference path, the lattice of robot
//! `i` is parameterised by its base `b_i` and height `h_i`, and the cost of a parameter
//! vector `x = (b_1, h_1, …, b_N, h_N)` is the total length of the coordinated, collision-free
//! paths (equation (1) of the paper) plus a price per time step (see below), so any
//! gradient-free optimiser (RADES, DE, CMA-ES) can search the roadmap configurations.
//!
//! The paper coordinates the robots with dRRT* in the composite roadmap. This benchmark uses
//! prioritised space-time search instead: robots plan in index order on their own roadmaps,
//! each avoiding the already planned ones (positions at every time step and edge midpoint
//! at least `safety` apart; a robot leaves the scene at its goal). One roadmap edge takes one
//! time step and waiting in place is allowed. Every step, moving or waiting, also costs
//! [`Intersection::time_cost`]: with length alone the straight middle row plus waits would
//! make nearly every configuration cost the same, whereas with a price on time a coarse
//! lattice (large `b_i`, fewer and faster steps) pays off unless it causes conflicts that
//! need waits or detours.
//! A robot that finds no plan adds a penalty of `1000` plus its straight-line distance, so
//! infeasible configurations still compare.
//!
//! In the [`Intersection::crossing`] scene the robots drive straight, and the coarsest
//! lattice (`b_i = 6` for all) happens to be conflict-free, so the optimum sits at that corner
//! of the box (cost 412 for eight robots) and the heights `h_i` only matter for
//! configurations that need detours. It is a smoke benchmark for the optimisers rather than
//! a hard coordination problem; scenes with turning robots are an open extension.
//!
//! ```
//! use evolutionary_planning::de::rades::{Config, Rades};
//! use evolutionary_planning::problems::intersection::Intersection;
//! use evolutionary_planning::{Limits, SplitMix64};
//!
//! let mut scene = Intersection::crossing(4);
//! let mut rades = Rades::new(Config::default(), scene.bounds());
//! // The paper's budget: 300 function evaluations.
//! let outcome = rades.run(&mut scene, &mut Limits::evaluations(300), &mut (), &mut SplitMix64::new(1));
//! let plan = scene.plan(outcome.best_genome().expect("evaluated")).expect("feasible");
//! assert_eq!(scene.collisions(&plan), 0);
//! ```

use alloc::collections::BinaryHeap;
use alloc::vec::Vec;
use core::cmp::Ordering;

use crate::Objective;
use crate::operators::real::Bounds;

/// A point in the plane.
pub type Point = (f64, f64);

/// One robot: where it enters and where it leaves, and its reference path (a polyline from
/// start to goal through the intersection).
#[derive(Debug, Clone, PartialEq)]
pub struct Robot {
    /// The reference polyline; its first point is the start, its last the goal.
    pub reference: Vec<Point>,
}

/// An axis-aligned rectangular obstacle `[x0, x1] × [y0, y1]`.
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Block {
    /// The lower-left corner.
    pub min: Point,
    /// The upper-right corner.
    pub max: Point,
}

impl Block {
    /// Whether the segment `a → b` touches the block (sampled densely; the blocks are large
    /// compared to the sampling step).
    fn hits(&self, from: Point, to: Point) -> bool {
        (0..=32).any(|k| {
            let t = f64::from(k) / 32.0;
            let (x, y) = (from.0 + t * (to.0 - from.0), from.1 + t * (to.1 - from.1));
            (self.min.0..=self.max.0).contains(&x) && (self.min.1..=self.max.1).contains(&y)
        })
    }
}

/// The intersection scene.
#[derive(Debug, Clone, PartialEq)]
pub struct Intersection {
    /// The robots, in planning priority order.
    pub robots: Vec<Robot>,
    /// The buildings at the corners.
    pub blocks: Vec<Block>,
    /// The minimum distance between two robots.
    pub safety: f64,
    /// The bounds of each `(b_i, h_i)` pair: the paper's `b ∈ [1, 6]`, `h ∈ [0.5, 5]`.
    pub parameter_bounds: [(f64, f64); 2],
    /// The cost of one time step, moving or waiting, in length units. Default `1`.
    pub time_cost: f64,
}

/// A roadmap: vertex positions and forward edges.
struct Roadmap {
    /// The vertex positions; vertex `0` is the start, vertex `1` the goal.
    points: Vec<Point>,
    /// The out-edges of every vertex: `(target, length)`.
    edges: Vec<Vec<(usize, f64)>>,
}

impl Intersection {
    /// A four-way crossing of roads 8 wide with buildings at the corners and up to eight
    /// robots driving straight across on the right-hand lanes: robots 0–3 come from the west,
    /// east, south and north; robots 4–7 follow them on the same lanes, 8 units behind.
    ///
    /// # Panics
    ///
    /// Panics if `robots` is not in `1..=8`.
    #[must_use]
    pub fn crossing(robots: usize) -> Self {
        assert!(
            (1..=8).contains(&robots),
            "the crossing scene has one to eight robots"
        );

        let lanes: [(Point, Point); 4] = [
            ((-18.0, -2.0), (18.0, -2.0)),
            ((18.0, 2.0), (-18.0, 2.0)),
            ((2.0, -18.0), (2.0, 18.0)),
            ((-2.0, 18.0), (-2.0, -18.0)),
        ];
        let robots = (0..robots)
            .map(|i| {
                let (start, goal) = lanes[i % 4];
                let behind = if i < 4 { 0.0 } else { 8.0 };
                let direction = unit((goal.0 - start.0, goal.1 - start.1));
                let shift = |p: Point, d: f64| (p.0 - d * direction.0, p.1 - d * direction.1);
                Robot {
                    reference: alloc::vec![shift(start, behind), shift(goal, -behind)],
                }
            })
            .collect();
        let corner = |sx: f64, sy: f64| Block {
            min: (
                if sx > 0.0 { 4.0 } else { -40.0 },
                if sy > 0.0 { 4.0 } else { -40.0 },
            ),
            max: (
                if sx > 0.0 { 40.0 } else { -4.0 },
                if sy > 0.0 { 40.0 } else { -4.0 },
            ),
        };

        Self {
            robots,
            blocks: alloc::vec![
                corner(1.0, 1.0),
                corner(-1.0, 1.0),
                corner(1.0, -1.0),
                corner(-1.0, -1.0)
            ],
            safety: 1.5,
            parameter_bounds: [(1.0, 6.0), (0.5, 5.0)],
            time_cost: 1.0,
        }
    }

    /// The search box of the parameter vector `(b_1, h_1, …, b_N, h_N)`.
    #[must_use]
    pub fn bounds(&self) -> Bounds {
        let [(b0, b1), (h0, h1)] = self.parameter_bounds;
        let lower = self.robots.iter().flat_map(|_| [b0, h0]).collect();
        let upper = self.robots.iter().flat_map(|_| [b1, h1]).collect();

        Bounds::new(lower, upper)
    }

    /// The coordinated trajectories (one position per time step, until each robot's goal)
    /// for parameters `x`, or `None` if some robot found no collision-free plan.
    #[must_use]
    pub fn plan(&self, x: &[f64]) -> Option<Vec<Vec<Point>>> {
        let mut planned: Vec<Vec<Point>> = Vec::with_capacity(self.robots.len());
        for (i, robot) in self.robots.iter().enumerate() {
            let roadmap = self.roadmap(
                robot,
                self.parameter(x, 2 * i, 0),
                self.parameter(x, 2 * i + 1, 1),
            );
            planned.push(self.space_time(&roadmap, &planned)?);
        }

        Some(planned)
    }

    /// The cost of one trajectory: its length plus [`Intersection::time_cost`] per step.
    #[must_use]
    pub fn trajectory_cost(&self, trajectory: &[Point]) -> f64 {
        trajectory
            .windows(2)
            .map(|w| distance(w[0], w[1]) + self.time_cost)
            .sum()
    }

    /// The number of time steps (and midpoints) at which two robots are closer than `safety`.
    #[must_use]
    pub fn collisions(&self, trajectories: &[Vec<Point>]) -> usize {
        let horizon = trajectories.iter().map(Vec::len).max().unwrap_or(0);
        let mut count = 0;
        for t in 0..horizon {
            for (i, a) in trajectories.iter().enumerate() {
                for b in &trajectories[i + 1..] {
                    count += usize::from(conflict(a, b, t, self.safety));
                }
            }
        }

        count
    }

    /// Reads parameter `index` of `x`, clamped to its bounds (`kind` 0: base, 1: height).
    fn parameter(&self, x: &[f64], index: usize, kind: usize) -> f64 {
        let (low, high) = self.parameter_bounds[kind];

        x.get(index).copied().unwrap_or(low).clamp(low, high)
    }

    /// The lattice roadmap of `robot` with base `base` and height `height`: points on the
    /// reference path every `base` units and offset by `±height`, with the forward edges of
    /// the paper's equation (4) that avoid the buildings.
    fn roadmap(&self, robot: &Robot, base: f64, height: f64) -> Roadmap {
        let middle = resample(&robot.reference, base);
        let r = middle.len();
        let mut points = Vec::with_capacity(3 * r);
        // Vertex 0 is the start and 1 the goal; then the interior middle points and both rows.
        points.push(middle[0]);
        points.push(middle[r - 1]);
        let mut index = alloc::vec![[usize::MAX; 3]; r];
        index[0][0] = 0;
        index[r - 1][0] = 1;
        for j in 0..r {
            let normal = normal_at(&middle, j);
            for (row, offset) in [(0, 0.0), (1, height), (2, -height)] {
                if index[j][row] != usize::MAX || ((j == 0 || j == r - 1) && row != 0) {
                    continue;
                }
                index[j][row] = points.len();
                points.push((
                    middle[j].0 + offset * normal.0,
                    middle[j].1 + offset * normal.1,
                ));
            }
        }

        let mut edges = alloc::vec![Vec::new(); points.len()];
        let mut connect = |from: usize, to: usize, points: &[Point]| {
            if from == usize::MAX || to == usize::MAX {
                return;
            }
            let (a, b) = (points[from], points[to]);
            if !self.blocks.iter().any(|block| block.hits(a, b)) {
                edges[from].push((to, distance(a, b)));
            }
        };
        for j in 0..r {
            let [q, p, s] = index[j];
            connect(q, p, &points);
            connect(q, s, &points);
            if j + 1 < r {
                let [q1, p1, s1] = index[j + 1];
                for (from, to) in [
                    (q, q1),
                    (p, q1),
                    (s, q1),
                    (p, p1),
                    (s, s1),
                    (q, p1),
                    (q, s1),
                ] {
                    connect(from, to, &points);
                }
            }
        }

        Roadmap { points, edges }
    }

    /// Prioritised space-time Dijkstra on `roadmap` avoiding the `planned` trajectories;
    /// minimises path length plus [`Intersection::time_cost`] per step.
    fn space_time(&self, roadmap: &Roadmap, planned: &[Vec<Point>]) -> Option<Vec<Point>> {
        /// A search entry ordered by smallest cost first.
        #[derive(PartialEq)]
        struct Entry(f64, usize, usize);
        impl Eq for Entry {}
        impl PartialOrd for Entry {
            fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
                Some(self.cmp(other))
            }
        }
        impl Ord for Entry {
            fn cmp(&self, other: &Self) -> Ordering {
                other
                    .0
                    .total_cmp(&self.0)
                    .then(other.2.cmp(&self.2))
                    .then(other.1.cmp(&self.1))
            }
        }

        let horizon = 2 * roadmap.points.len() + planned.iter().map(Vec::len).max().unwrap_or(0);
        let n = roadmap.points.len();
        let mut best = alloc::vec![f64::INFINITY; n * (horizon + 1)];
        let mut parent = alloc::vec![usize::MAX; n * (horizon + 1)];
        let mut heap = BinaryHeap::new();
        if !self.free(roadmap.points[0], roadmap.points[0], 0, planned) {
            return None;
        }

        best[0] = 0.0;
        heap.push(Entry(0.0, 0, 0));
        while let Some(Entry(cost, v, t)) = heap.pop() {
            if v == 1 {
                return Some(trace(&roadmap.points, &parent, n, v, t));
            }
            if cost > best[t * n + v] || t == horizon {
                continue;
            }

            let wait = core::iter::once((v, 0.0));
            for (w, length) in wait.chain(roadmap.edges[v].iter().copied()) {
                let next = (t + 1) * n + w;
                let total = cost + length + self.time_cost;
                if total < best[next]
                    && self.free(roadmap.points[v], roadmap.points[w], t + 1, planned)
                {
                    best[next] = total;
                    parent[next] = t * n + v;
                    heap.push(Entry(total, w, t + 1));
                }
            }
        }

        None
    }

    /// Whether moving `from → to` arriving at time `t` keeps the safety distance to every planned
    /// robot still in the scene (at `t` and at the midpoint of the move).
    fn free(&self, from: Point, to: Point, t: usize, planned: &[Vec<Point>]) -> bool {
        let middle = midpoint(from, to);
        planned.iter().all(|other| {
            let at = |time: usize| other.get(time).copied();
            let clear =
                |p: Point, q: Option<Point>| q.is_none_or(|q| distance(p, q) >= self.safety);
            let previous = t.checked_sub(1).and_then(at);
            let midpoint = match (previous, at(t)) {
                (Some(before), Some(now)) => Some(midpoint(before, now)),
                _ => None,
            };
            clear(to, at(t)) && clear(middle, midpoint)
        })
    }
}

impl Objective<Vec<f64>> for Intersection {
    /// The total cost of the coordinated plan: path length plus [`Intersection::time_cost`]
    /// per step; failed robots add `1000` plus their straight-line distance.
    fn evaluate(&mut self, x: &Vec<f64>) -> f64 {
        let mut planned: Vec<Vec<Point>> = Vec::with_capacity(self.robots.len());
        let mut cost = 0.0;
        for (i, robot) in self.robots.iter().enumerate() {
            let roadmap = self.roadmap(
                robot,
                self.parameter(x, 2 * i, 0),
                self.parameter(x, 2 * i + 1, 1),
            );
            if let Some(path) = self.space_time(&roadmap, &planned) {
                cost += self.trajectory_cost(&path);
                planned.push(path);
            } else {
                let (start, goal) = (
                    robot.reference[0],
                    robot.reference[robot.reference.len() - 1],
                );
                cost += 1000.0 + distance(start, goal);
            }
        }

        cost
    }
}

/// Whether trajectories `a` and `b` are closer than `safety` at time `t` or at the midpoint of
/// the step into `t`.
fn conflict(a: &[Point], b: &[Point], t: usize, safety: f64) -> bool {
    let (Some(&pa), Some(&pb)) = (a.get(t), b.get(t)) else {
        return false;
    };
    if distance(pa, pb) < safety {
        return true;
    }

    match (
        t.checked_sub(1).and_then(|s| a.get(s)),
        t.checked_sub(1).and_then(|s| b.get(s)),
    ) {
        (Some(&qa), Some(&qb)) => distance(midpoint(pa, qa), midpoint(pb, qb)) < safety,
        _ => false,
    }
}

/// The midpoint of two points.
fn midpoint(a: Point, b: Point) -> Point {
    (f64::midpoint(a.0, b.0), f64::midpoint(a.1, b.1))
}

/// Follows the parent pointers back from `(v, t)`.
fn trace(points: &[Point], parent: &[usize], n: usize, v: usize, t: usize) -> Vec<Point> {
    let mut states = alloc::vec![t * n + v];
    while parent[*states.last().expect("non-empty")] != usize::MAX {
        states.push(parent[*states.last().expect("non-empty")]);
    }
    states.reverse();

    states.into_iter().map(|s| points[s % n]).collect()
}

/// Points along `polyline` every `step` units of arc length, both ends included (the last
/// interval may be shorter): `R = 1 + ⌈L / b⌉` points, the paper's (2) rounded up.
fn resample(polyline: &[Point], step: f64) -> Vec<Point> {
    let mut points = alloc::vec![polyline[0]];
    let mut carried = 0.0;
    for w in polyline.windows(2) {
        let length = distance(w[0], w[1]);
        let mut s = step - carried;
        while s < length - 1e-9 {
            let t = s / length;
            points.push((
                w[0].0 + t * (w[1].0 - w[0].0),
                w[0].1 + t * (w[1].1 - w[0].1),
            ));
            s += step;
        }
        carried = length - (s - step);
    }

    points.push(polyline[polyline.len() - 1]);
    points
}

/// The left normal of the path at point `j` (from the neighbouring points).
fn normal_at(points: &[Point], j: usize) -> Point {
    let a = points[j.saturating_sub(1)];
    let b = points[(j + 1).min(points.len() - 1)];
    let (dx, dy) = unit((b.0 - a.0, b.1 - a.1));

    (-dy, dx)
}

/// The unit vector of `v` (zero stays zero).
fn unit(v: Point) -> Point {
    let length = libm::hypot(v.0, v.1);
    if length > 0.0 {
        (v.0 / length, v.1 / length)
    } else {
        (0.0, 0.0)
    }
}

/// The Euclidean distance.
fn distance(a: Point, b: Point) -> f64 {
    libm::hypot(a.0 - b.0, a.1 - b.1)
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::cmaes::{CmaEs, Config as CmaConfig};
    use crate::de::rades::{Config, Rades};
    use crate::de::{Config as DeConfig, De};
    use crate::{Limits, SplitMix64};

    /// Every optimiser finds a collision-free coordinated plan for four robots (RADES also
    /// for eight), and the reported cost equals the cost of the planned trajectories.
    #[test]
    fn coordinated_plans_are_collision_free() {
        for robots in [4, 8] {
            let mut scene = Intersection::crossing(robots);
            let bounds = scene.bounds();
            let mut rng = SplitMix64::new(3);
            let budget = if robots == 4 { 300 } else { 100 };
            let mut outcomes = alloc::vec![Rades::new(Config::default(), bounds.clone()).run(
                &mut scene,
                &mut Limits::evaluations(budget),
                &mut (),
                &mut rng
            )];
            if robots == 4 {
                outcomes.push(
                    De::new(
                        DeConfig {
                            population_size: 10,
                            ..DeConfig::default()
                        },
                        bounds.clone(),
                    )
                    .run(
                        &mut scene,
                        &mut Limits::evaluations(300),
                        &mut (),
                        &mut rng,
                    ),
                );
                outcomes.push(
                    CmaEs::new(
                        bounds.center(),
                        1.0,
                        CmaConfig {
                            bounds: Some(bounds.clone()),
                            ..CmaConfig::default()
                        },
                    )
                    .minimize(
                        &mut scene,
                        &mut Limits::evaluations(300),
                        &mut (),
                        &mut rng,
                    ),
                );
            }
            for outcome in outcomes {
                let x = outcome.best_genome().expect("evaluated");
                let plan = scene.plan(x).expect("feasible");
                let cost: f64 = plan.iter().map(|p| scene.trajectory_cost(p)).sum();
                assert_eq!(scene.collisions(&plan), 0, "{robots} robots");
                assert!((cost - outcome.best_cost()).abs() < 1e-9);
                assert!(
                    plan.iter()
                        .zip(&scene.robots)
                        .all(|(p, r)| p[p.len() - 1] == r.reference[r.reference.len() - 1])
                );
            }
        }
    }

    /// The objective is not flat: random configurations differ, and RADES with the paper's
    /// 300 evaluations beats the median random configuration.
    #[test]
    fn configurations_matter() {
        let mut scene = Intersection::crossing(4);
        let mut bounds = scene.bounds();
        let mut rng = SplitMix64::new(11);
        let mut costs: alloc::vec::Vec<f64> = (0..40)
            .map(|_| {
                let x = crate::operators::Initializer::initialize(&mut bounds, &mut rng);
                scene.evaluate(&x)
            })
            .collect();
        costs.sort_by(f64::total_cmp);
        let outcome = Rades::new(Config::default(), scene.bounds()).run(
            &mut scene,
            &mut Limits::evaluations(300),
            &mut (),
            &mut rng,
        );

        assert!(costs[39] - costs[0] > 1.0, "flat objective: {costs:?}");
        assert!(
            outcome.best_cost() < costs[20],
            "{} vs median {}",
            outcome.best_cost(),
            costs[20]
        );
    }

    /// In the straight-crossing scene the coarsest lattice is conflict-free and optimal
    /// (documented in the module docs): `b_i = 6` costs 412 for eight robots whatever `h_i`.
    #[test]
    fn coarsest_lattice_is_optimal_in_the_crossing() {
        let mut scene = Intersection::crossing(8);
        let bounds = scene.bounds();
        let upper = bounds.upper().to_vec();
        let mut low_heights = upper.clone();
        for k in (1..low_heights.len()).step_by(2) {
            low_heights[k] = bounds.lower()[k];
        }

        assert!((scene.evaluate(&upper) - 412.0).abs() < 1e-9);
        assert!((scene.evaluate(&low_heights) - 412.0).abs() < 1e-9);
        assert!(scene.evaluate(&bounds.lower().to_vec()) > 412.0);
    }

    /// Lattice resampling and roadmap structure.
    #[test]
    fn lattice_structure() {
        let points = resample(&[(0.0, 0.0), (10.0, 0.0)], 3.0);
        assert_eq!(
            points,
            [(0.0, 0.0), (3.0, 0.0), (6.0, 0.0), (9.0, 0.0), (10.0, 0.0)]
        );

        let scene = Intersection::crossing(1);
        let roadmap = scene.roadmap(&scene.robots[0], 4.0, 1.0);
        // The straight middle row is always available: the start reaches the goal.
        assert!(roadmap.edges[0].iter().any(|&(w, _)| w >= 2));
        assert!(roadmap.edges.iter().flatten().all(|&(_, l)| l > 0.0));
    }
}