Skip to main content

A Python package for hill climbing optimization with simulated annealing

Project description

Hill Climber

A Python package for hill climbing optimization of user-supplied objective functions with simulated annealing. Designed for flexible multi-objective optimization with support for N-dimensional data.

Documentation

View Full Documentation on GitHub Pages

Features

  • Simulated Annealing: Temperature-based acceptance of suboptimal solutions to escape local minima
  • Parallel Execution: Run multiple replicates simultaneously for diverse solutions
  • Flexible Objectives: Support for any objective function with multiple metrics
  • N-Dimensional Support: Optimize distributions with any number of dimensions
  • Checkpoint/Resume: Save and resume long-running optimizations
  • Boundary Handling: Reflection-based strategy prevents point accumulation at boundaries
  • Visualization: Built-in plotting for both input data and optimization results
  • JIT Compilation: Numba-optimized core functions for performance

Installation

pip install -r requirements.txt

Requirements

  • Python 3.8+
  • NumPy
  • Pandas
  • SciPy
  • Matplotlib
  • Numba

Quick Start

from hill_climber import HillClimber
import pandas as pd
import numpy as np

# Create sample data
data = pd.DataFrame({
    'x': np.random.rand(100),
    'y': np.random.rand(100)
})

# Define objective function
def my_objective(x, y):
    correlation = pd.Series(x).corr(pd.Series(y))
    metrics = {'correlation': correlation}

    return metrics, correlation

# Create optimizer
climber = HillClimber(
    data=data,
    objective_func=my_objective,
    max_time=1,  # minutes
    step_size=0.5,
    mode='maximize'
)

# Run optimization with multiple replicates
results = climber.climb_parallel(replicates=4, initial_noise=0.1)

# Visualize results
climber.plot_results(results, plot_type='histogram')

For detailed usage, configuration options, and advanced features, see the full documentation.

Example Notebooks

The notebooks/ directory contains complete worked examples demonstrating various use cases:

  1. Simulated Annealing: Introduction to the algorithm
  2. Pearson & Spearman: Optimizing for different correlation measures
  3. Mean & Std: Creating distributions with matching statistics but diverse structures
  4. Entropy & Correlation: Low correlation with internal structure
  5. Feature Interactions: Machine learning feature engineering demonstrations
  6. Checkpointing: Long-running optimization with save/resume

See the documentation for rendered versions of all notebooks.

Testing

# Run all tests
python -m pytest tests/

# Run specific test file
python -m pytest tests/test_hill_climber.py

# Run with coverage
python -m pytest tests/ --cov=hill_climber

License

See LICENSE file for details.

Contributing

Contributions welcome! Please ensure all tests pass before submitting pull requests.

Citation

If you use this package in your research, please cite appropriately.

Project details


Download files

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

Source Distribution

parallel_hill_climber-0.1.0.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

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

parallel_hill_climber-0.1.0-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file parallel_hill_climber-0.1.0.tar.gz.

File metadata

  • Download URL: parallel_hill_climber-0.1.0.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for parallel_hill_climber-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a70fc6bae52f76adc5681f8c7f7c8221b7c928976fb4718203ef87c13aa36de2
MD5 fcd0e149eded81495896fd9e5a6482b3
BLAKE2b-256 5928f62c115efa53361d7bd9a9bdb377fe11f4094978d26ad4ac01110ce8d9cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for parallel_hill_climber-0.1.0.tar.gz:

Publisher: publish-to-pypi.yml on gperdrizet/hill_climber

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file parallel_hill_climber-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for parallel_hill_climber-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f90defa82eb6b07a9f47455c7f7d86c3ff1b8d01d536b2b493c28c880a8ff860
MD5 7512e77ba1c98229ee558a7cf511d415
BLAKE2b-256 7c4ccf6c166c8a3c3c56d3824a2306ec1e5fa9f8406e19fabca082dccd1e17a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for parallel_hill_climber-0.1.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on gperdrizet/hill_climber

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page