src/bounds.rs

branch
dev
changeset 125
25b6c8b20d1b
parent 124
6aa955ad8122
child 126
0ccad3ee8e95
equal deleted inserted replaced
124:6aa955ad8122 125:25b6c8b20d1b
1 /*! 1 /*!
2 Bounded and minimizable/maximizable mappings. 2 Bounded and minimizable/maximizable mappings.
3 */ 3 */
4 4
5 use crate::instance::Instance; 5 use crate::instance::{Instance, Space};
6 use crate::loc::Loc; 6 use crate::mapping::Mapping;
7 use crate::mapping::RealMapping;
8 use crate::sets::{Cube, Set}; 7 use crate::sets::{Cube, Set};
9 use crate::types::{Float, Num}; 8 use crate::types::{Float, Num};
10 9
11 /// Trait for globally analysing a property `A` of a [`Mapping`]. 10 /// Trait for globally analysing a property `A` of a [`Mapping`].
12 /// 11 ///
57 } 56 }
58 57
59 impl<F: Float, T: GlobalAnalysis<F, Bounds<F>>> Bounded<F> for T {} 58 impl<F: Float, T: GlobalAnalysis<F, Bounds<F>>> Bounded<F> for T {}
60 59
61 /// A [`RealMapping`] that provides rough bounds as well as minimisation and maximisation. 60 /// A [`RealMapping`] that provides rough bounds as well as minimisation and maximisation.
62 pub trait MinMaxMapping<const N: usize, F: Float = f64>: RealMapping<N, F> + Bounded<F> { 61 pub trait MinMaxMapping<Domain: Space, F: Float = f64>:
62 Mapping<Domain, Codomain = F> + Bounded<F>
63 {
63 /// Maximise the mapping within stated value `tolerance`. 64 /// Maximise the mapping within stated value `tolerance`.
64 /// 65 ///
65 /// At most `max_steps` refinement steps are taken. 66 /// At most `max_steps` refinement steps are taken.
66 /// Returns the approximate maximiser and the corresponding function value. 67 /// Returns the approximate maximiser and the corresponding function value.
67 fn maximise(&mut self, tolerance: F, max_steps: usize) -> (Loc<N, F>, F); 68 fn maximise(&mut self, tolerance: F, max_steps: usize) -> (Domain, F);
68 69
69 /// Maximise the mapping within stated value `tolerance` subject to a lower bound. 70 /// Maximise the mapping within stated value `tolerance` subject to a lower bound.
70 /// 71 ///
71 /// At most `max_steps` refinement steps are taken. 72 /// At most `max_steps` refinement steps are taken.
72 /// Returns the approximate maximiser and the corresponding function value when one is found 73 /// Returns the approximate maximiser and the corresponding function value when one is found
73 /// above the `bound` threshold, otherwise `None`. 74 /// above the `bound` threshold, otherwise `None`.
74 fn maximise_above( 75 fn maximise_above(&mut self, bound: F, tolerance: F, max_steps: usize) -> Option<(Domain, F)>;
75 &mut self,
76 bound: F,
77 tolerance: F,
78 max_steps: usize,
79 ) -> Option<(Loc<N, F>, F)>;
80 76
81 /// Minimise the mapping within stated value `tolerance`. 77 /// Minimise the mapping within stated value `tolerance`.
82 /// 78 ///
83 /// At most `max_steps` refinement steps are taken. 79 /// At most `max_steps` refinement steps are taken.
84 /// Returns the approximate minimiser and the corresponding function value. 80 /// Returns the approximate minimiser and the corresponding function value.
85 fn minimise(&mut self, tolerance: F, max_steps: usize) -> (Loc<N, F>, F); 81 fn minimise(&mut self, tolerance: F, max_steps: usize) -> (Domain, F);
86 82
87 /// Minimise the mapping within stated value `tolerance` subject to a lower bound. 83 /// Minimise the mapping within stated value `tolerance` subject to a lower bound.
88 /// 84 ///
89 /// At most `max_steps` refinement steps are taken. 85 /// At most `max_steps` refinement steps are taken.
90 /// Returns the approximate minimiser and the corresponding function value when one is found 86 /// Returns the approximate minimiser and the corresponding function value when one is found
91 /// above the `bound` threshold, otherwise `None`. 87 /// above the `bound` threshold, otherwise `None`.
92 fn minimise_below( 88 fn minimise_below(&mut self, bound: F, tolerance: F, max_steps: usize) -> Option<(Domain, F)>;
93 &mut self,
94 bound: F,
95 tolerance: F,
96 max_steps: usize,
97 ) -> Option<(Loc<N, F>, F)>;
98 89
99 /// Verify that the mapping has a given upper `bound` within indicated `tolerance`. 90 /// Verify that the mapping has a given upper `bound` within indicated `tolerance`.
100 /// 91 ///
101 /// At most `max_steps` refinement steps are taken. 92 /// At most `max_steps` refinement steps are taken.
102 fn has_upper_bound(&mut self, bound: F, tolerance: F, max_steps: usize) -> bool; 93 fn has_upper_bound(&mut self, bound: F, tolerance: F, max_steps: usize) -> bool;

mercurial