This repository contains the artifact code for high-precision asymptotic experiments on worst-case generalized birthday problem (GBP) instances. It also includes mpoptimize, a small mpmath-backed constrained optimization package used by the artifact scripts.
The repository is intended to support two reproducible workflows:
uvworkflow for building, locking, running, and testing the whole project.requirements.txtworkflow for recreating the currently verified local environment exactly.
Disclaimer: We used
Codex + GPT-5.5to develop thempoptimizepackage, sampler scripts, and plotting scripts. We manually wrote the (regular) ISD models based on Regular-ISD/asymptotics.ipynb and verified the correctness of the generated code. Comprehensive tests were added to ensure the correctness of the numeric numerical optimization (see tests and example).
src/mpoptimize/: high-precisionminimize(...)implementation with SLSQP-like and COBYLA-like methods.mp_*_isd.py,mp_*_sampler.py,*_points.py: asymptotic ISD models and JSON data generation scripts.json/: precomputed artifact data used by the plotting scripts.plot_*.py: plotting scripts for the figures infig/and comparison figures generated from the JSON data.tests/: smoke, regression, and high-precision tests formpoptimize.
- Python
>=3.10,<3.13(the repository pins SciPy1.11.4; Python 3.13+ may force a source build instead of using wheels) uvfor the preferred artifact workflow
The pinned package versions used by the current working environment are listed in requirements.txt.
Create or update the project environment:
uv sync --all-extrasRun commands inside the managed environment:
uv run pytest
uv run plot-wc-rgbp
uv run plot-wc-lgbp
uv run plot-sdp-paras
uv run plot-wc-gbp
uv run plot-optimal-wcgbpBuild the local package:
uv buildInstall the repository as an editable local package:
uv pip install -e ".[artifact,test]"After editable installation, the console commands above are available in the active environment. Run plotting commands from the repository root so the scripts can use the bundled json/ data and write figures under fig/.
For a plain virtual environment without uv:
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -e ".[test]"This installs the same direct and transitive runtime versions as the currently verified local environment:
mpmath==1.3.0matplotlib==3.8.0numpy==1.26.3scipy==1.11.4
The repository includes precomputed JSON files under json/. To regenerate a small scan manually:
# small scans for regular and loose GBP points
uv run regular-rgbp-points --algorithm enum --start 0.01 --end 0.10 --step 0.01
uv run standard-lgbp-points --algorithm enum --start 0.01 --end 0.10 --step 0.01Full scans can be expensive because each point may solve a high-precision constrained optimization problem. The plotting scripts use the latest matching JSON file by filename prefix. To regenerate the full JSON data set for every registered algorithm:
#!/usr/bin/env bash
set -euo pipefail
# Full regular-GBP scans: c = 0.01, 0.02, ..., 1.00
for alg in perm enum rep rep_mo; do
uv run regular-rgbp-points --algorithm "$alg" --start 0.01 --end 1.00 --step 0.01
done
# Full loose-GBP scans: c = 0.01, 0.02, ..., 0.50
for alg in perm enum rep rep_mo; do
uv run standard-lgbp-points --algorithm "$alg" --start 0.01 --end 0.50 --step 0.01
doneGenerate the regular and loose GBP complexity plots:
uv run plot-wc-rgbp
uv run plot-wc-lgbpGenerate the side-by-side and optimal comparison plots:
uv run plot-wc-gbp
uv run plot-optimal-wcgbpBy default these commands write fig/complexity_gbp.pdf and fig/optimal_wcgbp.pdf, respectively.
Generate the worst-case parameter plots:
uv run plot-sdp-parasRun the test suite with:
uv run pytestor, in a manually managed environment:
pytestmpoptimize is a pure Python high-precision baseline. It avoids implicit float64 downcasting in the core optimization loops, but it is not intended to be a feature-complete replacement for SciPy's optimizers.