# Rafting basins and “swim distance” to global minima

We define **rafting** as follows:

- Nodes are **ordered supports** of size `d+1` (so with `d=2`, nodes are ordered triples of point ids).
- Neighbours differ by **changing exactly one** support entry to a different data point.
- From each node, take the neighbour with the **largest loss drop** (strictly improving). Repeat until no improving
  neighbour exists. The endpoint is a **local minimum** (a sink).

This gives an equivalence relation (“basins of attraction”):

- Two nodes are equivalent if rafting sends them to the **same sink**.

## “Swim distance” to a global basin

Let a **global basin** mean “a basin whose sink is a global minimum (lowest loss overall)”.

For a **non-global** sink `s`, define its **swim distance** as:

- the smallest number of single-point support changes needed to reach **any node** whose basin is global.

After you reach a node in a global basin, rafting will take you to a global minimum.

All plots below are made by `code/plot_rafting_basins.py` (using `p=3`, `loss=L∞`).

## Examples

### n = 5 (60 nodes)

- Dataset: `padic_lr_tiny5_dataset.csv`
- Sink network (node size ∝ basin size; global minima are red stars; colour = swim distance):

![tiny5 basin network](padic_lr_tiny5_basin_network.png)

- Histogram of swim distances (count of sinks, and basin-weighted fraction of start nodes):

![tiny5 upstream hist](padic_lr_tiny5_upstream_hist.png)

Sink table: `padic_lr_tiny5_basin_sinks.csv`

### n = 6 (120 nodes; seed 24)

- Dataset: `padic_lr_tiny6_dataset_seed24.csv`

![tiny6 basin network](padic_lr_tiny6_basin_network_seed24.png)

![tiny6 upstream hist](padic_lr_tiny6_upstream_hist_seed24.png)

Sink table: `padic_lr_tiny6_basin_sinks_seed24.csv`

### n = 8 (336 nodes; seed 8376)

- Dataset: `padic_lr_tiny8_dataset_seed8376.csv`

![tiny8 basin network](padic_lr_tiny8_basin_network_seed8376.png)

![tiny8 upstream hist](padic_lr_tiny8_upstream_hist_seed8376.png)

Sink table: `padic_lr_tiny8_basin_sinks_seed8376.csv`

## A trend (so far)

In these examples, **every non-global sink is 1 step away from a global basin**: one single-point support change is
enough to escape into a basin that rafts to a global minimum.

