HumpDay

Derivative-free optimization algorithms in Python and JavaScript with no dependencies

HumpDay provides a tiny pure implementation of 22 derivative-free optimization algorithms in Python (and also JavaScript), with no external dependencies. All algorithms operate on the unit hypercube [0,1]ⁿ with automatic domain transformations for bounded and unbounded problems. Each algorithm is cross-validated against an established reference implementation.
When you call minimize() without a method=, HumpDay times one call to your objective and picks the algorithm whose per-iteration overhead is small relative to that cost — so cheap functions get lightweight algorithms and expensive ones get sample-efficient ones. See Recommendations for the dimensional caps and overhead tiers that drive the choice.
Differential Evolution clears the rack in one break. Try it · 13+ more demos →
Run Algorithm Contest Python Source Browse Applications JavaScript Source

Save the Planet

Cut and paste to avoid waste.

Read https://raw.githubusercontent.com/microprediction/humpday/main/SKILL.md
and create a project skill from it.

SKILL.md

Python Usage

Install via pip with minimal dependencies:

pip install humpday

You don't need to pick an algorithm. Call minimize with just the objective and bounds — HumpDay times one call to your objective and consults a benchmarks-driven recommendation grid to pick the algorithm whose dimensional cap, overhead tier, and Borda mean-rank on a 12-objective suite match your problem:

from humpday import minimize

def objective(x):
    return (x[0] - 2)**2 + (x[1] - 3)**2

result = minimize(objective, bounds=[(-5, 5), (-5, 5)])
print(result.x)                  # [2.0, 3.0]
print(result.method)             # which algorithm was picked
print(result.eval_time_measured) # cost of one objective call, in seconds
print(result.tier)               # overhead tier (0 trivial → 4 GP-fit-heavy)

If you do want a specific algorithm, pass method=:

result = minimize(objective, bounds=[(-5, 5), (-5, 5)], method='DifferentialEvolution')
Available Algorithm Methods
'PRIMA_UOBYQA', 'PRIMA_NEWUOA', 'PRIMA_BOBYQA', 'NelderMead', 'Powell', 'LBFGSB', 'DifferentialEvolution', 'ParticleSwarm', 'CMAEvolutionStrategy', 'EvolutionStrategy', 'GeneticAlgorithm', 'BayesianOpt', 'RandomSearch', 'GridSearch', 'Rechenberg', 'HillClimbing', 'CoordinateDescent', 'PatternSearch', 'SimulatedAnnealing', 'HarmonySearch', 'FireflyAlgorithm', 'AntColonyOpt'

Interactive Demonstrations

The following tools provide empirical evaluation and visualization of algorithm performance:

Algorithm Contest

Comparative evaluation of optimizers on user-defined problems with statistical analysis.

Run Contest →

3D Visualization

Real-time visualization of optimization trajectories on three-dimensional objective surfaces.

View Visualization →

Individual Algorithm Documentation

Detailed documentation and interactive demos for each algorithm:

Algorithm Type Python Implementation JavaScript Implementation Reference Paper Documentation
PRIMA_UOBYQA Trust Region prima_algorithms.py#L16 prima-algorithms.js#L72 Powell (2002) View →
PRIMA_NEWUOA Trust Region prima_algorithms.py#L84 prima-algorithms.js#L320 Powell (2006) View →
PRIMA_BOBYQA Trust Region prima_algorithms.py#L148 prima-algorithms.js#L580 Powell (2009) View →
NelderMead Direct Search scipy_algorithms.py#L17 scipy-algorithms.js#L18 Nelder & Mead (1965) View →
Powell Direct Search scipy_algorithms.py#L83 scipy-algorithms.js#L145 Powell (1964) View →
LBFGSB Quasi-Newton scipy_algorithms.py#L149 scipy-algorithms.js#L209 Byrd et al. (1995) View →
DifferentialEvolution Evolutionary evolutionary_algorithms.py#L15 evolutionary-algorithms.js#L16 Storn & Price (1997) View →
ParticleSwarm Swarm Intelligence evolutionary_algorithms.py#L79 evolutionary-algorithms.js#L80 Kennedy & Eberhart (1995) View →
SimulatedAnnealing Metaheuristic evolutionary_algorithms.py#L143 evolutionary-algorithms.js#L144 Kirkpatrick et al. (1983) View →
GeneticAlgorithm Evolutionary evolutionary_algorithms.py#L207 evolutionary-algorithms.js#L208 Holland (1992) View →
RandomSearch Sampling evolutionary_algorithms.py#L271 evolutionary-algorithms.js#L272 Bergstra & Bengio (2012) View →
BayesianOpt Bayesian evolutionary_algorithms.py#L278 evolutionary-algorithms.js#L296 Brochu et al. (2010) View →
CMAEvolutionStrategy Evolutionary evolutionary_algorithms.py#L479 evolutionary-algorithms.js#L408 Hansen (2016) View →
FireflyAlgorithm Bio-inspired evolutionary_algorithms.py#L679 evolutionary-algorithms.js#L525 Yang (2008) View →
AntColonyOpt Swarm Intelligence evolutionary_algorithms.py#L724 evolutionary-algorithms.js#L582 Dorigo et al. (1996) View →
HarmonySearch Metaheuristic alloptimizers.py#L38 evolutionary-algorithms.js#L654 Geem et al. (2001) View →
EvolutionStrategy Evolutionary evolutionary_algorithms.py#L829 evolutionary-algorithms.js#L719 Beyer & Schwefel (2002) View →
Rechenberg (1+1)-Evolution Strategy search_algorithms.py#L14 search-algorithms.js#L21 Rechenberg (1973), Evolutionsstrategie View →
CoordinateDescent Local Search search_algorithms.py#L57 search-algorithms.js#L69 Wright (2015) View →
PatternSearch Direct Search search_algorithms.py#L109 search-algorithms.js#L129 Torczon (1997) View →
HillClimbing Local Search alloptimizers.py#L37 search-algorithms.js#L200 Russell & Norvig (1995) View →

Algorithm Categories

Trust Region Methods

Model-based algorithms using quadratic approximations:

Classic Numerical Methods

Workhorse non-derivative-free methods, ported to pure Python:

Evolutionary & Swarm

Population-based stochastic methods:

Metaheuristics

Acceptance-rule and memory-based search:

Local & Pattern Search

Lightweight baselines and direct-search workhorses: