Code Recipes
Algorithm starter kit for HACKB submissions
Browse curated Python recipes for black-box optimization. Copy the code and dependencies as a starting point for your own submissions.
Bayesian Optimization (scikit-optimize, GP-EI)
Gaussian-process Bayesian optimization via scikit-optimize's gp_minimize with Expected Improvement as the acquisition function. Good for: continuous-heavy spaces with expensive evaluations and budgets in the tens. Dependencies: scikit-optimize, scikit-learn, numpy. Falls back to random search if skopt is unavailable in the runtime image.
Random Search
The simplest optimization baseline. Samples candidates uniformly at random from the search space and tracks the best evaluation seen so far. Good for: small budgets, unknown structure, or as a baseline for comparing other methods. Dependencies: Python standard library only.
Bayesian Optimization (Optuna TPE)
General-purpose Bayesian optimization using Optuna's default TPESampler. Algorithm: Tree-structured Parzen Estimator. Good for: mixed-type search spaces with continuous, integer, categorical, and binary variables. Dependencies: optuna. A safe default — try this first when the search space is mixed.
Evolutionary (Optuna NSGA-II)
Genetic-algorithm implementation using Optuna's NSGAIISampler. Algorithm: NSGA-II (Non-dominated Sorting Genetic Algorithm II). Good for: mixed-type spaces and rugged landscapes where continuous optimizers struggle. Dependencies: optuna.
Bayesian Optimization (Optuna GP)
Built-in [GPSampler] from Optuna — a Gaussian-process Bayesian optimizer. Highlights: a BoTorch-free GP baseline that stays inside the Optuna ecosystem. Good for: continuous-heavy spaces with expensive evaluations. Dependencies: optuna, scipy, torch. A drop-in alternative to scikit-optimize.
Evolutionary (Optuna CMA-ES)
Optuna's [CmaEsSampler], backed by the cmaes package. Algorithm: CMA-ES (Covariance Matrix Adaptation Evolution Strategy). Warmup: the first 20% of the budget is spent on random startup trials before switching to CMA-ES. Good for: medium-to-high-dimensional continuous-heavy problems. Dependencies: optuna, cmaes.
Grid Search
Classic grid search baseline. Continuous variables: discretized at a resolution derived from the budget. Integer / categorical variables: enumerated as-is. Good for: low-dimensional or categorical-heavy spaces, trial purposes. Dependencies: Python standard library only.
FMQA (Fixstars Amplify)
Factorization Machine + quantum-inspired annealing baseline using Fixstars amplify-bbopt — an FMQA implementation. Algorithm: fits an FM surrogate on observed (x, y) pairs each iteration and proposes the next candidate via the Fixstars Amplify cloud annealer. Good for: binary / categorical / mixed-integer combinatorial spaces (QUBO-like structure). Dependencies: amplify, amplify-bbopt.