Skip to main content

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gloss_opt-1.0.1.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gloss_opt-1.0.1-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file gloss_opt-1.0.1.tar.gz.

File metadata

  • Download URL: gloss_opt-1.0.1.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for gloss_opt-1.0.1.tar.gz
Algorithm Hash digest
SHA256 67db7ab1a5d83dffee979f20c06d0ca36655dd57ced44340a3e3afb8256a9541
MD5 fe484bdc7167a06c0d16fba5bff73e24
BLAKE2b-256 9894fe417562d859ae8c0e4967914d8434f53d266dc589610efda27038b50c01

See more details on using hashes here.

File details

Details for the file gloss_opt-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: gloss_opt-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for gloss_opt-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 be2127cb772004f33cc90e78898b0af2c094590d87de9a11c6cc6d1e728ab52b
MD5 6eab2668a09d0eed086654fbadf0d445
BLAKE2b-256 8ebee1a46d8c5c574501316920bcdc42f4ee1b2c6ecaaee187694994610d7a3d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page