| Genetic Algorithm and Direct Search Toolbox™ | ![]() |
x = patternsearch(@fun,x0)
x = patternsearch(@fun,x0,A,b)
x = patternsearch(@fun,x0,A,b,Aeq,beq)
x = patternsearch(@fun,x0,A,b,Aeq,beq,LB,UB)
x = patternsearch(@fun,x0,A,b,Aeq,beq,LB,UB,nonlcon)
x = patternsearch(@fun,x0,A,b,Aeq,beq,LB,UB,nonlcon,options)
x = patternsearch(problem)
[x,fval] = patternsearch(@fun,x0, ...)
[x,fval,exitflag] = patternsearch(@fun,x0, ...)
[x,fval,exitflag,output] = patternsearch(@fun,x0,
...)
patternsearch finds the minimum of a function using a pattern search.
x = patternsearch(@fun,x0) finds the local minimum, x, to the MATLAB® function, fun, that computes the values of the objective function f(x), and x0 is an initial point for the pattern search algorithm. The function patternsearch accepts the objective function as a function handle of the form @fun. The function fun accepts a vector input and returns a scalar function value.
Note To write a function with additional parameters to the independent variables that can be called by patternsearch, see the section on Passing Extra Parameters in the Optimization Toolbox™ User's Guide. |
x = patternsearch(@fun,x0,A,b) finds a
local minimum x to the function fun, subject to the linear inequality constraints represented in matrix
form by
.
If the problem has m linear inequality constraints and n variables, then
A is a matrix of size m-by-n.
b is a vector of length m.
x = patternsearch(@fun,x0,A,b,Aeq,beq) finds a local minimum x to the function fun, starting at x0, and subject to the constraints
|
|
|
|
where
represents the
linear equality constraints in matrix form. If the problem has r linear equality constraints and n variables,
then
Aeq is a matrix of size r-by-n.
beq is a vector of length r.
If there are no inequality constraints, pass empty matrices, [], for A and b.
x = patternsearch(@fun,x0,A,b,Aeq,beq,LB,UB) defines a set of lower and upper bounds on the design variables, x, so that a solution is found in the range
. If the problem has n variables, LB and UB are vectors of length n. If LB or UB is empty (or not provided),
it is automatically expanded to -Inf or Inf, respectively. If there are no inequality or equality
constraints, pass empty matrices for A, b, Aeq and beq.
x = patternsearch(@fun,x0,A,b,Aeq,beq,LB,UB,nonlcon) subjects the minimization to the constraints defined in nonlcon, a nonlinear constraint function. The function nonlcon accepts x and returns the vectors C and Ceq, representing the nonlinear inequalities and equalities respectively. fmincon minimizes fun such that C(x) ≤ 0 and Ceq(x) = 0. (Set LB = [] and UB = [] if no bounds exist.)
x = patternsearch(@fun,x0,A,b,Aeq,beq,LB,UB,nonlcon,options) minimizes fun with the default optimization parameters replaced by values in options. The structure options can be created using psoptimset.
x = patternsearch(problem) finds the minimum for problem, where problem is a structure containing the following fields:
objective — Objective function
X0 — Starting point
Aineq — Matrix for linear inequality constraints
bineq — Vector for linear inequality constraints
Aeq — Matrix for linear equality constraints
beq — Vector for linear equality constraints
lb — Lower bound for x
ub — Upper bound for x
nonlcon — Nonlinear constraint function
Solver — 'patternsearch'
options — Options structure created with psoptimset
randstate — Optional field to reset the state of rand
randnstate — Optional field to reset the state of randn
Create the structure problem by exporting a problem from the Optimization Tool, as described in Importing and Exporting Your Work in the Optimization Toolbox User's Guide.
Note problem must have all the fields as specified above. |
[x,fval] = patternsearch(@fun,x0, ...) returns the value of the objective function fun at the solution x.
[x,fval,exitflag] = patternsearch(@fun,x0, ...) returns exitflag, which describes the exit condition of patternsearch. Possible values of exitflag and the corresponding conditions are
1 | Magnitude of mesh size is less than specified tolerance and constraint violation less than options.TolCon. |
2 | Change in x less than the specified tolerance and constraint violation less than options.TolCon. |
4 | Magnitude of step smaller than machine precision and constraint violation less than options.TolCon. |
0 | Maximum number of function evaluations or iterations reached. |
-1 | Optimization terminated by the output or plot function. |
-2 | No feasible point found. |
[x,fval,exitflag,output] = patternsearch(@fun,x0, ...) returns a structure output containing information about the search. The output structure contains the following fields:
function — Objective function
problemtype — Type of problem: unconstrained, bound constrained or linear constrained
pollmethod — Polling technique
searchmethod — Search technique used, if any
iteration — Total number of iterations
funccount — Total number of function evaluations
meshsize — Mesh size at x
maxconstraint — Maximum constraint violation, if any
message — Reason why the algorithm terminated
Note patternsearch does not accepts functions whose inputs are of type complex. To solve problems involving complex data, write your functions so that they accept real vectors, by separating the real and imaginary parts. |
Given the following constraints

the following code finds the minimum of the function, lincontest6, that is provided with your software:
A = [1 1; -1 2; 2 1];
b = [2; 2; 3];
lb = zeros(2,1);
[x,fval,exitflag] = patternsearch(@lincontest6,[0 0],...
A,b,[],[],lb)
Optimization terminated: mesh size less than
options.TolMesh.
x =
0.6667 1.3333
fval =
-8.2222
exitflag =
1
[1] Torczon, Virginia, "On the Convergence of Pattern Search Algorithms",SIAM Journal on Optimization, Volume 7, Number 1, pages 1–25, 1997.
[2] Lewis, Robert Michael and Virginia Torczon, "Pattern Search Algorithms for Bound Constrained Minimization", SIAM Journal on Optimization, Volume 9, Number 4, pages 1082–1099, 1999.
[3] Lewis, Robert Michael and Virginia Torczon, "Pattern Search Methods for Linearly Constrained Minimization", SIAM Journal on Optimization, Volume 10, Number 3, pages 917–941, 2000.
[4] Audet, Charles and J. E. Dennis Jr., "Analysis of Generalized Pattern Searches", SIAM Journal on Optimization, Volume 13, Number 3, pages 889–903, 2003.
[5] Lewis, Robert Michael and Virginia Torczon, "A Globally Convergent Augmented Lagrangian Pattern Search Algorithm for Optimization with General Constraints and Simple Bounds", SIAM Journal on Optimization, Volume 12, Number 4, pages 1075–1089, 2002.
[6] A. R. Conn, N. I. M. Gould, and Ph. L. Toint. "A Globally Convergent Augmented Lagrangian Pattern Search Algorithm for Optimization with General Constraints and Simple Bounds", SIAM Journal on Numerical Analysis, Volume 28, Number 2, pages 545–572, 1991.
[7] A. R. Conn, N. I. M. Gould, and Ph. L. Toint. "A Globally Convergent Augmented Lagrangian Pattern Search Algorithm for Optimization with General Constraints and Simple Bounds", Mathematics of Computation, Volume 66, Number 217, pages 261–288, 1997.
optimtool, psoptimget, psoptimset, ga, simulannealbnd, threshacceptbnd
![]() | gaoptimset | psoptimget | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |