src/bounds.rs

branch
dev
changeset 125
25b6c8b20d1b
parent 124
6aa955ad8122
child 126
0ccad3ee8e95
--- a/src/bounds.rs	Thu May 01 13:06:58 2025 -0500
+++ b/src/bounds.rs	Thu May 01 14:53:14 2025 -0500
@@ -2,9 +2,8 @@
 Bounded and minimizable/maximizable mappings.
 */
 
-use crate::instance::Instance;
-use crate::loc::Loc;
-use crate::mapping::RealMapping;
+use crate::instance::{Instance, Space};
+use crate::mapping::Mapping;
 use crate::sets::{Cube, Set};
 use crate::types::{Float, Num};
 
@@ -59,42 +58,34 @@
 impl<F: Float, T: GlobalAnalysis<F, Bounds<F>>> Bounded<F> for T {}
 
 /// A [`RealMapping`] that provides rough bounds as well as minimisation and maximisation.
-pub trait MinMaxMapping<const N: usize, F: Float = f64>: RealMapping<N, F> + Bounded<F> {
+pub trait MinMaxMapping<Domain: Space, F: Float = f64>:
+    Mapping<Domain, Codomain = F> + Bounded<F>
+{
     /// Maximise the mapping within stated value `tolerance`.
     ///
     /// At most `max_steps` refinement steps are taken.
     /// Returns the approximate maximiser and the corresponding function value.
-    fn maximise(&mut self, tolerance: F, max_steps: usize) -> (Loc<N, F>, F);
+    fn maximise(&mut self, tolerance: F, max_steps: usize) -> (Domain, F);
 
     /// Maximise the mapping within stated value `tolerance` subject to a lower bound.
     ///
     /// At most `max_steps` refinement steps are taken.
     /// Returns the approximate maximiser and the corresponding function value when one is found
     /// above the `bound` threshold, otherwise `None`.
-    fn maximise_above(
-        &mut self,
-        bound: F,
-        tolerance: F,
-        max_steps: usize,
-    ) -> Option<(Loc<N, F>, F)>;
+    fn maximise_above(&mut self, bound: F, tolerance: F, max_steps: usize) -> Option<(Domain, F)>;
 
     /// Minimise the mapping within stated value `tolerance`.
     ///
     /// At most `max_steps` refinement steps are taken.
     /// Returns the approximate minimiser and the corresponding function value.
-    fn minimise(&mut self, tolerance: F, max_steps: usize) -> (Loc<N, F>, F);
+    fn minimise(&mut self, tolerance: F, max_steps: usize) -> (Domain, F);
 
     /// Minimise the mapping within stated value `tolerance` subject to a lower bound.
     ///
     /// At most `max_steps` refinement steps are taken.
     /// Returns the approximate minimiser and the corresponding function value when one is found
     /// above the `bound` threshold, otherwise `None`.
-    fn minimise_below(
-        &mut self,
-        bound: F,
-        tolerance: F,
-        max_steps: usize,
-    ) -> Option<(Loc<N, F>, F)>;
+    fn minimise_below(&mut self, bound: F, tolerance: F, max_steps: usize) -> Option<(Domain, F)>;
 
     /// Verify that the mapping has a given upper `bound` within indicated `tolerance`.
     ///

mercurial