| Genetic Algorithm and Direct Search Toolbox | ![]() |
Performing a Pattern Search from the Command Line
As an alternative to using the Pattern Search Tool, you can call the function patternsearch at the command line. This section explains how to do so and covers the following topics:
Performing a Pattern Search with the Default Options
This section describes how to perform a pattern search with the default options.
Pattern Search on Unconstrained Problems
For an unconstrained problem, call patternsearch with the syntax
The required input arguments are
@objectfun -- A function handle to the objective function objectfun, which you can write as an M-file. See Writing an M-File for the Function You Want to Optimize to learn how to do this.
x0 -- The initial point for the pattern search algorithm
As an example, you can run the example described in Example: Finding the Minimum of a Function from the command line by entering
Optimization terminated: Current mesh size 9.5367e-007 is less than 'TolMesh'. x = -4.7124 -0.0000 fval = -2.0000
Pattern Search on Constrained Problems
If your problem has constraints, use the syntax
A is a matrix and b is vector that represent inequality constraints of the form
.
Aeq is a matrix and beq is a vector that represent equality constraints of the form
.
lb and ub are vectors representing bound constraints of the form
and
, respectively.
You only need to pass in the constraints that are part of the problem. For example, if there are no bound constraints, use the syntax
Use empty brackets [] for constraint arguments that are not needed for the problem. For example, if there are no inequality constraints, use the syntax
Additional Output Arguments
To get more information about the performance of the pattern search, you can call patternsearch with the syntax
Besides x and fval, this returns the following additional output arguments:
exitflag -- Integer indicating whether the algorithm was successful
output -- Structure containing information about the performance of the solver
See the reference page for patternsearch for more information about these arguments.
| Generate M-File | Setting Options | ![]() |
| © 1994-2009 The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |