Skip to main content

Late Acceptance Hill Climbing in Python

Project description

Late Acceptance Hill Climbing

Implementation of Late Acceptance Hill Climbing (LAHC) algorithm by Burke and Bykov [Burke2017] in python.

Installation

Either download the repository to your computer and install, e.g. by pip

pip install .

or install directly from the python package index.

pip install lahc

Usage

The package provides a base class for subclassing to a specific problem. The move and energy methods must be implemented by the user before the algorithm is applied.

The user controls the algorithm by adjusting a single algorithmic parameter, the history length, and the termination criteria for the algorithm. See subsection on each of the topics below.

The search is started by calling the run method.

The example is a good place to start using of the package.

Note

The implementation relies heavily on copying the state. The default copy strategy (copy_strategy='deepcopy') relies on the STL copy.deepcopy method which works for most data structures, but is typically quite slow. Large performance gains can be easily obtained by adapting a different copying strategy, see the documentation of the copy_state method.

The history length

The behaviour of the LAHC algorithm is governed by a single parameter, the history length. To alter the history length of the algorithm, adjust the history_length parameter of the class.

If the history length is set to one, the LAHC algorithm is equivalent to a greedy Hill Climbing algorithm. Increasing the history length generally improves the solution quality, but also increases the time to convergence.

Selection of the history length should therefore be based on requirements for the quality of the solution and time available for the analysis.

A useful characteristic of the LAHC heuristic is that the runtime to convergence is roughly proportional to the history length. The runtime at any history length can therefore be estimated after applying the algorithm at a few different history lengths.

As a general recommendation, start at a low history length and gradually increase it to determine the runtime and variation in the estimated results. Select a shorter history length that allows multiple runs in the time allocated for simulations rather than a longer history length with a single run.

Termination criteria

The algorithm terminates when the terminate_search method evaluates to True or when a interupt signal (Ctrl-C) is sent to the process.

The default behaviour of the terminate_search method is to terminate the algorithm when a minimum number of attempts has been made and the algorithm has not been able to improve the solution for a certain number of steps. The minimum number of steps and necessary number of idle iterations can be adjusted with the steps_minimum and steps_idle_fraction parameters, respectively.

The default value of the steps_idle_fraction (0.02) is generally a good choice for a variety of problems, but the default steps_minimum value (100000) may have to be adjusted depending on the problem. As a general recommendation, the user should reduce the steps_minimum parameter if the algorithm consistently terminates at steps_minimum after running for a long period without improving the solution.

Acknowledgements

Both the structure and parts of the source code for the LateAcceptanceHillClimber class is copied from the Annealer class in the simanneal python project. All contributions from the simanneal project is hereby gratefully acknowledged. Check out the simanneal project at

https://github.com/perrygeo/simanneal

which implements the widely used and sucessful Simulated Annealing metaheuristic.

Support

Please open an issue for support.

Contributing

Please contribute using Github Flow. Create a branch, add commits, and open a pull request.

Bibliography

[BURKE2017]

E. K. Burke, Y. Bykov, The late acceptance Hill-Climbing heuristic. European Journal of Operational Research. 258, 70–78 (2017).

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

lahc-1.0.5.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

lahc-1.0.5-py2.py3-none-any.whl (7.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file lahc-1.0.5.tar.gz.

File metadata

  • Download URL: lahc-1.0.5.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for lahc-1.0.5.tar.gz
Algorithm Hash digest
SHA256 7053246cff238492ab3415a7e1ae993854bae6694d5a96b75b8f5d2d8b34fe0d
MD5 0d096a31bf86f4b2387eadcf44b088eb
BLAKE2b-256 363577047f955dcbe7ffb2ac27e0b4f1eda2052048a73a447512e9c7752e1a4c

See more details on using hashes here.

File details

Details for the file lahc-1.0.5-py2.py3-none-any.whl.

File metadata

  • Download URL: lahc-1.0.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for lahc-1.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c2899a6863928fd255e274194af7ea96b7d94a2e303c2bb8378cff99c260576d
MD5 9beaf6c408d8da44428b80723f55b9eb
BLAKE2b-256 e723a4abfca877e0426e5f1e59e2d728614fba049473946a81cde86efb51c422

See more details on using hashes here.

Supported by

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