Skip to content

Commit be5dd8c

Browse files
author
Lara Chiara Ost
committed
Initial commit
0 parents  commit be5dd8c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+26392
-0
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
build/
2+
conf/
3+
.vscode
4+
.cache
5+
.clangd
6+
test*
7+
!test

LICENSE

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
Copyright 2024 Lara Ost
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Banana Trees
2+
3+
This implements the banana tree data structure introduced by Cultrera di Montesano, Edelsbrunner, Henzinger and Ost at SODA 2024.
4+
5+
# Build Instructions
6+
7+
The code is written in C++20.
8+
Building requires boost (any reasonably recent version should do; we use the pool library and the intrusive library).
9+
All other dependencies are in the `ext` directory.
10+
11+
To compile using `meson` and `ninja`:
12+
```
13+
mkdir build
14+
meson setup --buildtype=release build .
15+
ninja -C build/
16+
```
17+
18+
If `operator<<` for `std::chrono::duration` types is not available, run `meson setup -D fallback-operator=true build .` instead.
19+
Alternatively, run `meson configure -D fallback-operator=true build` after the setup step.
20+
21+
Replace `release` by `debug` for a debug build.
22+
23+
Tests are build if meson finds `GTest` and `gtest_main`.
24+
25+
# Running Experiments
26+
27+
Relevant executables are `ex_construction`, `ex_local_maintenance`, `ex_topological_maintenance`, `ex_time_series`.
28+
Run with option `--help` to see the available options.
29+
The string passed to `--gen-args` is described in `docs/generators.md`
30+
31+
`ex_construction` generates a time series and measures the time for constructing the banana tree.
32+
33+
`ex_local_maintenance` generates a time series and measures the time for value changes in an interval $M = [-m,m]$.
34+
It selects a random item, then, from the original input, changes the value of that item by values in $M$.
35+
The magnitudes of the changes are chosen from $M$ uniformly spaced; $D$ changes are performed in total.
36+
The paramters $m$ and $D$ are user specified (`-m` and `-d`, respectively).
37+
38+
`ex_topological_maintenance` generates a time series and measures the time for topological operations.
39+
The size of the left interval relative to the total time series is given by the option `-c`.
40+
41+
Both `ex_local_maintenance` and `ex_topological_maintenance` can run worst-case scenarios by selecting the appropriate subcommand.
42+
The `num_items` option works slightly differently in these executables than described in the help string:
43+
the format is `min number_of_divisions max`; `number_of_divisions` values are selected from the interval `[min, max]`,
44+
such that they are spaced evenly on a logarithmic scale.
45+
46+
`ex_time_series construct` reads a time series from standard input in the form of a sequence of function values and constructs the banana tree.
47+
48+
Each executable outputs performance statistics to standard output.
49+
This output can be converted into a csv-file using the python script `tools/convert-to-csv.py`.
50+
Structural properties of the banana trees can be written to a separate file via the option `-o`.
51+
This output can be converted into a csv-file using the python script `tools/structure-convert-to-csv.py`.
52+
53+
# License
54+
55+
This repository, except files in `ext/`, is published under the MIT license.
56+
57+
See the files in `ext/` for the respective licenses.

docs/banana_tree_conventions.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Banana Trees
2+
3+
This document describes conventions used in the implementation. See the paper for a full description of banana trees.
4+
5+
## Nodes in Banana Trees
6+
7+
A node in a banana tree has between two and four neighbors:
8+
9+
- Internal nodes have neighbors on the same trail (pointed to by `up` and `down`) and the first node(s) on their in- and mid-trail (pointed to by `in` and `mid`).
10+
- The special root has the first nodes on its in- and mid-trail as its only neighbors (pointed to by `in` and `mid`).
11+
- Leaves have the first nodes on their in- and mid-trails as neighbors (pointed to by `in` and `mid`).
12+
13+
The `up` and `down` pointers of leaves and the special root are `null`.
14+
All nodes have non-null `low` pointers; only leaves have non-null `death` pointers.
15+
16+
| | up | down | in | mid | low | death |
17+
|--------------|----|------|----|-----|-----|-------|
18+
|internal node | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
19+
|leaf | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: | `= this` | :heavy_check_mark: |
20+
|special root | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: | `= in->low` | :x: |
21+
22+
### `low` Pointers
23+
24+
`low` pointers generally point to the descendant with the lowest function value.
25+
For internal nodes this is the lower end of the trail containing the node.
26+
The `low`-pointers of leaves point to themselves and the `low`-pointer of the special root points to the birth of the global window, i.e., to the lower end of the trails starting at the special root.
27+
28+
### `death` Pointers
29+
30+
`death` pointers are only not `null` at leaves, where they point to the node upper end of the trails starting at the leaf.
31+
32+
## Construction
33+
34+
Which of the trails beginning at the special root is the in-trail and which is the mid-trail is not specified in the paper. However, the construction algorithm always ends up with the left trail being the in-trail and the right trail being the mid-trail.
35+
36+
For a node on the special banana, we say that it is on the in-trail if its item is left of the item represented by `low` of the special root. Otherwise, it is on the mid-trail.

docs/generators.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Synthetic Data Generators
2+
3+
## Gaussian Random Walks
4+
5+
Generate a random walk where $f(x_i) = f(x_{i-1}) + \cal{N}(\mu, \sigma)$.
6+
7+
Pass to `--gen_args` as
8+
```
9+
grw:<mean>;<sd>
10+
```
11+
`<mean>` is the mean of the normal distribution, `<sd>` its standard deviation.
12+
All parameters (`<...>`) are converted to a number by `std::stod(...)`.
13+
Parameter `<sd>` is optional.
14+
15+
## Linear Case for Local Maintenance
16+
17+
Pass to `--gen_args` as `local-wc`.
18+
19+
## Quasi-Periodic Functions
20+
21+
### Method 1 -- Sine Wave + Random Walk
22+
23+
$f(x) = a \cdot sin(\omega x) + R(x; \mu, \sigma)$, where $R(x; \mu, \sigma)$ is a Gaussian random walk.
24+
25+
Parameters:
26+
- $a$: amplitude of the sine wave
27+
- $\omega$: angular frequency in items; $\omega = 1/(2\pi \cdot b)$ has period $b$
28+
- $\mu$: mean of the normal distribution of the random walk
29+
- $\sigma$: the standard deviation of the normal distribution of the random walk
30+
31+
Pass to `--gen_args` as
32+
```
33+
sqp:<period>;<amplitude>;<mean>;<sd>
34+
```
35+
All parameters (`<...>`) are converted to a number by `std::stod(...)`.
36+
All are optional, but must be specified in the given order,
37+
i.e., if `<mean>` is given, then `<period>` and `<amplitude>` cannot be omitted.
38+
39+
### Method 2 -- Sine Wave Modulating a Random Walk
40+
41+
$f(x) = R(x; a \cdot sin(wx), \sigma)$, where $R(x; \mu, \sigma)$ is a Gaussian random walk.
42+
43+
Parameters:
44+
- $a$: amplitude of the sine wave
45+
- $\omega$: angular frequency in items; $\omega = 1/(2\pi \cdot b)$ has period $b$
46+
- $\sigma$: mean of the normal distribution of the random walk as above
47+
48+
Pass to `--gen_args` as
49+
```
50+
mqp:<number of periods>;<amplitude>;<sd>
51+
```
52+
All parameters (`<...>`) are converted to a number by `std::stod(...)`.
53+
All are optional, but must be specified in the given order,
54+
i.e., if `<sd>` is given, then `<number of periods>` and `<amplitude>` cannot be omitted.
903 KB
Binary file not shown.

0 commit comments

Comments
 (0)