GLOSS: Global-LOcal-unexplored Sampling Strategy
GLOSS is a batch recommendation algorithm for surrogate-based optimization in large, sparsely sampled chemical spaces. It lessens over-reliance on the surrogate model by dividing each recommended batch across three complementary strategies:
- Global: upper-confidence-bound (UCB) acquisition over the whole space, with a diversity radius that keeps the batch from collapsing onto a single predicted optimum.
- Local: harvests the surrogate's multiple local optima directly through a BallTree spatial index.
- Unexplored: distance-gated sampling of regions far from all observed points, where surrogate predictions are unreliable and greedy search stalls.
This repository contains the reference implementation, the test suite, and the complete benchmark used in the accompanying paper.
Installation
From PyPI (library only):
pip install gloss-opt
From source (library plus benchmarks and data):
git clone https://github.com/zbc0315/gloss-opt.git
cd gloss-opt
pip install -e .
Requires Python >= 3.9. Core dependencies: numpy, scipy, scikit-learn. Optional surrogate backends (torch, xgboost, lightgbm) and benchmark extras (pandas, matplotlib, rdkit, openpyxl) install with:
pip install -e ".[full]"
Quickstart
import numpy as np
from gloss import GLOSS
# Discrete candidate pool: 10,000 points in 5 dimensions
rng = np.random.default_rng(0)
candidates = rng.uniform(0.0, 1.0, size=(10_000, 5))
opt = GLOSS(
space={"candidates": candidates},
mode="discrete",
direction="maximize",
ucb_kappa=2.0,
diversity_radius=0.02,
seed=0,
)
# Initial observations
X_obs = candidates[:8]
y_obs = np.sin(X_obs).sum(axis=1)
# One recommendation round: 4 global + 2 local + 2 unexplored points
batch = opt.recommend(
X_train=X_obs,
y_train=y_obs,
strategy_points={"global_best": 4, "local_best": 2, "unexplored": 2, "unconverged": 0},
)
points = np.array([r["point"] for r in batch]) # (8, 5) points to evaluate next
recommend() fits a surrogate on the observations (or accepts a pre-fitted
one via surrogate=) and runs the three strategies in sequence with
deduplication. It returns a list of dicts, one per recommended point, each
carrying the point itself, its predicted_value, and the strategy that
proposed it. Continuous spaces are supported via mode="continuous" and
space={"bounds": [(lo, hi), ...]}.
Reproducing the paper benchmarks
The benchmark compares GLOSS against four baselines (BO-EI, BO-UCB, GA, and random sampling) on three chemical datasets, with all algorithms sharing one Random Forest surrogate and identical bottom-20% initializations.
# Quick validation (1 seed, 10 rounds)
python -m benchmarks.bench_main --study pilot
# Individual studies
python -m benchmarks.bench_main --study main # 3 datasets x 5 algorithms
python -m benchmarks.bench_main --study scaling # QM9 pool 5k -> 100k
python -m benchmarks.bench_main --study complexity # Arrhenius C1 -> C5
python -m benchmarks.bench_main --study ratio_scaling
python -m benchmarks.bench_main --study ratio_complexity
# Everything (5 seeds; several hours on a single machine)
python -m benchmarks.bench_main --study all
# Local top-K ablation (Supporting Information S2)
python -m benchmarks.bench_local_topk
# Regenerate all paper figures from the result CSVs
python -m benchmarks.plot_benchmark
Result CSVs land in benchmarks/results/ and figures in benchmarks/plots/.
The CSVs backing the published figures are included in this repository, so
plot_benchmark.py reproduces every figure without re-running the campaigns.
Datasets
No manual download is needed. On first use, benchmarks/datasets.py fetches
each dataset from its original public source into benchmarks/data/:
| Dataset | Source | Size |
|---|---|---|
| QM9 (HOMO-LUMO gap) | DeepChem S3 mirror of QM9 | 134k molecules |
| Buchwald-Hartwig yields | rxn_yields repository (Dreher and Doyle) | 3,955 reactions |
| Arrhenius-2D | virtual landscape, generated by benchmarks/virtual_functions.py |
analytic |
Molecular features (20 RDKit descriptors) are computed locally; the
precomputed stratified QM9 pools for the scaling study can be rebuilt with
python -m benchmarks.build_qm9_strat.
Tests
pytest tests/ -v
Citing
If you use GLOSS in your work, please cite the paper (see CITATION.cff).
License
MIT. See LICENSE.
Metadata
Release files for gloss-opt 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gloss_opt-1.0.1.tar.gz | 27.7 kB | Without provenance | Details for gloss_opt-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gloss_opt-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for gloss_opt-1.0.1-py3-none-any.whl |
Total release size: 49.7 kB
Release files / gloss_opt-1.0.1.tar.gz
| Download URL | gloss_opt-1.0.1.tar.gz |
|---|---|
| Size | 27.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67db7ab1a5d83dffee979f20c06d0ca36655dd57ced44340a3e3afb8256a9541
|
|
BLAKE2b-256 checksum How to use checksums |
9894fe417562d859ae8c0e4967914d8434f53d266dc589610efda27038b50c01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / gloss_opt-1.0.1-py3-none-any.whl
| Download URL | gloss_opt-1.0.1-py3-none-any.whl |
|---|---|
| Size | 22.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be2127cb772004f33cc90e78898b0af2c094590d87de9a11c6cc6d1e728ab52b
|
|
BLAKE2b-256 checksum How to use checksums |
8ebee1a46d8c5c574501316920bcdc42f4ee1b2c6ecaaee187694994610d7a3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for gloss-opt 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.