src/bisection_tree/aggregator.rs

branch
dev
changeset 63
f7b87d84864d
parent 8
4e09b7829b51
child 86
d5b0e496b72f
equal deleted inserted replaced
62:d8305c9b6fdf 63:f7b87d84864d
2 Aggregation / summarisation of information in branches of bisection trees. 2 Aggregation / summarisation of information in branches of bisection trees.
3 */ 3 */
4 4
5 use crate::types::*; 5 use crate::types::*;
6 use crate::sets::Set; 6 use crate::sets::Set;
7 use crate::instance::Instance;
7 8
8 /// Trait for aggregating information about a branch of a [bisection tree][super::BT]. 9 /// Trait for aggregating information about a branch of a [bisection tree][super::BT].
9 /// 10 ///
10 /// Currently [`Bounds`] is the only provided aggregator. 11 /// Currently [`Bounds`] is the only provided aggregator.
11 /// It keeps track of upper and lower bounds of a function representeed by the `BT` by 12 /// It keeps track of upper and lower bounds of a function representeed by the `BT` by
134 } 135 }
135 } 136 }
136 } 137 }
137 138
138 impl<F : Float> Set<F> for Bounds<F> { 139 impl<F : Float> Set<F> for Bounds<F> {
139 fn contains(&self, item : &F) -> bool { 140 fn contains<I : Instance<F>>(&self, item : I) -> bool {
141 let v = item.own();
140 let &Bounds(l, u) = self; 142 let &Bounds(l, u) = self;
141 debug_assert!(l <= u); 143 debug_assert!(l <= u);
142 l <= *item && *item <= u 144 l <= v && v <= u
143 } 145 }
144 } 146 }
145 147
146 impl<F : Float> Bounds<F> { 148 impl<F : Float> Bounds<F> {
147 /// Calculate a common bound (glb, lub) for two bounds. 149 /// Calculate a common bound (glb, lub) for two bounds.

mercurial