https://github.com/jacobwilliams/simulated-annealing
Simulated Annealing with Modern Fortran
https://github.com/jacobwilliams/simulated-annealing
annealing fortran optimization simulated-annealing stochastic-optimization
Last synced: about 1 month ago
JSON representation
Simulated Annealing with Modern Fortran
- Host: GitHub
- URL: https://github.com/jacobwilliams/simulated-annealing
- Owner: jacobwilliams
- License: other
- Created: 2019-09-02T01:44:03.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-04-20T05:48:59.000Z (about 1 year ago)
- Last Synced: 2025-06-25T23:36:25.238Z (about 1 year ago)
- Topics: annealing, fortran, optimization, simulated-annealing, stochastic-optimization
- Language: Fortran
- Homepage:
- Size: 805 KB
- Stars: 27
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README

============
A modern Fortran simulated annealing optimization method.
## Status
[](https://github.com/topics/fortran)
[](https://github.com/jacobwilliams/simulated-annealing/actions)
[](https://github.com/jacobwilliams/simulated-annealing/releases/latest)
[](https://codecov.io/gh/jacobwilliams/simulated-annealing)
## Building
A [Fortran Package Manager](https://github.com/fortran-lang/fpm) manifest file is included, so that the library and test cases can be compiled with FPM. For example:
```
fpm build --profile release
fpm test --profile release
```
To use `simulated-annealing` within your fpm project, add the following to your `fpm.toml` file:
```toml
[dependencies]
simulated-annealing = { git="https://github.com/jacobwilliams/simulated-annealing.git" }
```
To generate the documentation using [ford](https://github.com/Fortran-FOSS-Programmers/ford), run: ```ford ford.md```
## Features
The library contains an implementation of a simulated annealing optimization method. See the references for more details. The main class is `simulated_annealing_type`. It also includes the ability to submit function evaluations to parallel workers (the exact parallel implementation is up to the user to implement).
The library also exports a C interface, which can also be called from Python. A Python package is also included (see the `sa_fortran` class). To use the Python interface, first build and install the shared library using:
```
fpm install --prefix ./sa_fortran/lib --profile release
```
Then refer to the two python examples `python_example.py` and `parallel_example.py` for how to use it.
## Using with dask
An example is given (`dask_parallel_example.py`) of using the parallel interface with [Dask](https://www.dask.org).
Example to run locally with 8 workers:
```
python dask_parallel_example.py --workers 8 --dimension 2
```
## Example output

## See also
* https://www.netlib.org/opt/simann.f
## Documentation
The latest API documentation can be found [here](https://jacobwilliams.github.io/simulated-annealing/). This was generated from the source code using [FORD](https://github.com/Fortran-FOSS-Programmers/ford).
## References
* Corana et al., "[Minimizing multimodal functions of continuous variables
with the "simulated annealing" algorithm](https://dl.acm.org/doi/10.1145/29380.29864)", september 1987
(vol. 13, no. 3, pp. 262-280),
acm transactions on mathematical software.
* Goffe, Ferrier and Rogers, "[Global optimization of statistical functions
with simulated annealing](https://www.sciencedirect.com/science/article/abs/pii/0304407694900388)", journal of econometrics, vol. 60, no. 1/2,
jan./feb. 1994, pp. 65-100.
* S. Kirkpatrick, C. D. Gelatt Jr., M. P. Vecchi, "[Optimization by Simulated Annealing](https://pdfs.semanticscholar.org/e893/4a942f06ee91940ab57732953ec6a24b3f00.pdf)", Science 13 May 1983, Vol. 220, Issue 4598, pp. 671-680
* W. L. Goffe, [SIMANN: A Global Optimization Algorithm using Simulated Annealing](https://www.researchgate.net/publication/24015773_SIMANN_A_Global_Optimization_Algorithm_using_Simulated_Annealing), Studies in Nonlinear Dynamics & Econometrics, De Gruyter, vol. 1(3), pages 1-9, October 1996.