An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

![simulated-annealing](media/logo.png)
============

A modern Fortran simulated annealing optimization method.

## Status

[![Language](https://img.shields.io/badge/-Fortran-734f96?logo=fortran&logoColor=white)](https://github.com/topics/fortran)
[![CI Status](https://github.com/jacobwilliams/simulated-annealing/actions/workflows/CI.yml/badge.svg)](https://github.com/jacobwilliams/simulated-annealing/actions)
[![GitHub release](https://img.shields.io/github/release/jacobwilliams/simulated-annealing.svg?style=plastic)](https://github.com/jacobwilliams/simulated-annealing/releases/latest)
[![codecov](https://codecov.io/gh/jacobwilliams/simulated-annealing/branch/master/graph/badge.svg?token=43HK33CSMY)](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

![2D Optimization Visualization](media/report_2d.jpg)

## 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.