The MaxSA package provides an implementation in Ox of the Simulated Annealing algorithm for optimizing non-smooth functions with possible multiple local maxima.

The implementation follows exactly the implementation of Goffe, William L., Gary D. Ferrier, and John Rogers, who provide programs in Fortran and Gauss. Note that an earlier translation of the code to Ox was made by Michael Creel.

The following abstract and description are copied straight from the original Fortran code, adapting only Goffe's e-mail address:


Simulated annealing is a global optimization method that distinguishes between different local optima. Starting from an initial point, the algorithm takes a step and the function is evaluated. When minimizing a function, any downhill step is accepted and the process repeats from this new point. An uphill step may be accepted. Thus, it can escape from local optima. This uphill decision is made by the Metropolis criteria. As the optimization process proceeds, the length of the steps decline and the algorithm closes in on the global optimum. Since the algorithm makes very few assumptions regarding the function to be optimized, it is quite robust with respect to non-quadratic surfaces. The degree of robustness can be adjusted by the user. In fact, simulated annealing can be used as a local optimizer for difficult functions.

This implementation of simulated annealing was used in "Global Optimization of Statistical Functions with Simulated Annealing," Goffe, Ferrier and Rogers, Journal of Econometrics, vol. 60, no. 1/2, Jan./Feb. 1994, pp. 65-100. Briefly, we found it competitive, if not superior, to multiple restarts of conventional optimization routines for difficult optimization problems.

For more information on this routine, contact its author: Bill Goffe,

For information on the Ox-version of the software, you can contact


Goffe, William L., Gary D. Ferrier, and John Rogers (1994). Global Optimization of Statistical Functions with Simulated Annealing. Journal of Econometrics, 60(1/2):65-99.

Fortran code available as

Installation instructions

To install the package,

Change log, loose ends

Updated manual for Ox7
30/3/2010 (new version of
Thanks to Pawel Janus, got rid of an error when using constrained optimization. In the original version the bounds were not fully taken into account.
Changed manner of inclusion. From now on, the package should be imported using #import <packages/maxsa/maxsa> instead of included as before.
Adapted installation instructions to refer to OX4PATH.
Added option to indicate lower and upper bounds on the parameters in the call to MaxSA.
Implemented an extra warning for low initial temperature, improved the documentation on this point, and changed output to indicate that indeed we are maximizing instead of minimizing. Thanks to M.Creel for pointing this all out to me.
Publication of package on web