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
//! Nonlinear systems `x' = f(x, u)` on `polyzonotope-reach`'s [`NonlinearReach`].
use ;
use ;
use crateReach;
/// A [`Reach`] model of the nonlinear system `x' = f(x, u)` with `N` states.
///
/// The control of an edge is one input set `U_k` per time step of
/// [`NonlinearSettings::step`]; see the [module docs](super). Each step linearizes or
/// polynomializes `f` around the current set ([`NonlinearSettings::method`]) and encloses
/// the abstraction error. A step polyzonotope-reach cannot prove (the set or the step is
/// too large for the abstraction, or the step for the Taylor bound) makes
/// [`Reach::propagate`] return `None`, so the edge is `Indeterminate`, never `Safe`.
///
/// Sets are stepped whole: [`NonlinearSettings::max_pieces`], `splitting`,
/// `merge_tolerance` and `adaptive` do not apply, since a split set has no single end set
/// to hand to the next edge.
///
/// # Examples
///
/// ```
/// use robust_planning::models::Nonlinear;
/// use nalgebra::{DMatrix, DVector};
/// use robust_planning::polyzonotope::{SparsePolyZonotope, Zonotope};
/// use robust_planning::polyzonotope_reach::{NonlinearSettings, Polynomial};
/// use robust_planning::Reach;
///
/// // `x' = u - x³` per axis, from the box `[-0.1, 0.1]²` under inputs `u ∈ [0.9, 1.1]²`.
/// let drag = Polynomial::new(2, 2)
/// .term(0, 1.0, &[0, 0, 1, 0])
/// .term(0, -1.0, &[3, 0, 0, 0])
/// .term(1, 1.0, &[0, 0, 0, 1])
/// .term(1, -1.0, &[0, 3, 0, 0]);
/// let model = Nonlinear::<_, 2>::new(drag, NonlinearSettings::new(0.1));
/// let start = SparsePolyZonotope::from_zonotope(&Zonotope::new(
/// DVector::zeros(2),
/// DMatrix::identity(2, 2) * 0.1,
/// ));
/// let input = Zonotope::new(DVector::from_element(2, 1.0), DMatrix::identity(2, 2) * 0.1);
///
/// let mut cover = Vec::new();
/// let end = model.propagate(&start, &vec![input; 5], &mut cover).expect("short steps are proven");
///
/// assert_eq!(cover.len(), 5);
/// assert!(end.interval_hull().0[0].lo > 0.0);
/// ```