src/bounds.rs

branch
dev
changeset 124
6aa955ad8122
parent 97
4e80fb049dca
child 125
25b6c8b20d1b
equal deleted inserted replaced
122:495448cca603 124:6aa955ad8122
38 /// Perform local analysis of the property `A` of `Self`. 38 /// Perform local analysis of the property `A` of `Self`.
39 /// 39 ///
40 /// As an example, in the case of `A` being [`Bounds`][super::aggregator::Bounds], 40 /// As an example, in the case of `A` being [`Bounds`][super::aggregator::Bounds],
41 /// this function will return upper and lower bounds within `cube` for the mapping 41 /// this function will return upper and lower bounds within `cube` for the mapping
42 /// represented by `self`. 42 /// represented by `self`.
43 fn local_analysis(&self, cube: &Cube<F, N>) -> A; 43 fn local_analysis(&self, cube: &Cube<N, F>) -> A;
44 } 44 }
45 45
46 /// Trait for determining the upper and lower bounds of an float-valued [`Mapping`]. 46 /// Trait for determining the upper and lower bounds of an float-valued [`Mapping`].
47 /// 47 ///
48 /// This is a blanket-implemented alias for [`GlobalAnalysis`]`<F, Bounds<F>>` 48 /// This is a blanket-implemented alias for [`GlobalAnalysis`]`<F, Bounds<F>>`
57 } 57 }
58 58
59 impl<F: Float, T: GlobalAnalysis<F, Bounds<F>>> Bounded<F> for T {} 59 impl<F: Float, T: GlobalAnalysis<F, Bounds<F>>> Bounded<F> for T {}
60 60
61 /// A [`RealMapping`] that provides rough bounds as well as minimisation and maximisation. 61 /// A [`RealMapping`] that provides rough bounds as well as minimisation and maximisation.
62 pub trait MinMaxMapping<F: Float, const N: usize>: RealMapping<F, N> + Bounded<F> { 62 pub trait MinMaxMapping<const N: usize, F: Float = f64>: RealMapping<N, F> + Bounded<F> {
63 /// Maximise the mapping within stated value `tolerance`. 63 /// Maximise the mapping within stated value `tolerance`.
64 /// 64 ///
65 /// At most `max_steps` refinement steps are taken. 65 /// At most `max_steps` refinement steps are taken.
66 /// Returns the approximate maximiser and the corresponding function value. 66 /// Returns the approximate maximiser and the corresponding function value.
67 fn maximise(&mut self, tolerance: F, max_steps: usize) -> (Loc<F, N>, F); 67 fn maximise(&mut self, tolerance: F, max_steps: usize) -> (Loc<N, F>, F);
68 68
69 /// Maximise the mapping within stated value `tolerance` subject to a lower bound. 69 /// Maximise the mapping within stated value `tolerance` subject to a lower bound.
70 /// 70 ///
71 /// At most `max_steps` refinement steps are taken. 71 /// At most `max_steps` refinement steps are taken.
72 /// Returns the approximate maximiser and the corresponding function value when one is found 72 /// Returns the approximate maximiser and the corresponding function value when one is found
74 fn maximise_above( 74 fn maximise_above(
75 &mut self, 75 &mut self,
76 bound: F, 76 bound: F,
77 tolerance: F, 77 tolerance: F,
78 max_steps: usize, 78 max_steps: usize,
79 ) -> Option<(Loc<F, N>, F)>; 79 ) -> Option<(Loc<N, F>, F)>;
80 80
81 /// Minimise the mapping within stated value `tolerance`. 81 /// Minimise the mapping within stated value `tolerance`.
82 /// 82 ///
83 /// At most `max_steps` refinement steps are taken. 83 /// At most `max_steps` refinement steps are taken.
84 /// Returns the approximate minimiser and the corresponding function value. 84 /// Returns the approximate minimiser and the corresponding function value.
85 fn minimise(&mut self, tolerance: F, max_steps: usize) -> (Loc<F, N>, F); 85 fn minimise(&mut self, tolerance: F, max_steps: usize) -> (Loc<N, F>, F);
86 86
87 /// Minimise the mapping within stated value `tolerance` subject to a lower bound. 87 /// Minimise the mapping within stated value `tolerance` subject to a lower bound.
88 /// 88 ///
89 /// At most `max_steps` refinement steps are taken. 89 /// At most `max_steps` refinement steps are taken.
90 /// Returns the approximate minimiser and the corresponding function value when one is found 90 /// Returns the approximate minimiser and the corresponding function value when one is found
92 fn minimise_below( 92 fn minimise_below(
93 &mut self, 93 &mut self,
94 bound: F, 94 bound: F,
95 tolerance: F, 95 tolerance: F,
96 max_steps: usize, 96 max_steps: usize,
97 ) -> Option<(Loc<F, N>, F)>; 97 ) -> Option<(Loc<N, F>, F)>;
98 98
99 /// Verify that the mapping has a given upper `bound` within indicated `tolerance`. 99 /// Verify that the mapping has a given upper `bound` within indicated `tolerance`.
100 /// 100 ///
101 /// At most `max_steps` refinement steps are taken. 101 /// At most `max_steps` refinement steps are taken.
102 fn has_upper_bound(&mut self, bound: F, tolerance: F, max_steps: usize) -> bool; 102 fn has_upper_bound(&mut self, bound: F, tolerance: F, max_steps: usize) -> bool;

mercurial