src/bisection_tree.rs

Wed, 22 Apr 2026 23:41:59 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Wed, 22 Apr 2026 23:41:59 -0500
branch
dev
changeset 197
1f301affeae3
parent 5
59dc4c5883f4
permissions
-rw-r--r--

Fix internal links in documentation

5
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
1 /*!
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
2 Geometrical bisection trees and efficient representations of sums of functions.
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
3
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
4 [Bisection trees][BTImpl] subdivide at each branching node a [cubical][crate::sets::Cube] domain of
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
5 dimension $N$ into $P=2^N$ subcubes at a branching point. Objects implementing [`Support`] can be
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
6 [inserted][BTImpl::insert] into the leaves of the tree via a low storage requirement identifier.
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
7 The identifier is inserted into *every* leaf node of the tree intersected by the cube provided
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
8 by [`Support::support_hint`].
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
9
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
10 Bisection tree functions or [`BTFN`]s use bisection trees for efficient presentations of sums
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
11 $\sum_{k=1}^m f_k$ of mathematical functions $f_k$, where each $f_k$ typically has a small
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
12 support, i.e., set $\\{x \mid f(x) ≠ 0 \\}$, compared to the support of the entire sum.
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
13 To do so, the data type representing $f_k$ needs to implement [`Support`]. To evaluate the
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
14 value of the sum, each $f_k$ also needs to implement [`Mapping`][crate::mapping::Mapping].
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
15 Moreover, the sum needs to be represented by a [`SupportGenerator`] that associates to a
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
16 low-storage-requirement identifier (typically `usize`) an object of the type that represents
197
1f301affeae3 Fix internal links in documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 5
diff changeset
17 $f_k$. [`BTFN`]s support basic vector space operations, and
1f301affeae3 Fix internal links in documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 5
diff changeset
18 [minimisation][crate::bounds::MinMaxMapping::minimise] and
1f301affeae3 Fix internal links in documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 5
diff changeset
19 [maximisation][crate::bounds::MinMaxMapping::maximise]
1f301affeae3 Fix internal links in documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 5
diff changeset
20 via a [branch-and-bound strategy][BTSearch::search_and_refine].
5
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
21
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
22 The nodes of a bisection tree also store aggregate information about the objects stored in the
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
23 tree via an [`Aggregator`]. This way, rough upper and lower [bound][Bounds] estimates on
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
24 $\sum_{k=1}^m f_k$ can be efficiently maintained in the tree, based on corresponding estimates
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
25 on each $f_k$. This is done [locally][LocalAnalysis] for every node and corresponding subcube
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
26 of the domain of the tree.
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
27
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
28 ## Type parameters
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
29
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
30 The various types and traits herein depend on several type parameters:
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
31
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
32 - `N` is the geometrical dimension and `F` the numerical type for coordinates.
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
33 - `P` is the branching factor and would generally equal $2^N$, but has to be explicitly specified
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
34 due to current restrictions in Rust's const generics.
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
35 - `D` is the data/identifier stored in the bisection tree, and `A` the [aggregate][Aggregator]
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
36 information of all the data in a branch.
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
37
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
38 ## Starting points
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
39
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
40 [`BTImpl::new`] creates a new bisection tree. [`BTImpl::insert`] can be used to insert new data
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
41 into it. [`BTImpl::iter_at`] iterates over the data at a point `x` of the domain of the tree.
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
42
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
43 A new [`BTFN`] can be constructed with [`BTFN::construct`] given an implementation of
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
44 a [`SupportGenerator`]. They can be summed and multipliced by a schalar using standard arithmetic
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
45 operations. The types of the objects in two summed `BTFN`s do not need to be the same.
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
46 To find an approximate minimum of a `BTFN` using a branch-and-bound strategy,
197
1f301affeae3 Fix internal links in documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 5
diff changeset
47 use [`crate::bounds::MinMaxMapping::minimise`].
1f301affeae3 Fix internal links in documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 5
diff changeset
48 [`crate::bounds::Bounded::bounds`] provides a shortcut to [`GlobalAnalysis`] with the
5
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
49 [`Bounds`] aggregator. If the rough bounds so obtained do not indicate that the `BTFN` is in some
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
50 given bounds, instead of doing a full minimisation and maximisation for higher quality bounds,
197
1f301affeae3 Fix internal links in documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 5
diff changeset
51 it is more efficient to use [`crate::bounds::MinMaxMapping::has_upper_bound`] and
1f301affeae3 Fix internal links in documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 5
diff changeset
52 [`crate::bounds::MinMaxMapping::has_lower_bound`].
5
59dc4c5883f4 Improve documentation
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
53 */
0
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
54
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
55 mod supportid;
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
56 pub use supportid::*;
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
57 mod aggregator;
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
58 pub use aggregator::*;
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
59 mod either;
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
60 pub use either::*;
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
61 mod support;
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
62 pub use support::*;
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
63 mod bt;
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
64 pub use bt::*;
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
65 mod refine;
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
66 pub use refine::*;
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
67 mod btfn;
9f27689eb130 Initialise new clean repository
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
68 pub use btfn::*;

mercurial