Main Content

Searching and Polling

Definition of Search

In patternsearch, a search is an algorithm that runs before a poll. The search attempts to locate a better point than the current point. (Better means one with lower objective function value.) If the search finds a better point, the better point becomes the current point, and no polling is done at that iteration. If the search does not find a better point, patternsearch performs a poll.

By default, patternsearch does not use search. To search, see How to Use a Search Method.

The figure patternsearch With a Search Method contains a flow chart of direct search including using a search method.

patternsearch With a Search Method

Iteration limit applies to all built-in search methods except those that are poll methods. If you select an iteration limit for the search method, the search is enabled until the iteration limit is reached. Afterward, patternsearch stops searching and only polls.

How to Use a Search Method

To use search in patternsearch:

  • In the Optimize Live Editor task, select a search function in Specify solver options > Algorithm settings > Search function.

  • At the command line, create options with a search method using optimoptions. For example, to use Latin hypercube search:

    opts = optimoptions("patternsearch","SearchFcn",@searchlhs);

    For more information, including a list of all built-in search methods, consult the patternsearch function reference page, and the Search Options section of the options reference.

You can write your own search method. Use the syntax described in Structure of the Search Function. To use your search method in a pattern search, give its function handle as the Custom Function (SearchFcn) option.

Built-In Search Types

  • Poll methods — You can use any poll method as a search algorithm in the "classic" algorithm. patternsearch conducts one poll step as a search. For this type of search to be beneficial, your search type should be different from your poll type. (patternsearch does not search if the selected search method is the same as the poll type.) Therefore, use a MADS search with a GSS or GPS poll, or use a GSS or GPS search with a MADS poll.


    You can use a poll method as a search method only when the Algorithm option is "classic".

  • fminsearch, also called Nelder-Mead — fminsearch is for unconstrained problems only. fminsearch runs to its natural stopping criteria; it does not take just one step. Therefore, use fminsearch for just one iteration. This is the default setting. To change settings, see Search Options.

  • gaga runs to its natural stopping criteria; it does not take just one step. Therefore, use ga for just one iteration. This is the default setting. To change settings, see Search Options.

  • Latin hypercube search — Described in Search Options. By default, searches 15n points, where n is the number of variables, and only searches during the first iteration. To change settings, see Search Options.

  • "rbfsurrogate" — As described in Search Options, searches using a radial basis function surrogate, similar to the surrogateopt surrogate (see Surrogate Optimization Algorithm). This search can lower the number of function evaluations, but is relatively time-consuming, so is best suited for time-consuming objective functions.

When to Use Search

There are two main reasons to use a search method:

Search Methods for Increased Speed

Generally, you do not know beforehand whether a search method speeds an optimization or not. So try a search method when:

  • You are performing repeated optimizations on similar problems, or on the same problem with different parameters.

  • You can experiment with different search methods to find a lower solution time.

Search does not always speed an optimization. For one example where it does, see Search and Poll.

Search Methods for Better Solutions

Since search methods run before poll methods, using search can be equivalent to choosing a different starting point for your optimization. This comment holds for the Nelder-Mead, ga, and Latin hypercube search methods, all of which, by default, run once at the beginning of an optimization. ga and Latin hypercube searches are stochastic, and can search through several basins of attraction.

Related Topics