# HG changeset patch # User Tuomo Valkonen # Date 1746129194 18000 # Node ID 25b6c8b20d1bd1fe3a91f87eaea3d442150d3b17 # Parent 6aa955ad8122f2a1b9343b37e3adcb20891f3979 Allow MinMaxMappings on any domain diff -r 6aa955ad8122 -r 25b6c8b20d1b src/bisection_tree/btfn.rs --- a/src/bisection_tree/btfn.rs Thu May 01 13:06:58 2025 -0500 +++ b/src/bisection_tree/btfn.rs Thu May 01 14:53:14 2025 -0500 @@ -838,7 +838,7 @@ // there should be a result, or new nodes above the `glb` inserted into the queue. Then the waiting // threads can also continue processing. If, however, numerical inaccuracy destroyes the `glb`, // the queue may run out, and we get “Refiner failure”. -impl MinMaxMapping for BTFN +impl MinMaxMapping, F> for BTFN where BT: BTSearch>, G: SupportGenerator, diff -r 6aa955ad8122 -r 25b6c8b20d1b src/bounds.rs --- 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>> Bounded for T {} /// A [`RealMapping`] that provides rough bounds as well as minimisation and maximisation. -pub trait MinMaxMapping: RealMapping + Bounded { +pub trait MinMaxMapping: + Mapping + Bounded +{ /// 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, 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, 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, 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, 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`. ///