EmptySpaceSearch 0.5.2__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/PKG-INFO +56 -16
  2. emptyspacesearch-0.5.2/src/EmptySpaceSearch.egg-info/PKG-INFO → emptyspacesearch-0.7.0/README.md +47 -34
  3. emptyspacesearch-0.7.0/pyproject.toml +73 -0
  4. emptyspacesearch-0.5.2/README.md → emptyspacesearch-0.7.0/src/EmptySpaceSearch.egg-info/PKG-INFO +74 -14
  5. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/src/EmptySpaceSearch.egg-info/SOURCES.txt +2 -0
  6. emptyspacesearch-0.7.0/src/EmptySpaceSearch.egg-info/requires.txt +10 -0
  7. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/src/ess/__init__.py +40 -20
  8. emptyspacesearch-0.7.0/src/ess/attraction.py +356 -0
  9. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/src/ess/ess.py +167 -235
  10. emptyspacesearch-0.7.0/src/ess/geometry.py +168 -0
  11. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/src/ess/utils.py +33 -23
  12. emptyspacesearch-0.7.0/test/test_attraction.py +229 -0
  13. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/test/test_ess.py +203 -92
  14. emptyspacesearch-0.7.0/test/test_examples.py +116 -0
  15. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/test/test_forces.py +65 -33
  16. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/test/test_utils.py +30 -15
  17. emptyspacesearch-0.5.2/pyproject.toml +0 -44
  18. emptyspacesearch-0.5.2/src/EmptySpaceSearch.egg-info/requires.txt +0 -2
  19. emptyspacesearch-0.5.2/src/ess/attraction.py +0 -473
  20. emptyspacesearch-0.5.2/test/test_attraction.py +0 -214
  21. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/LICENSE +0 -0
  22. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/setup.cfg +0 -0
  23. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/src/EmptySpaceSearch.egg-info/dependency_links.txt +0 -0
  24. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/src/EmptySpaceSearch.egg-info/top_level.txt +0 -0
  25. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/src/ess/baseline.py +0 -0
  26. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/src/ess/legacy.py +0 -0
  27. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/src/ess/samplers.py +0 -0
  28. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/test/test_baseline.py +0 -0
  29. {emptyspacesearch-0.5.2 → emptyspacesearch-0.7.0}/test/test_packaging.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: EmptySpaceSearch
3
- Version: 0.5.2
3
+ Version: 0.7.0
4
4
  Summary: Empty Space Search
5
5
  Author-email: Mário Antunes <mario.antunes@ua.pt>
6
6
  License: MIT
@@ -15,7 +15,14 @@ Requires-Python: >=3.12
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
17
  Requires-Dist: numpy>=2.0.0
18
- Requires-Dist: torann>=0.2.1
18
+ Requires-Dist: torann>=0.5.0
19
+ Provides-Extra: dev
20
+ Requires-Dist: ruff==0.16.1; extra == "dev"
21
+ Requires-Dist: basedpyright==1.39.8; extra == "dev"
22
+ Requires-Dist: vulture==2.16; extra == "dev"
23
+ Requires-Dist: coverage==7.14.2; extra == "dev"
24
+ Requires-Dist: pre-commit; extra == "dev"
25
+ Requires-Dist: matplotlib; extra == "dev"
19
26
  Dynamic: license-file
20
27
 
21
28
  # ![ESS Logo](assets/ess_logo.svg) Empty Space Search (ESS)
@@ -36,7 +43,7 @@ It simulates electrostatic repulsive forces to "relax" new points into the empty
36
43
  * **Radius-Based Interactions**: Supports physical range searches (interacting with *all* neighbors within a radius) alongside standard k-NN, with automatic L1-ball radius estimation for high-dimensional spaces.
37
44
  * **Single Scalable Engine**: Neighbour search is [torann](https://github.com/mariolpantunes/torann) — exact brute force at small N, toroidal LSH above its threshold, chosen internally; per-epoch coordinate updates are native (no index rebuilds).
38
45
  * **Robust Early Stopping**: Convergence is detected on the force field itself (plateau of the largest net force, learning-rate-decoupled), typically stopping in tens of epochs instead of hundreds.
39
- * **High-Dimensional Metrics**: Includes robust coverage metrics (Maximin, Clark-Evans Index, Sparse Grid Coverage) optimized for dimensions > 32D.
46
+ * **High-Dimensional Metrics**: Ranks designs on wrap-around and projection discrepancy — normalised so 1.0 = random, and valid at any ambient dimension. Toroidal separation (shared with [torann](https://github.com/mariolpantunes/torann)) is reported as a diagnostic. Clark-Evans has been removed; see *Metrics* below for why.
40
47
  * **Smart Initialization**: Uses a vectorized "Best Candidate" sampling strategy to seed new batches in the most promising void regions.
41
48
  * **Guided Attraction (New in v0.5.0)**: Given the attractiveness of the measured points, placement and relaxation both balance repulsion against a pull toward promising regions, with the collapse condition checked rather than discovered.
42
49
 
@@ -132,7 +139,7 @@ new_points = esa(
132
139
  attraction_weight=0.5, # pull against the repulsion
133
140
  attraction_metric='cauchy', # must decay slower than the repulsion
134
141
  attraction_kwargs={'power': 1.0},
135
- att_model='auto', # how unmeasured positions are estimated
142
+ att_model='idw', # how unmeasured positions are estimated
136
143
  )
137
144
  ```
138
145
 
@@ -141,11 +148,17 @@ paid for, so a candidate's is estimated. `att_model` picks how:
141
148
 
142
149
  | model | coefficients | how they are obtained |
143
150
  |---|---|---|
144
- | `idw` | none | inverse-distance over the `k_att` nearest measured points |
145
- | `fourier` | `2d+1` | least squares, ridge-regularised |
151
+ | `idw` | none | **default**: inverse-distance over the `k_att` nearest measured points |
146
152
  | `projection` | `2d` | correlation against the basis, James-Stein shrunk |
147
- | `detrended` | `2d+1` | the Fourier fit plus IDW on its residual |
148
- | `auto` | — | **default**: cross-validates the others and keeps the best |
153
+
154
+ `fourier`, `detrended` and `auto` were removed in v1.0.0. All three fit `2d`
155
+ coefficients, and a caller supplies anchors by population size rather than by
156
+ dimension, so staying identifiable needed a population growing linearly in `d`
157
+ — where every anchor is a paid objective call. Measured inside OBLESA as the
158
+ share of the selected population the relaxed block won, against 33% parity,
159
+ `detrended` fell 70.4 → 13.8 across `d = 8..64` while `idw` held 74.9 → 71.0.
160
+ `auto` additionally cross-validated four candidates on every fit: 23 ms at 60
161
+ sources, 86 seconds at 15360.
149
162
 
150
163
  **Why a trigonometric basis.** The space is a torus, so a model of it has to be
151
164
  periodic — a polynomial is discontinuous at the seam and would assert a
@@ -155,12 +168,12 @@ quadratic well is the von Mises density, whose logarithm is
155
168
  axis. A first-harmonic model *is* an additive log-von-Mises field. Higher
156
169
  harmonics buy narrower and multimodal wells, at `2·harmonics·d` coefficients.
157
170
 
158
- **Which to use.** `fourier` solves for its coefficients, so it needs more
159
- measured points than unknowns; `projection` correlates instead, which stays
160
- defined at any count. Held-out error, normalised so 1.0 is what predicting the
161
- mean scores:
171
+ **Which to use.** `idw`, unless you know the objective is additive and you
172
+ have far more measured points than `2d`. Held-out error, normalised so 1.0 is
173
+ what predicting the mean scores — the removed ridge is kept in the table
174
+ because it is *why* the others are hedged:
162
175
 
163
- | truth | ridge | projection | idw |
176
+ | truth | ridge (removed) | projection | idw |
164
177
  |---|---|---|---|
165
178
  | additive, `d=8`, `M=300` | **0.31** | 0.36 | 0.48 |
166
179
  | additive, `d=100`, `M=30` | **0.78** | 0.80 | 0.80 |
@@ -170,7 +183,16 @@ mean scores:
170
183
  Above 1.0 means worse than abstaining. Least squares commits hard, which pays
171
184
  when the basis matches the truth and costs when it does not; the shrunk
172
185
  projection and the interpolation both hedge. Four of the eight objectives in
173
- the downstream benchmark are non-separable, which is where that matters.
186
+ the downstream benchmark are non-separable, which is where that matters — and
187
+ it is why the model that wins the first row was still the wrong default.
188
+
189
+ **Two costs `idw` does carry**, both measured rather than argued. Its query is
190
+ `O(M·d)` with no closed form to tabulate, so 512 queries against 15360 sources
191
+ at `d=100` take 2.35 s against 2.4 ms for a tabulated harmonic model. And in
192
+ high dimension distances concentrate, so more sources stop helping:
193
+ leave-one-out error at `d=100` moves only 0.624 → 0.614 as `M` goes 60 → 300.
194
+ Neither bites at the anchor counts a population-sized caller supplies (60–400),
195
+ which is the regime this default is chosen for.
174
196
 
175
197
  No fixed choice wins in both regimes, and the one that decides it — whether the
176
198
  additive basis matches the objective — cannot be read off `M` and `d`. So
@@ -194,7 +216,7 @@ class MyModel(ess.AttractionModel):
194
216
  ess.esa(samples, bounds, n=60, attractiveness=-scores, att_model=MyModel())
195
217
  ```
196
218
 
197
- `att_model` also takes a tuned built-in, e.g. `ess.HarmonicRidge(harmonics=3)`.
219
+ `att_model` also takes a tuned built-in, e.g. `ess.HarmonicProjection(harmonics=3)`.
198
220
 
199
221
  Two guards are checked rather than left to a run. An attraction that
200
222
  out-pulls repulsion at contact collapses every free point onto its most
@@ -249,9 +271,27 @@ Uniformity metrics do not survive high dimension equally well, so
249
271
  | `wrap_around_discrepancy` | deviation from uniform over every wrap-around box, full dimension | **yes** |
250
272
  | `projection_discrepancy` | the same, averaged over 1-D / 2-D coordinate projections; fixed scale in any ambient $d$ | **yes** |
251
273
  | `expected_discrepancy` | the null both are divided by, so 1.0 = as uniform as random | — |
252
- | `toroidal_separation` | the smallest toroidal $L_1$ gap in the set | diagnostic only |
274
+ | `toroidal_separation` | the smallest toroidal $L_1$ gap to another point (defined in `torann.metrics`) | diagnostic only |
253
275
  | `euclidean_separation`, `calculate_grid_coverage` | non-wrapping separation, and grid occupancy | provenance only |
254
276
 
277
+ ### Division of labour with torann
278
+
279
+ `torann` answers **geometric** questions — which points are near which, and how
280
+ far apart. It owns the neighbour index and the *definitions* of toroidal point
281
+ metrics, each being one exact k-NN scan. ESS owns everything about **purpose**:
282
+ how designs are generated, and which metric decides that one is better. That
283
+ second question depends on what the points are for, so it is answered here and
284
+ not there.
285
+
286
+ The line was drawn after the alternative failed. With a metric defined in one
287
+ project and chosen in another, a rename in one silently outlived the other: two
288
+ benchmark scripts kept asking for a removed key and died in their reporting
289
+ *after completing every run*, and a third printed a lower-is-better discrepancy
290
+ under a higher-is-better heading — reporting a 10x improvement as a 10x
291
+ regression — for weeks, without ever failing. `test/test_examples.py` now runs
292
+ every example end to end, because importing them does not catch a bad key
293
+ inside a report function.
294
+
255
295
  **Rank designs with the two discrepancies.** They measure deviation from
256
296
  uniformity and reference no point metric at all, so no choice of geometry
257
297
  can flatter an arm that happened to optimise it. Divide by
@@ -1,23 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: EmptySpaceSearch
3
- Version: 0.5.2
4
- Summary: Empty Space Search
5
- Author-email: Mário Antunes <mario.antunes@ua.pt>
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/mariolpantunes/ess
8
- Project-URL: Documentation, https://mariolpantunes.github.io/ess/
9
- Project-URL: Repository, https://github.com/mariolpantunes/ess
10
- Project-URL: Issues, https://github.com/mariolpantunes/ess/issues
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Operating System :: OS Independent
14
- Requires-Python: >=3.12
15
- Description-Content-Type: text/markdown
16
- License-File: LICENSE
17
- Requires-Dist: numpy>=2.0.0
18
- Requires-Dist: torann>=0.2.1
19
- Dynamic: license-file
20
-
21
1
  # ![ESS Logo](assets/ess_logo.svg) Empty Space Search (ESS)
22
2
 
23
3
  ![PyPI - Version](https://img.shields.io/pypi/v/EmptySpaceSearch)
@@ -36,7 +16,7 @@ It simulates electrostatic repulsive forces to "relax" new points into the empty
36
16
  * **Radius-Based Interactions**: Supports physical range searches (interacting with *all* neighbors within a radius) alongside standard k-NN, with automatic L1-ball radius estimation for high-dimensional spaces.
37
17
  * **Single Scalable Engine**: Neighbour search is [torann](https://github.com/mariolpantunes/torann) — exact brute force at small N, toroidal LSH above its threshold, chosen internally; per-epoch coordinate updates are native (no index rebuilds).
38
18
  * **Robust Early Stopping**: Convergence is detected on the force field itself (plateau of the largest net force, learning-rate-decoupled), typically stopping in tens of epochs instead of hundreds.
39
- * **High-Dimensional Metrics**: Includes robust coverage metrics (Maximin, Clark-Evans Index, Sparse Grid Coverage) optimized for dimensions > 32D.
19
+ * **High-Dimensional Metrics**: Ranks designs on wrap-around and projection discrepancy — normalised so 1.0 = random, and valid at any ambient dimension. Toroidal separation (shared with [torann](https://github.com/mariolpantunes/torann)) is reported as a diagnostic. Clark-Evans has been removed; see *Metrics* below for why.
40
20
  * **Smart Initialization**: Uses a vectorized "Best Candidate" sampling strategy to seed new batches in the most promising void regions.
41
21
  * **Guided Attraction (New in v0.5.0)**: Given the attractiveness of the measured points, placement and relaxation both balance repulsion against a pull toward promising regions, with the collapse condition checked rather than discovered.
42
22
 
@@ -132,7 +112,7 @@ new_points = esa(
132
112
  attraction_weight=0.5, # pull against the repulsion
133
113
  attraction_metric='cauchy', # must decay slower than the repulsion
134
114
  attraction_kwargs={'power': 1.0},
135
- att_model='auto', # how unmeasured positions are estimated
115
+ att_model='idw', # how unmeasured positions are estimated
136
116
  )
137
117
  ```
138
118
 
@@ -141,11 +121,17 @@ paid for, so a candidate's is estimated. `att_model` picks how:
141
121
 
142
122
  | model | coefficients | how they are obtained |
143
123
  |---|---|---|
144
- | `idw` | none | inverse-distance over the `k_att` nearest measured points |
145
- | `fourier` | `2d+1` | least squares, ridge-regularised |
124
+ | `idw` | none | **default**: inverse-distance over the `k_att` nearest measured points |
146
125
  | `projection` | `2d` | correlation against the basis, James-Stein shrunk |
147
- | `detrended` | `2d+1` | the Fourier fit plus IDW on its residual |
148
- | `auto` | — | **default**: cross-validates the others and keeps the best |
126
+
127
+ `fourier`, `detrended` and `auto` were removed in v1.0.0. All three fit `2d`
128
+ coefficients, and a caller supplies anchors by population size rather than by
129
+ dimension, so staying identifiable needed a population growing linearly in `d`
130
+ — where every anchor is a paid objective call. Measured inside OBLESA as the
131
+ share of the selected population the relaxed block won, against 33% parity,
132
+ `detrended` fell 70.4 → 13.8 across `d = 8..64` while `idw` held 74.9 → 71.0.
133
+ `auto` additionally cross-validated four candidates on every fit: 23 ms at 60
134
+ sources, 86 seconds at 15360.
149
135
 
150
136
  **Why a trigonometric basis.** The space is a torus, so a model of it has to be
151
137
  periodic — a polynomial is discontinuous at the seam and would assert a
@@ -155,12 +141,12 @@ quadratic well is the von Mises density, whose logarithm is
155
141
  axis. A first-harmonic model *is* an additive log-von-Mises field. Higher
156
142
  harmonics buy narrower and multimodal wells, at `2·harmonics·d` coefficients.
157
143
 
158
- **Which to use.** `fourier` solves for its coefficients, so it needs more
159
- measured points than unknowns; `projection` correlates instead, which stays
160
- defined at any count. Held-out error, normalised so 1.0 is what predicting the
161
- mean scores:
144
+ **Which to use.** `idw`, unless you know the objective is additive and you
145
+ have far more measured points than `2d`. Held-out error, normalised so 1.0 is
146
+ what predicting the mean scores — the removed ridge is kept in the table
147
+ because it is *why* the others are hedged:
162
148
 
163
- | truth | ridge | projection | idw |
149
+ | truth | ridge (removed) | projection | idw |
164
150
  |---|---|---|---|
165
151
  | additive, `d=8`, `M=300` | **0.31** | 0.36 | 0.48 |
166
152
  | additive, `d=100`, `M=30` | **0.78** | 0.80 | 0.80 |
@@ -170,7 +156,16 @@ mean scores:
170
156
  Above 1.0 means worse than abstaining. Least squares commits hard, which pays
171
157
  when the basis matches the truth and costs when it does not; the shrunk
172
158
  projection and the interpolation both hedge. Four of the eight objectives in
173
- the downstream benchmark are non-separable, which is where that matters.
159
+ the downstream benchmark are non-separable, which is where that matters — and
160
+ it is why the model that wins the first row was still the wrong default.
161
+
162
+ **Two costs `idw` does carry**, both measured rather than argued. Its query is
163
+ `O(M·d)` with no closed form to tabulate, so 512 queries against 15360 sources
164
+ at `d=100` take 2.35 s against 2.4 ms for a tabulated harmonic model. And in
165
+ high dimension distances concentrate, so more sources stop helping:
166
+ leave-one-out error at `d=100` moves only 0.624 → 0.614 as `M` goes 60 → 300.
167
+ Neither bites at the anchor counts a population-sized caller supplies (60–400),
168
+ which is the regime this default is chosen for.
174
169
 
175
170
  No fixed choice wins in both regimes, and the one that decides it — whether the
176
171
  additive basis matches the objective — cannot be read off `M` and `d`. So
@@ -194,7 +189,7 @@ class MyModel(ess.AttractionModel):
194
189
  ess.esa(samples, bounds, n=60, attractiveness=-scores, att_model=MyModel())
195
190
  ```
196
191
 
197
- `att_model` also takes a tuned built-in, e.g. `ess.HarmonicRidge(harmonics=3)`.
192
+ `att_model` also takes a tuned built-in, e.g. `ess.HarmonicProjection(harmonics=3)`.
198
193
 
199
194
  Two guards are checked rather than left to a run. An attraction that
200
195
  out-pulls repulsion at contact collapses every free point onto its most
@@ -249,9 +244,27 @@ Uniformity metrics do not survive high dimension equally well, so
249
244
  | `wrap_around_discrepancy` | deviation from uniform over every wrap-around box, full dimension | **yes** |
250
245
  | `projection_discrepancy` | the same, averaged over 1-D / 2-D coordinate projections; fixed scale in any ambient $d$ | **yes** |
251
246
  | `expected_discrepancy` | the null both are divided by, so 1.0 = as uniform as random | — |
252
- | `toroidal_separation` | the smallest toroidal $L_1$ gap in the set | diagnostic only |
247
+ | `toroidal_separation` | the smallest toroidal $L_1$ gap to another point (defined in `torann.metrics`) | diagnostic only |
253
248
  | `euclidean_separation`, `calculate_grid_coverage` | non-wrapping separation, and grid occupancy | provenance only |
254
249
 
250
+ ### Division of labour with torann
251
+
252
+ `torann` answers **geometric** questions — which points are near which, and how
253
+ far apart. It owns the neighbour index and the *definitions* of toroidal point
254
+ metrics, each being one exact k-NN scan. ESS owns everything about **purpose**:
255
+ how designs are generated, and which metric decides that one is better. That
256
+ second question depends on what the points are for, so it is answered here and
257
+ not there.
258
+
259
+ The line was drawn after the alternative failed. With a metric defined in one
260
+ project and chosen in another, a rename in one silently outlived the other: two
261
+ benchmark scripts kept asking for a removed key and died in their reporting
262
+ *after completing every run*, and a third printed a lower-is-better discrepancy
263
+ under a higher-is-better heading — reporting a 10x improvement as a 10x
264
+ regression — for weeks, without ever failing. `test/test_examples.py` now runs
265
+ every example end to end, because importing them does not catch a bad key
266
+ inside a report function.
267
+
255
268
  **Rank designs with the two discrepancies.** They measure deviation from
256
269
  uniformity and reference no point metric at all, so no choice of geometry
257
270
  can flatter an arm that happened to optimise it. Divide by
@@ -0,0 +1,73 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "EmptySpaceSearch"
7
+ version = "0.7.0"
8
+ authors = [
9
+ {name = "Mário Antunes", email = "mario.antunes@ua.pt"}
10
+ ]
11
+ description = "Empty Space Search"
12
+ readme = "README.md"
13
+ license = {text = "MIT"}
14
+ requires-python = ">=3.12"
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ ]
20
+ dependencies = [
21
+ "numpy>=2.0.0",
22
+ "torann>=0.5.0",
23
+ ]
24
+
25
+ [project.optional-dependencies]
26
+ # The gate's toolchain, pinned in one place so `pre-commit` and
27
+ # `.github/workflows` cannot run different versions of it. They used to name
28
+ # versions separately and drifted -- CI pinned basedpyright 1.39.8 while this
29
+ # repository's venv had 1.39.9 -- and `language: system` hooks, which is what
30
+ # these are deliberately, run whatever is installed.
31
+ #
32
+ # Install with: pip install -e ".[dev]"
33
+ dev = [
34
+ "ruff==0.16.1",
35
+ "basedpyright==1.39.8",
36
+ "vulture==2.16",
37
+ "coverage==7.14.2",
38
+ "pre-commit",
39
+ # Only the plot examples need it. It is here so `test_examples.py`
40
+ # actually runs them in CI instead of skipping them, which is the whole
41
+ # point of that test.
42
+ "matplotlib",
43
+ ]
44
+
45
+ [project.urls]
46
+ Homepage = "https://github.com/mariolpantunes/ess"
47
+ Documentation = "https://mariolpantunes.github.io/ess/"
48
+ Repository = "https://github.com/mariolpantunes/ess"
49
+ Issues = "https://github.com/mariolpantunes/ess/issues"
50
+
51
+ [tool.setuptools.packages.find]
52
+ where = ["src"]
53
+
54
+ [tool.ruff]
55
+ line-length = 120
56
+
57
+ [tool.ruff.lint.per-file-ignores]
58
+ # `test/` and `examples/` are linted now -- they are where the rot happens --
59
+ # but two rules are noise outside the package: B023 (a closure over a loop
60
+ # variable, always consumed in the same iteration by a benchmark harness
61
+ # here) and RUF059 (an unused half of `idx, dst = ...` in a test that only
62
+ # asserts on one). Everything else applies, correctness rules included.
63
+ "test/**" = ["B023", "RUF059"]
64
+ "examples/**" = ["B023", "RUF059"]
65
+
66
+ [tool.basedpyright]
67
+ typeCheckingMode = "standard"
68
+ include = ["src/ess"]
69
+ reportImportCycles = "none"
70
+
71
+ [tool.vulture]
72
+ paths = ["src/ess"]
73
+ min_confidence = 80
@@ -1,3 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: EmptySpaceSearch
3
+ Version: 0.7.0
4
+ Summary: Empty Space Search
5
+ Author-email: Mário Antunes <mario.antunes@ua.pt>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/mariolpantunes/ess
8
+ Project-URL: Documentation, https://mariolpantunes.github.io/ess/
9
+ Project-URL: Repository, https://github.com/mariolpantunes/ess
10
+ Project-URL: Issues, https://github.com/mariolpantunes/ess/issues
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.12
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: numpy>=2.0.0
18
+ Requires-Dist: torann>=0.5.0
19
+ Provides-Extra: dev
20
+ Requires-Dist: ruff==0.16.1; extra == "dev"
21
+ Requires-Dist: basedpyright==1.39.8; extra == "dev"
22
+ Requires-Dist: vulture==2.16; extra == "dev"
23
+ Requires-Dist: coverage==7.14.2; extra == "dev"
24
+ Requires-Dist: pre-commit; extra == "dev"
25
+ Requires-Dist: matplotlib; extra == "dev"
26
+ Dynamic: license-file
27
+
1
28
  # ![ESS Logo](assets/ess_logo.svg) Empty Space Search (ESS)
2
29
 
3
30
  ![PyPI - Version](https://img.shields.io/pypi/v/EmptySpaceSearch)
@@ -16,7 +43,7 @@ It simulates electrostatic repulsive forces to "relax" new points into the empty
16
43
  * **Radius-Based Interactions**: Supports physical range searches (interacting with *all* neighbors within a radius) alongside standard k-NN, with automatic L1-ball radius estimation for high-dimensional spaces.
17
44
  * **Single Scalable Engine**: Neighbour search is [torann](https://github.com/mariolpantunes/torann) — exact brute force at small N, toroidal LSH above its threshold, chosen internally; per-epoch coordinate updates are native (no index rebuilds).
18
45
  * **Robust Early Stopping**: Convergence is detected on the force field itself (plateau of the largest net force, learning-rate-decoupled), typically stopping in tens of epochs instead of hundreds.
19
- * **High-Dimensional Metrics**: Includes robust coverage metrics (Maximin, Clark-Evans Index, Sparse Grid Coverage) optimized for dimensions > 32D.
46
+ * **High-Dimensional Metrics**: Ranks designs on wrap-around and projection discrepancy — normalised so 1.0 = random, and valid at any ambient dimension. Toroidal separation (shared with [torann](https://github.com/mariolpantunes/torann)) is reported as a diagnostic. Clark-Evans has been removed; see *Metrics* below for why.
20
47
  * **Smart Initialization**: Uses a vectorized "Best Candidate" sampling strategy to seed new batches in the most promising void regions.
21
48
  * **Guided Attraction (New in v0.5.0)**: Given the attractiveness of the measured points, placement and relaxation both balance repulsion against a pull toward promising regions, with the collapse condition checked rather than discovered.
22
49
 
@@ -112,7 +139,7 @@ new_points = esa(
112
139
  attraction_weight=0.5, # pull against the repulsion
113
140
  attraction_metric='cauchy', # must decay slower than the repulsion
114
141
  attraction_kwargs={'power': 1.0},
115
- att_model='auto', # how unmeasured positions are estimated
142
+ att_model='idw', # how unmeasured positions are estimated
116
143
  )
117
144
  ```
118
145
 
@@ -121,11 +148,17 @@ paid for, so a candidate's is estimated. `att_model` picks how:
121
148
 
122
149
  | model | coefficients | how they are obtained |
123
150
  |---|---|---|
124
- | `idw` | none | inverse-distance over the `k_att` nearest measured points |
125
- | `fourier` | `2d+1` | least squares, ridge-regularised |
151
+ | `idw` | none | **default**: inverse-distance over the `k_att` nearest measured points |
126
152
  | `projection` | `2d` | correlation against the basis, James-Stein shrunk |
127
- | `detrended` | `2d+1` | the Fourier fit plus IDW on its residual |
128
- | `auto` | — | **default**: cross-validates the others and keeps the best |
153
+
154
+ `fourier`, `detrended` and `auto` were removed in v1.0.0. All three fit `2d`
155
+ coefficients, and a caller supplies anchors by population size rather than by
156
+ dimension, so staying identifiable needed a population growing linearly in `d`
157
+ — where every anchor is a paid objective call. Measured inside OBLESA as the
158
+ share of the selected population the relaxed block won, against 33% parity,
159
+ `detrended` fell 70.4 → 13.8 across `d = 8..64` while `idw` held 74.9 → 71.0.
160
+ `auto` additionally cross-validated four candidates on every fit: 23 ms at 60
161
+ sources, 86 seconds at 15360.
129
162
 
130
163
  **Why a trigonometric basis.** The space is a torus, so a model of it has to be
131
164
  periodic — a polynomial is discontinuous at the seam and would assert a
@@ -135,12 +168,12 @@ quadratic well is the von Mises density, whose logarithm is
135
168
  axis. A first-harmonic model *is* an additive log-von-Mises field. Higher
136
169
  harmonics buy narrower and multimodal wells, at `2·harmonics·d` coefficients.
137
170
 
138
- **Which to use.** `fourier` solves for its coefficients, so it needs more
139
- measured points than unknowns; `projection` correlates instead, which stays
140
- defined at any count. Held-out error, normalised so 1.0 is what predicting the
141
- mean scores:
171
+ **Which to use.** `idw`, unless you know the objective is additive and you
172
+ have far more measured points than `2d`. Held-out error, normalised so 1.0 is
173
+ what predicting the mean scores — the removed ridge is kept in the table
174
+ because it is *why* the others are hedged:
142
175
 
143
- | truth | ridge | projection | idw |
176
+ | truth | ridge (removed) | projection | idw |
144
177
  |---|---|---|---|
145
178
  | additive, `d=8`, `M=300` | **0.31** | 0.36 | 0.48 |
146
179
  | additive, `d=100`, `M=30` | **0.78** | 0.80 | 0.80 |
@@ -150,7 +183,16 @@ mean scores:
150
183
  Above 1.0 means worse than abstaining. Least squares commits hard, which pays
151
184
  when the basis matches the truth and costs when it does not; the shrunk
152
185
  projection and the interpolation both hedge. Four of the eight objectives in
153
- the downstream benchmark are non-separable, which is where that matters.
186
+ the downstream benchmark are non-separable, which is where that matters — and
187
+ it is why the model that wins the first row was still the wrong default.
188
+
189
+ **Two costs `idw` does carry**, both measured rather than argued. Its query is
190
+ `O(M·d)` with no closed form to tabulate, so 512 queries against 15360 sources
191
+ at `d=100` take 2.35 s against 2.4 ms for a tabulated harmonic model. And in
192
+ high dimension distances concentrate, so more sources stop helping:
193
+ leave-one-out error at `d=100` moves only 0.624 → 0.614 as `M` goes 60 → 300.
194
+ Neither bites at the anchor counts a population-sized caller supplies (60–400),
195
+ which is the regime this default is chosen for.
154
196
 
155
197
  No fixed choice wins in both regimes, and the one that decides it — whether the
156
198
  additive basis matches the objective — cannot be read off `M` and `d`. So
@@ -174,7 +216,7 @@ class MyModel(ess.AttractionModel):
174
216
  ess.esa(samples, bounds, n=60, attractiveness=-scores, att_model=MyModel())
175
217
  ```
176
218
 
177
- `att_model` also takes a tuned built-in, e.g. `ess.HarmonicRidge(harmonics=3)`.
219
+ `att_model` also takes a tuned built-in, e.g. `ess.HarmonicProjection(harmonics=3)`.
178
220
 
179
221
  Two guards are checked rather than left to a run. An attraction that
180
222
  out-pulls repulsion at contact collapses every free point onto its most
@@ -229,9 +271,27 @@ Uniformity metrics do not survive high dimension equally well, so
229
271
  | `wrap_around_discrepancy` | deviation from uniform over every wrap-around box, full dimension | **yes** |
230
272
  | `projection_discrepancy` | the same, averaged over 1-D / 2-D coordinate projections; fixed scale in any ambient $d$ | **yes** |
231
273
  | `expected_discrepancy` | the null both are divided by, so 1.0 = as uniform as random | — |
232
- | `toroidal_separation` | the smallest toroidal $L_1$ gap in the set | diagnostic only |
274
+ | `toroidal_separation` | the smallest toroidal $L_1$ gap to another point (defined in `torann.metrics`) | diagnostic only |
233
275
  | `euclidean_separation`, `calculate_grid_coverage` | non-wrapping separation, and grid occupancy | provenance only |
234
276
 
277
+ ### Division of labour with torann
278
+
279
+ `torann` answers **geometric** questions — which points are near which, and how
280
+ far apart. It owns the neighbour index and the *definitions* of toroidal point
281
+ metrics, each being one exact k-NN scan. ESS owns everything about **purpose**:
282
+ how designs are generated, and which metric decides that one is better. That
283
+ second question depends on what the points are for, so it is answered here and
284
+ not there.
285
+
286
+ The line was drawn after the alternative failed. With a metric defined in one
287
+ project and chosen in another, a rename in one silently outlived the other: two
288
+ benchmark scripts kept asking for a removed key and died in their reporting
289
+ *after completing every run*, and a third printed a lower-is-better discrepancy
290
+ under a higher-is-better heading — reporting a 10x improvement as a 10x
291
+ regression — for weeks, without ever failing. `test/test_examples.py` now runs
292
+ every example end to end, because importing them does not catch a bad key
293
+ inside a report function.
294
+
235
295
  **Rank designs with the two discrepancies.** They measure deviation from
236
296
  uniformity and reference no point metric at all, so no choice of geometry
237
297
  can flatter an arm that happened to optimise it. Divide by
@@ -10,12 +10,14 @@ src/ess/__init__.py
10
10
  src/ess/attraction.py
11
11
  src/ess/baseline.py
12
12
  src/ess/ess.py
13
+ src/ess/geometry.py
13
14
  src/ess/legacy.py
14
15
  src/ess/samplers.py
15
16
  src/ess/utils.py
16
17
  test/test_attraction.py
17
18
  test/test_baseline.py
18
19
  test/test_ess.py
20
+ test/test_examples.py
19
21
  test/test_forces.py
20
22
  test/test_packaging.py
21
23
  test/test_utils.py
@@ -0,0 +1,10 @@
1
+ numpy>=2.0.0
2
+ torann>=0.5.0
3
+
4
+ [dev]
5
+ ruff==0.16.1
6
+ basedpyright==1.39.8
7
+ vulture==2.16
8
+ coverage==7.14.2
9
+ pre-commit
10
+ matplotlib
@@ -36,18 +36,44 @@ Modules
36
36
  * `utils`: Metrics for spatial distribution. **Rank designs with
37
37
  `projection_discrepancy` and `wrap_around_discrepancy`** — they measure
38
38
  deviation from uniformity and reference no point metric at all, so no
39
- choice of geometry can flatter an arm that optimised it.
40
- `toroidal_separation` is a raw $L_1$ gap, useful as a diagnostic within
41
- one fixed geometry; `euclidean_separation` is its non-wrapping
42
- counterpart, kept for provenance. Clark-Evans is gone: it only has
43
- meaning divided by an expected nearest-neighbour distance, which makes it
44
- a statistic *about a metric* rather than about uniformity, and it was
45
- measurably blunt besides.
39
+ choice of geometry can flatter an arm that optimised it. ESS relaxes
40
+ under a toroidal-$L_1$ repulsion, so ranking it on a toroidal-$L_1$ point
41
+ metric would be grading the optimiser with its own loss, and would report
42
+ a large margin for exactly that reason and no other.
43
+ `toroidal_separation` is that point metric — a raw $L_1$ gap, useful as a
44
+ diagnostic within one fixed geometry, and **never** a ranking here. Its
45
+ definition comes from `torann.metrics` (see *Division of labour* below);
46
+ `euclidean_separation` is its non-wrapping counterpart, kept for
47
+ provenance. Clark-Evans is gone: it only has meaning divided by an
48
+ expected nearest-neighbour distance, which makes it a statistic *about a
49
+ metric* rather than about uniformity, and it was measurably blunt
50
+ besides.
46
51
  * `baseline`: Reference constructions for *testing* ESS, not for using it
47
52
  -- `dart` (Mitchell's best-candidate: the ablation of the relaxation),
48
53
  `random_fill` (the null), and `grid_oracle` (the emptiest point by
49
54
  exhaustion, at low `d`).
50
55
  * `legacy`: Reference implementations of earlier sequential strategies.
56
+
57
+ Division of labour with torann
58
+ ------------------------------
59
+ `torann` answers *geometric* questions — which points are near which, and how
60
+ far apart they are. It owns the neighbour index and the **definitions** of
61
+ toroidal point metrics, because each is one exact k-NN scan.
62
+
63
+ ESS owns everything about *purpose*: how designs are generated, and how they
64
+ are **ranked**. Which metric decides that a design is better is a question
65
+ about what the points are for, and the reasoning above — rank on
66
+ discrepancies, never on a point metric ESS itself optimises — is this
67
+ project's to make and lives here.
68
+
69
+ Keep that line. It was drawn after the alternative failed: with a metric
70
+ defined in one project and chosen in another, a rename in one silently
71
+ outlived the other. Two benchmark scripts kept asking for a removed key and
72
+ died in their reporting *after completing every run*, and a third printed a
73
+ lower-is-better discrepancy under a higher-is-better heading for weeks —
74
+ reporting a 10x improvement as a 10x regression without ever failing.
75
+ `test/test_examples.py` runs every example end to end for that reason;
76
+ importing them is not enough to catch a bad key in a report function.
51
77
  """
52
78
 
53
79
  import importlib.metadata
@@ -71,29 +97,20 @@ except importlib.metadata.PackageNotFoundError: # pragma: no cover
71
97
  # 3. Neighbour-search engine (re-exported for custom configuration)
72
98
  from torann import ToroidalNN
73
99
 
74
- from . import attraction, baseline, legacy, samplers, utils
100
+ from . import attraction, baseline, geometry, legacy, samplers, utils
75
101
 
76
102
  # 2. Main API Exports
77
- from .attraction import (
78
- AttractionModel,
79
- Auto,
80
- Detrended,
81
- HarmonicProjection,
82
- HarmonicRidge,
83
- InverseDistance,
84
- )
103
+ from .attraction import AttractionModel, InverseDistance
85
104
  from .ess import esa, ess
105
+ from .geometry import NEIGHBOUR_TARGET, l1_radius_for_count, radius_for_target
86
106
 
87
107
  # 4. Sampler Exports
88
108
  from .samplers import LHCSampler, Sampler, UniformSampler, check_sampler
89
109
 
90
110
  # Define __all__ to control what 'from ess import *' exports
91
111
  __all__ = [
112
+ "NEIGHBOUR_TARGET",
92
113
  "AttractionModel",
93
- "Auto",
94
- "Detrended",
95
- "HarmonicProjection",
96
- "HarmonicRidge",
97
114
  "InverseDistance",
98
115
  "LHCSampler",
99
116
  "Sampler",
@@ -104,7 +121,10 @@ __all__ = [
104
121
  "check_sampler",
105
122
  "esa",
106
123
  "ess",
124
+ "geometry",
125
+ "l1_radius_for_count",
107
126
  "legacy",
127
+ "radius_for_target",
108
128
  "samplers",
109
129
  "utils",
110
130
  ]