The Compass Search Optimization Algorithm

COMPASS_SEARCH is a Python library which seeks the minimizer of a scalar function of several variables using compass search, a direct search algorithm that does not use derivatives.

The algorithm, which goes back to Fermi and Metropolis, is easy to describe. The algorithm begins with a starting point X, and a step size DELTA.

For each dimension I, the algorithm considers perturbing X(I) by adding or subtracting DELTA.

If a perturbation is found which decreases the function, this becomes the new X. Otherwise DELTA is halved.

The iteration halts when DELTA reaches a minimal value.

The algorithm is not guaranteed to find a global minimum. It can, for instance, easily be attracted to a local minimum. Moreover, the algorithm can diverge if, for instance, the function decreases as the argument goes to infinity.


[ x, fx, k ] = compass_search ( f, m, x, delta_tol, delta, k_max )


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


COMPASS_SEARCH is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Data and Programs:

ASA047, a Python library which minimizes a scalar function of several variables using the Nelder-Mead algorithm.

TOMS178, a Python library which optimizes a scalar functional of multiple variables using the Hooke-Jeeves method, by Arthur Kaupe. This is a version of ACM TOMS algorithm 178.


John Burkardt


  1. Tamara Kolda, Robert Michael Lewis, Virginia Torczon,
    Optimization by Direct Search: New Perspectives on Some Classical and Modern Methods,
    SIAM Review,
    Volume 45, Number 3, 2003, pages 385-482.

Source Code:

Examples and Tests:

You can go up one level to the Python source codes.

Last revised on 23 January 2016.