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
Install from PyPI (Recommended for Use in Your Code)
Install the package directly from PyPI to use it in your own projects:
pip install parallel-hill-climber
Fork or Clone for Development
To explore the examples, modify the code, or contribute:
Option 1: GitHub Codespaces (No local setup required)
- Fork this repository
- Open in GitHub Codespaces
- The development environment will be configured automatically
Option 2: Local Development
- Clone or fork the repository:
git clone https://github.com/gperdrizet/hill_climber.git cd hill_climber
- Install in editable mode with development dependencies:
pip install -e .
Requirements
- Python 3.10+
- 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:
- Simulated Annealing: Introduction to the algorithm
- Pearson & Spearman: Optimizing for different correlation measures
- Mean & Std: Creating distributions with matching statistics but diverse structures
- Entropy & Correlation: Low correlation with internal structure
- Feature Interactions: Machine learning feature engineering demonstrations
- 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
This project is licensed under the GNU General Public License v3.0 (GPL-3.0). See the LICENSE file for full details.
In summary, you are free to use, modify, and distribute this software, but any derivative works must also be released under the GPL-3.0 license.
Contributing
Contributions welcome! Please ensure all tests pass before submitting pull requests.
Citation
If you use this package in your research, please use the "Cite this repository" button at the top of the GitHub repository page to get properly formatted citations in APA, BibTeX, or other formats.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file parallel_hill_climber-0.1.10.tar.gz.
File metadata
- Download URL: parallel_hill_climber-0.1.10.tar.gz
- Upload date:
- Size: 29.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1601d840e10b6fe6be86cb26cae0594d8dfd48d51a6f2a136b1154eb507d8ce6
|
|
| MD5 |
751979b3eaf029908d1f94e853a46fb4
|
|
| BLAKE2b-256 |
d3f26dda15ac6958a944b730656e54fba49b3c15861be09b96939087a5d017c6
|
Provenance
The following attestation bundles were made for parallel_hill_climber-0.1.10.tar.gz:
Publisher:
publish-to-pypi.yml on gperdrizet/hill_climber
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
parallel_hill_climber-0.1.10.tar.gz -
Subject digest:
1601d840e10b6fe6be86cb26cae0594d8dfd48d51a6f2a136b1154eb507d8ce6 - Sigstore transparency entry: 701759885
- Sigstore integration time:
-
Permalink:
gperdrizet/hill_climber@0553a3115f6a27faa072d5f60aff440f4b02ff4d -
Branch / Tag:
refs/tags/v0.1.10 - Owner: https://github.com/gperdrizet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@0553a3115f6a27faa072d5f60aff440f4b02ff4d -
Trigger Event:
release
-
Statement type:
File details
Details for the file parallel_hill_climber-0.1.10-py3-none-any.whl.
File metadata
- Download URL: parallel_hill_climber-0.1.10-py3-none-any.whl
- Upload date:
- Size: 28.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c34ffa4aa42dbc9822f8600b246c1fe918a33544f9c93835c5f2361d9d94c579
|
|
| MD5 |
5cbcd098893069290ec262c1d2a8326d
|
|
| BLAKE2b-256 |
4efa2a5e1387413c417336270bda17545933af7872eaeeca717b6dd2fea135e4
|
Provenance
The following attestation bundles were made for parallel_hill_climber-0.1.10-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on gperdrizet/hill_climber
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
parallel_hill_climber-0.1.10-py3-none-any.whl -
Subject digest:
c34ffa4aa42dbc9822f8600b246c1fe918a33544f9c93835c5f2361d9d94c579 - Sigstore transparency entry: 701759889
- Sigstore integration time:
-
Permalink:
gperdrizet/hill_climber@0553a3115f6a27faa072d5f60aff440f4b02ff4d -
Branch / Tag:
refs/tags/v0.1.10 - Owner: https://github.com/gperdrizet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@0553a3115f6a27faa072d5f60aff440f4b02ff4d -
Trigger Event:
release
-
Statement type: