Skip to main content

A derivative-free solver for unconstrained minimization

Project description

Build Status GNU GPL v3 License Latest PyPI version

directsearch is a package for solving unconstrained minimization, without requiring derivatives of the objective. It is particularly useful when evaluations of the objective function are expensive and/or noisy.

It implements a family of direct search methods. For general references on these methods, please consult:

  1. A R Conn, K Scheinberg, and L N Vicente. Introduction to derivative-free optimization. SIAM, 2009.

  2. C Audet, and W. Hare. Derivative-Free and Blackbox Optimization. Springer, 2017.

  3. T G Kolda, R M Lewis, and V Torczon. Optimization by Direct Search: New Perspectives on Some Classical and Modern Methods. SIAM Review, 45(3), 2003, 385-482.

This package extends general direct search methods to use randomized methods for improved practical performance and scalability.

Citation

If you use this package, please cite:

  • L Roberts, and C W Royer. Direct search based on probabilistic descent in reduced spaces, SIAM J. Optim., 33(4):3057-3082, 2023.

If you use this package with linear constraints (v1.1 and later), please also cite:

  • L Roberts, and C W Royer. Poll Set Construction and Worst-Case Complexity for Direct Search under Polyhedral Convex Constraints, arXiv preprint arXiv:2605.27814, 2026.

Installation

Please install using pip:

$ pip install [--user] directsearch

To instead install from source run:

$ git clone git@github.com:lindonroberts/directsearch.git
$ cd directsearch
$ pip install -e .

The -e option to pip allows you to modify the source code and for your Python installation to recognize this.

Usage

This package can solve unconstrained nonlinear optimization problems of the form min_{x in R^n} f(x) and problems with linear inequality constraints of the form min_{x in R^n} f(x) s.t. Ax <= b (which includes bound constraints). Linear constraints were added in version 1.1. The simplest usage of directsearch is

soln = directsearch.solve(f, x0, A=None, b=None)

where

  • f is a callable objective function, taking in a numpy.ndarray the same shape as x0 and returing a single float.

  • x0 is a one-dimensional numpy.ndarray (i.e. len(x0.shape)==1), the starting point for the algorithm. It should be the best available guess of the minimizer.

  • A and b are optional numpy.ndarray objects representing the linear constraints A @ x <= b (i.e. len(A.shape)==2 and len(b.shape)==1). If x0 does not satisfy these constraints, then it will be perturbed by the solver.

The output is an object with fields:

  • soln.x: the approximate minimizer, the best x value found (a numpy.ndarray the same shape as x0).

  • soln.f: the minimum value equal to f(soln.x).

  • soln.nf: the number of evaluations of f required by the solve routine.

  • soln.flag: an integer indicating the reason for termination.

  • soln.msg: a string with a human-readable termination message.

The possible values of soln.flag are:

  • soln.EXIT_MAXFUN_REACHED: termination on maximum number of objective evaluations.

  • soln.EXIT_ALPHA_MIN_REACHED: termination on small step size (success).

You can print information about the solution using print(soln). The examples directory has several scripts showing the usage of directsearch.

Interfaces to solver instances

There are many configurable options for the solver in directsearch and several ways to call specific direct search algorithm implementations. The full set of available functions is:

  • directsearch.solve() applies a direct-search method to a given optimization problem. It is the most flexible available routine.

  • directsearch.solve_directsearch() applies regular direct-search techniques without sketching [1,2,3,7].

  • directsearch.solve_probabilistic_directsearch() applies direct search based on probabilistic descent without sketching [4].

  • directsearch.solve_subspace_directsearch() applies direct-search schemes based on polling directions in random subspaces [5].

  • directsearch.solve_stp() applies the stochastic three points method, a particular direct-search technique [6].

The randomized solvers are only available for unconstrained problems (i.e. A is None and b is None). Only solve() and solve_directsearch() are available for linearly constrained problems.

The default algorithms used by solve() are regular direct search without sketching [1,2,3] for unconstrained problems and its extension [7] for linearly constrained problems.

Optional parameters and more information

See usage.txt for full details on how to call these functions. The most commonly used optional inputs (to all functions) are:

  • maxevals: the maximum number of allowed evaluations of f during the solve.

  • verbose: a bool for whether or not to print progress information.

  • print_freq: an int indicating how frequently to print progress information (1 is at every iteration).

Choosing a solver instance (for unconstrained problems)

As a rule of thumb, if len(x0) is not too large (e.g. less than 50), then solve_directsearch() or solve_probabilistic_directsearch() are suitable choices. Of these, generally solve_probabilistic_directsearch() will solve with fewer evaluations of f, but solve_directsearch() is a deterministic algorithm. If len(x0) is larger, then directsearch.solve_subspace_directsearch() may be a better option. Note that solve_directsearch() is the only deterministic algorithm (i.e. reproducible without setting the numpy random seed).

References

  1. A R Conn, K Scheinberg, and L N Vicente. Introduction to derivative-free optimization. SIAM, 2009.

  2. C Audet, and W. Hare. Derivative-Free and Blackbox Optimization. Springer, 2017.

  3. T G Kolda, R M Lewis, and V Torczon. Optimization by Direct Search: New Perspectives on Some Classical and Modern Methods. SIAM Review, 45(3), 2003, 385-482.

  4. S Gratton, C W Royer, L N Vicente, and Z Zhang. Direct Search Based on Probabilistic Descent. SIAM J. Optimization, 25(3), 2015, 1515-1541.

  5. L Roberts, and C W Royer. Direct search based on probabilistic descent in reduced spaces, SIAM J. Optimization, 33(4), 2023, 3057-3082.

  6. E H Bergou, E Gorbunov, and P Richtarik. Stochastic Three Points Method for Unconstrained Smooth Minimization. SIAM J. Optimization, 30(4), 2020, 2726-2749.

  7. L Roberts, and C W Royer. Polling Set Construction and Worst-Case Complexity for Direct Search under Polyhedral Convex Constraints. arXiv preprint arXiv:2605.27814, 2026.

Bugs

Please report any bugs using GitHub’s issue tracker.

License

This algorithm is released under the GNU GPL license.

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

directsearch-1.1.tar.gz (48.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

directsearch-1.1-py3-none-any.whl (48.7 kB view details)

Uploaded Python 3

File details

Details for the file directsearch-1.1.tar.gz.

File metadata

  • Download URL: directsearch-1.1.tar.gz
  • Upload date:
  • Size: 48.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for directsearch-1.1.tar.gz
Algorithm Hash digest
SHA256 8d5058a3f68085a259f18e9c94c4120ea6d98af383e7347363374162164c08c9
MD5 5c7cac17c53193b2bd6dd8a8bc72cb36
BLAKE2b-256 7d73508a5a6221198a009bdd8651dd033b4e76282ccf235ac8abb550f57e2c77

See more details on using hashes here.

Provenance

The following attestation bundles were made for directsearch-1.1.tar.gz:

Publisher: upload_pypi.yml on lindonroberts/directsearch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file directsearch-1.1-py3-none-any.whl.

File metadata

  • Download URL: directsearch-1.1-py3-none-any.whl
  • Upload date:
  • Size: 48.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for directsearch-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f4a4c1537381ff087d55786864b66027cc6cd1c0d0d1e19206a87b076d2a0f95
MD5 58d338dc533f1a52567e30eb9cdac3ac
BLAKE2b-256 f3eb0e01499696b245783b98e76f1f81e96bd46b932b3626330e3c7169750954

See more details on using hashes here.

Provenance

The following attestation bundles were made for directsearch-1.1-py3-none-any.whl:

Publisher: upload_pypi.yml on lindonroberts/directsearch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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