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.
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.
Poll methods — You can use any poll method
as a search 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.
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.
ga
— ga
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.
There are two main reasons to use a search method:
To speed an optimization (see Search Methods for Increased Speed)
To obtain a better local solution, or to obtain a global solution (see Search Methods for Better Solutions)
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.
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.