A Python package for hill climbing optimization with replica exchange and 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 multi-column datasets.
1. Documentation
2. Features
- Replica exchange (parallel tempering): Multiple replicas at different temperatures exchange configurations for improved global optimization (
multiprocessing.Pool) - Real-time monitoring dashboard: Live progress plots and run info. with SQLite backend
- Simulated annealing: Temperature-based acceptance of suboptimal solutions to escape local minima
- Flexible objectives: Support for user supplied objective functions with custom multiple metrics
- Checkpoint/resume: Save and resume long-running optimizations with configurable checkpoint intervals
- JIT compilation: Numba-optimized core functions for performance
3. Quick start
3.1. Installation
Install the package directly from PyPI to use it in your own projects:
pip install parallel-hill-climber
For detailed usage, configuration options, and advanced features, see the full documentation.
3.2. Example climb
Simple hill climb to maximize the Pearson correlation coefficient between two random uniform features:
import numpy as np
import pandas as pd
from hill_climber import HillClimber
# 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 with replica exchange
climber = HillClimber(
data=data,
objective_func=my_objective,
max_time=1,
mode='maximize',
n_replicas=4
)
# Run optimization
best_data = climber.climb()
Best data contains the winning solution from all replicates at the end of the run. Individual replicate results can be accessed with the climber object's .get_replicas() method after the run is complete.
3.3. Real-time monitoring dashboard
You can monitor real-time optimization with the built-in Streamlit dashboard. To use the dashboard, install hill climber with the dashboard extras and then launch the dashboard.
pip install parallel-hill-climber[dashboard]
hill-climber-dashboard
Then open the provided url in a web browser. Note: the dashboard is only avalible on the same machine (or same LAN) running hill climber.
The dashboard provides:
- Replica leaderboard showing current best from each replica
- Three views of optimization progress:
- All Perturbations: Sampled overview (every db_step_interval)
- Accepted Steps: Complete SA exploration path
- Improvements: Monotonic progress toward best solution
- Acceptance rate tracking
- Interactive time series plots for all metrics
- Temperature exchange visualization
- Run metadata including hyperparameters and configuration
4. Development environment setup
To explore the examples, modify the code, or contribute:
4.1. Setup option 1: GitHub Codespaces (No local setup required)
- Fork this repository
- Open in GitHub Codespaces
- The development environment will be configured automatically
- Documentation will be built and served at http://localhost:8000 automatically
- The monitoring dashboard will start and be served at http://localhost:8501 automatically
4.2. Setup option 2: Local development
-
Clone or fork the repository:
git clone https://github.com/gperdrizet/hill_climber.git cd hill_climber
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
4.3. Building documentation
You can build and view a local copy of the documentation as follows:
cd docs
make html
# View docs by opening docs/build/html/index.html in a browser
# Or serve locally with: python -m http.server 8000 --directory build/html
4.4. Running tests
To run the test suite:
# Run all tests
python tests/run_tests.py
# Or with pytest if installed
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
5. Contributing
Contributions welcome! Please ensure all tests pass before submitting pull requests.
6. 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.
7. 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-3.0.0.tar.gz.
File metadata
- Download URL: parallel_hill_climber-3.0.0.tar.gz
- Upload date:
- Size: 56.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05c84962a7ded7a5e85c893e7066862917f06d34555044b74f1fa5cce7cdaa8b
|
|
| MD5 |
9bfe5cbba2ebf76776f0f2b56dc60f7c
|
|
| BLAKE2b-256 |
e6de6b622d125428b2739fcda91cbc5f89e0af0b507d0d9a6d0a683b83fb3c53
|
Provenance
The following attestation bundles were made for parallel_hill_climber-3.0.0.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-3.0.0.tar.gz -
Subject digest:
05c84962a7ded7a5e85c893e7066862917f06d34555044b74f1fa5cce7cdaa8b - Sigstore transparency entry: 766832719
- Sigstore integration time:
-
Permalink:
gperdrizet/hill_climber@3b3cf4cc63658abbad32169dc5e9b24e59ad58f8 -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/gperdrizet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@3b3cf4cc63658abbad32169dc5e9b24e59ad58f8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file parallel_hill_climber-3.0.0-py3-none-any.whl.
File metadata
- Download URL: parallel_hill_climber-3.0.0-py3-none-any.whl
- Upload date:
- Size: 59.7 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 |
5d667af65a3bedcb32c3bb9b44641fde9b8f00fcc16aa2d84e1ecfdaa0d996bf
|
|
| MD5 |
4b477d529ec568b7a391db43bc6f1153
|
|
| BLAKE2b-256 |
ebc76298bd21f2b92ef254bc94e09189a67dd688273b8aaf60d8dbe210c82147
|
Provenance
The following attestation bundles were made for parallel_hill_climber-3.0.0-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-3.0.0-py3-none-any.whl -
Subject digest:
5d667af65a3bedcb32c3bb9b44641fde9b8f00fcc16aa2d84e1ecfdaa0d996bf - Sigstore transparency entry: 766832727
- Sigstore integration time:
-
Permalink:
gperdrizet/hill_climber@3b3cf4cc63658abbad32169dc5e9b24e59ad58f8 -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/gperdrizet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@3b3cf4cc63658abbad32169dc5e9b24e59ad58f8 -
Trigger Event:
release
-
Statement type: