MathWorks Machine Translation
The automated translation of this page is provided by a general purpose third party translator tool.
MathWorks does not warrant, and disclaims all liability for, the accuracy, suitability, or fitness for purpose of the translation.
Find points in Pareto set
x = paretosearch(fun,nvars)
x = paretosearch(fun,nvars,A,b)
x = paretosearch(fun,nvars,A,b,Aeq,beq)
x = paretosearch(fun,nvars,A,b,Aeq,beq,lb,ub)
x = paretosearch(fun,nvars,A,b,Aeq,beq,lb,ub,nonlcon)
x = paretosearch(fun,nvars,A,b,Aeq,beq,lb,ub,nonlcon,options)
x = paretosearch(problem)
[x,fval]
= paretosearch(___)
[x,fval,exitflag,output]
= paretosearch(___)
[x,fval,exitflag,output,residuals]
= paretosearch(___)
defines a set of lower and upper bounds on the design variables in
x
= paretosearch(fun
,nvars
,A
,b
,Aeq
,beq
,lb
,ub
)x
, so that x
is always in the range
lb
≤ x
≤ ub
.
If no linear equalities exist, set Aeq = []
and beq =
[]
. If x(i)
has no lower bound, set lb(i)
= Inf
. If x(i)
has no upper bound, set
ub(i) = Inf
.
applies the nonlinear inequalities x
= paretosearch(fun
,nvars
,A
,b
,Aeq
,beq
,lb
,ub
,nonlcon
)c(x)
defined in
nonlcon
. The paretosearch
function finds
nondominated points such that c(x) ≤ 0
. If no bounds
exist, set lb = []
, ub = []
, or both.
Currently, paretosearch
does not support nonlinear equality
constraints ceq(x) = 0
.
Find points on the Pareto front of a twoobjective function of a twodimensional variable.
fun = @(x)[norm(x[1,2])^2;norm(x+[2,1])^2]; rng default % For reproducibility x = paretosearch(fun,2);
Pareto set found that satisfies the constraints. Optimization completed because the relative change in the volume of the Pareto set is less than 'options.ParetoSetChangeTolerance' and constraints are satisfied to within 'options.ConstraintTolerance'.
Plot the solution as a scatter plot.
plot(x(:,1),x(:,2),'m*') xlabel('x(1)') ylabel('x(2)')
Theoretically, the solution of this problem is a straight line from [2,1]
to [1,2]
. paretosearch
returns evenlyspaced points close to this line.
Create a Pareto front for a twoobjective problem in two dimensions subject to the linear constraint x(1) + x(2) <= 1
.
fun = @(x)[norm(x[1,2])^2;norm(x+[2,1])^2]; A = [1,1]; b = 1; rng default % For reproducibility x = paretosearch(fun,2,A,b);
Pareto set found that satisfies the constraints. Optimization completed because the relative change in the volume of the Pareto set is less than 'options.ParetoSetChangeTolerance' and constraints are satisfied to within 'options.ConstraintTolerance'.
Plot the solution as a scatter plot.
plot(x(:,1),x(:,2),'m*') xlabel('x(1)') ylabel('x(2)')
Theoretically, the solution of this problem is a straight line from [2,1]
to [0,1]
. paretosearch
returns evenlyspaced points close to this line.
Create a Pareto front for a twoobjective problem in two dimensions subject to the bounds x(1) >= 0
and x(2) <= 1
.
fun = @(x)[norm(x[1,2])^2;norm(x+[2,1])^2]; lb = [0,Inf]; % x(1) >= 0 ub = [Inf,1]; % x(2) <= 1 rng default % For reproducibility x = paretosearch(fun,2,[],[],[],[],lb,ub);
Pareto set found that satisfies the constraints. Optimization completed because the relative change in the volume of the Pareto set is less than 'options.ParetoSetChangeTolerance' and constraints are satisfied to within 'options.ConstraintTolerance'.
Plot the solution as a scatter plot.
plot(x(:,1),x(:,2),'m*') xlabel('x(1)') ylabel('x(2)')
All of the solution points are on the constraint boundaries x(1) = 0
or x(2) = 1
.
Create a Pareto front for a twoobjective problem in two dimensions subject to bounds 1.1 <= x(i) <= 1.1
and the nonlinear constraint norm(x)^2 <= 1.2
. The nonlinear constraint function appears at the end of this example, and works if you run this example as a live script. To run this example otherwise, include the nonlinear constraint function as a file on your MATLAB® path.
To better see the effect of the nonlinear constraint, set options to use a large Pareto set size.
rng default % For reproducibility fun = @(x)[norm(x[1,2])^2;norm(x+[2,1])^2]; lb = [1.1,1.1]; ub = [1.1,1.1]; options = optimoptions('paretosearch','ParetoSetSize',200); x = paretosearch(fun,2,[],[],[],[],lb,ub,@circlecons,options);
Pareto set found that satisfies the constraints. Optimization completed because the relative change in the volume of the Pareto set is less than 'options.ParetoSetChangeTolerance' and constraints are satisfied to within 'options.ConstraintTolerance'.
Plot the solution as a scatter plot. Include a plot of the circular constraint boundary.
figure plot(x(:,1),x(:,2),'k*') xlabel('x(1)') ylabel('x(2)') hold on rectangle('Position',[1.2 1.2 2.4 2.4],'Curvature',1,'EdgeColor','r') xlim([1.2,0.5]) ylim([0.5,1.2]) axis square hold off
The solution points that have positive x(1)
values or negative x(2)
values are close to the nonlinear constraint boundary.
function [c,ceq] = circlecons(x) ceq = []; c = norm(x)^2  1.2; end
To monitor the progress of paretosearch
, specify the 'psplotparetof'
plot function.
fun = @(x)[norm(x[1,2])^2;norm(x+[2,1])^2]; options = optimoptions('paretosearch','PlotFcn','psplotparetof'); lb = [4,4]; ub = lb; x = paretosearch(fun,2,[],[],[],[],lb,ub,[],options);
Pareto set found that satisfies the constraints. Optimization completed because the relative change in the volume of the Pareto set is less than 'options.ParetoSetChangeTolerance' and constraints are satisfied to within 'options.ConstraintTolerance'.
The solution looks like a quartercircular arc with radius 18, which can be shown to be the analytical solution.
Obtain the Pareto front in both function space and parameter space by calling paretosearch
with both the x
and fval
outputs. Set options to plot the Pareto set in both function space and parameter space.
fun = @(x)[norm(x[1,2])^2;norm(x+[2,1])^2]; lb = [4,4]; ub = lb; options = optimoptions('paretosearch','PlotFcn',{'psplotparetof' 'psplotparetox'}); rng default % For reproducibility [x,fval] = paretosearch(fun,2,[],[],[],[],lb,ub,[],options);
Pareto set found that satisfies the constraints. Optimization completed because the relative change in the volume of the Pareto set is less than 'options.ParetoSetChangeTolerance' and constraints are satisfied to within 'options.ConstraintTolerance'.
The analytical solution in objective function space is a quartercircular arc of radius 18. In parameter space, the analytical solution is a straight line from [2,1]
to [1,2]
. The solution points are close to the analytical curves.
Set options to monitor the Pareto set solution process. Also, obtain more outputs from paretosearch
to enable you to understand the solution process.
options = optimoptions('paretosearch','Display','iter',... 'PlotFcn',{'psplotparetof' 'psplotparetox'}); fun = @(x)[norm(x[1,2])^2;norm(x+[2,1])^2]; lb = [4,4]; ub = lb; rng default % For reproducibility [x,fval,exitflag,output] = paretosearch(fun,2,[],[],[],[],lb,ub,[],options);
Iter Fcount NumSolutions Spread Volume 0 60 11  3.7872e+02 1 386 12  3.4654e+02 2 702 27 9.4324e01 2.9452e+02 3 1029 27  2.9904e+02 4 1357 40 0.0000e+00 3.0154e+02 5 1697 60 1.4903e01 3.0369e+02 6 1841 60 1.4515e01 3.0439e+02 7 1961 60 1.7716e01 3.0465e+02 8 2075 60 1.6123e01 3.0475e+02 9 2189 60 1.7419e01 3.0449e+02 Pareto set found that satisfies the constraints. Optimization completed because the relative change in the volume of the Pareto set is less than 'options.ParetoSetChangeTolerance' and constraints are satisfied to within 'options.ConstraintTolerance'.
Examine the additional outputs.
fprintf('Exit flag %d.\n',exitflag)
Exit flag 1.
disp(output)
iterations: 10 funccount: 2189 volume: 304.4256 averagedistance: 0.0215 spread: 0.1742 maxconstraint: 0 message: 'Pareto set found that satisfies the constraints. ...' rngstate: [1x1 struct]
Obtain and examine the Pareto front constraint residuals. Create a problem with the linear inequality constraint sum(x) <= 1/2
and the nonlinear inequality constraint norm(x)^2 <= 1.2
. For improved accuracy, use 200 points on the Pareto front, and a ParetoSetChangeTolerance
of 1e7
, and give the natural bounds 1.2 <= x(i) <= 1.2
.
The nonlinear constraint function appears at the end of this example, and works if you run this example as a live script. To run this example otherwise, include the nonlinear constraint function as a file on your MATLAB® path.
fun = @(x)[norm(x[1,2])^2;norm(x+[2,1])^2]; A = [1,1]; b = 1/2; lb = [1.2,1.2]; ub = lb; nonlcon = @circlecons; rng default % For reproducibility options = optimoptions('paretosearch','ParetoSetChangeTolerance',1e7,... 'PlotFcn',{'psplotparetof' 'psplotparetox'},'ParetoSetSize',200);
Call paretosearch
using all outputs.
[x,fval,exitflag,output,residuals] = paretosearch(fun,2,A,b,[],[],lb,ub,nonlcon,options);
Pareto set found that satisfies the constraints. Optimization completed because the relative change in the volume of the Pareto set is less than 'options.ParetoSetChangeTolerance' and constraints are satisfied to within 'options.ConstraintTolerance'.
The inequality constraints reduce the size of the Pareto set compared to an unconstrained set. Examine the returned residuals.
fprintf('The maximum linear inequality constraint residual is %f.\n',max(residuals.ineqlin))
The maximum linear inequality constraint residual is 0.000000.
fprintf('The maximum nonlinear inequality constraint residual is %f.\n',max(residuals.ineqnonlin))
The maximum nonlinear inequality constraint residual is 0.000244.
The maximum returned residuals are negative, meaning that all the returned points are feasible. The maximum returned residuals are close to zero, meaning that each constraint is active for some points.
function [c,ceq] = circlecons(x) ceq = []; c = norm(x)^2  1.2; end
fun
— Fitness functions to optimizeFitness functions to optimize, specified as a function handle or function name.
fun
is a function that accepts a real row vector of doubles x
of length nvars
and returns a real vector F(x)
of objective function values. For details on writing fun
, see Compute Objective Functions.
If you set the UseVectorized
option to true
, then fun
accepts a matrix of size n
bynvars
, where the matrix represents n
individuals. fun
returns a matrix of size n
bym
, where m
is the number of objective functions. See Vectorize the Fitness Function.
Example: @(x)[sin(x),cos(x)]
Data Types: char
 function_handle
 string
nvars
— Number of variablesNumber of variables, specified as a positive integer. The solver passes row vectors of length
nvars
to fun
.
Example: 4
Data Types: double
A
— Linear inequality constraintsLinear inequality constraints, specified as a real matrix. A
is an M
bynvars
matrix, where M
is the number of inequalities.
A
encodes the M
linear inequalities
A*x <= b
,
where x
is the column vector of nvars
variables x(:)
, and b
is a column vector with M
elements.
For example, to specify
x_{1} + 2x_{2} ≤ 10
3x_{1} + 4x_{2} ≤ 20
5x_{1} + 6x_{2} ≤ 30,
give these constraints:
A = [1,2;3,4;5,6]; b = [10;20;30];
Example: To specify that the control variables sum to 1 or less, give the constraints
A = ones(1,N)
and b = 1
.
Data Types: double
b
— Linear inequality constraintsLinear inequality constraints, specified as a real vector. b
is an M
element vector related to the A
matrix. If you pass b
as a row vector, solvers internally convert b
to the column vector b(:)
.
b
encodes the M
linear inequalities
A*x <= b
,
where x
is the column vector of N
variables x(:)
, and A
is a matrix of size M
byN
.
For example, to specify
x_{1} + 2x_{2} ≤ 10
3x_{1} + 4x_{2} ≤ 20
5x_{1} + 6x_{2} ≤ 30,
give these constraints:
A = [1,2;3,4;5,6]; b = [10;20;30];
Example: To specify that the control variables sum to 1 or less, give the constraints
A = ones(1,N)
and b = 1
.
Data Types: double
Aeq
— Linear equality constraintsLinear equality constraints, specified as a real matrix. Aeq
is an Me
bynvars
matrix, where Me
is the number of equalities.
Aeq
encodes the Me
linear equalities
Aeq*x = beq
,
where x
is the column vector of N
variables x(:)
, and beq
is a column vector with Me
elements.
For example, to specify
x_{1}
+ 2x_{2} +
3x_{3} =
10
2x_{1}
+ 4x_{2} +
x_{3} =
20,
give these constraints:
Aeq = [1,2,3;2,4,1]; beq = [10;20];
Example: To specify that the control variables sum to 1, give the constraints Aeq =
ones(1,N)
and beq = 1
.
Data Types: double
beq
— Linear equality constraintsLinear equality constraints, specified as a real vector. beq
is an Me
element vector related to the Aeq
matrix. If you pass beq
as a row vector, solvers internally convert beq
to the column vector beq(:)
.
beq
encodes the Me
linear equalities
Aeq*x = beq
,
where x
is the column vector of N
variables x(:)
, and Aeq
is a matrix of size Meq
byN
.
For example, to specify
x_{1}
+ 2x_{2} +
3x_{3} =
10
2x_{1}
+ 4x_{2} +
x_{3} =
20,
give these constraints:
Aeq = [1,2,3;2,4,1]; beq = [10;20];
Example: To specify that the control variables sum to 1, give the constraints Aeq =
ones(1,N)
and beq = 1
.
Data Types: double
lb
— Lower bounds[]
(default)  real vector or arrayLower bounds, specified as a real vector or array of doubles. lb
represents
the lower bounds elementwise in
lb
≤ x
≤ ub
.
Internally, paretosearch
converts an array lb
to the
vector lb(:)
.
Example: lb = [0;Inf;4]
means x(1) ≥ 0
, x(3) ≥ 4
.
Data Types: double
ub
— Upper bounds[]
(default)  real vector or arrayUpper bounds, specified as a real vector or array of doubles. ub
represents
the upper bounds elementwise in
lb
≤ x
≤ ub
.
Internally, paretosearch
converts an array ub
to the
vector ub(:)
.
Example: ub = [Inf;4;10]
means x(2) ≤ 4
, x(3) ≤ 10
.
Data Types: double
nonlcon
— Nonlinear constraintsNonlinear constraints, specified as a function handle or function name.
nonlcon
is a function that accepts a row vector
x
and returns two row vectors,
c(x)
and ceq(x)
.
c(x)
is the row vector of nonlinear inequality
constraints at x
. The
paretosearch
function attempts to satisfy
c(x) <= 0
for all entries of
c
.
ceq(x)
must return []
,
because currently paretosearch
does not support
nonlinear equality constraints.
If you set the UseVectorized
option to
true
, then nonlcon
accepts a
matrix of size n
bynvars
, where the
matrix represents n
individuals.
nonlcon
returns a matrix of size
n
bymc
in the first argument,
where mc
is the number of nonlinear inequality
constraints. See Vectorize the Fitness Function.
For example,
x = paretosearch(@myfun,nvars,A,b,Aeq,beq,lb,ub,@mycon)
,
where mycon
is a MATLAB^{®} function such as the following:
function [c,ceq] = mycon(x) c = ... % Compute nonlinear inequalities at x. ceq = [] % No nonlinear equalities at x.
For more information, see Nonlinear Constraints (Optimization Toolbox).
Data Types: char
 function_handle
 string
options
— Optimization optionsoptimoptions
 structureOptimization options, specified as the output of optimoptions
or as a
structure.
optimoptions
hides the options listed in
italics; see Options that optimoptions Hides.
{}
denotes the default value. See option details in
Pattern Search Options.
Options for patternsearch
and paretosearch
Option  Description  Values 

 Tolerance on constraints. For an options structure, use  Positive scalar  
 Level of display.  'off'  'iter'  'diagnose'  {'final'} 
 Maximum number of objective function evaluations. For an options structure, use  Positive integer  
 Maximum number of iterations. For an options structure, use  Positive integer  
 Total time (in seconds) allowed for optimization. For an options structure, use  Positive scalar  
 Tolerance on the mesh size. For an options structure, use
 Positive scalar  
 Function that an optimization function calls at each iteration. Specify as a function handle or a cell array of function handles. For an options structure, use  
 Plots of output from the pattern search. Specify as the name of a builtin plot function, a function handle, or a cell array of names of builtin plot functions or function handles. For an options structure, use

For
For 
 Polling strategy used in the pattern search. 
For

 Compute objective and nonlinear constraint functions in parallel. See Vectorized and Parallel Options (User Function Evaluation) and How to Use Parallel Processing in Global Optimization Toolbox. 

 Specifies whether functions are vectorized. See Vectorized and Parallel Options (User Function Evaluation) and Vectorize the Objective and Constraint Functions. For an options structure, use 

Options for paretosearch
Only
Option  Description  Values 

 Initial points for
 Matrix with 
 Minimum fraction of the pattern to poll.  Scalar from 0 through 1  
 Number of points in the Pareto set.  Positive integer  
 The solver stops when the relative change in a stopping measure over a window of
iterations is less than or equal to
See Definitions for paretosearch Algorithm. The solver stops when the relative change in any
applicable measure is less than
NoteSetting  Positive scalar  
Options for patternsearch
Only
Option  Description  Values 

Cache  With 

CacheSize  Size of the history.  Positive scalar  
CacheTol  Largest distance from the current mesh point to any point in the history in order for
 Positive scalar  
FunctionTolerance  Tolerance on the function. Iterations stop if the change in function value is less than
For an options structure, use
 Positive scalar  
InitialMeshSize  Initial mesh size for the algorithm. See How Pattern Search Polling Works.  Positive scalar  
InitialPenalty  Initial value of the penalty parameter. See Nonlinear Constraint Solver Algorithm.  Positive scalar  
MaxMeshSize  Maximum mesh size used in a poll or search step. See How Pattern Search Polling Works.  Positive scalar  
MeshContractionFactor  Mesh contraction factor for unsuccessful iteration. For an options structure, use  Positive scalar  
MeshExpansionFactor  Mesh expansion factor for successful iteration. For an options structure, use  Positive scalar  
MeshRotate  Rotate the pattern before declaring a point to be optimum. See Mesh Options. 

PenaltyFactor  Penalty update parameter. See Nonlinear Constraint Solver Algorithm.  Positive scalar  
PlotInterval  Specifies that plot functions are called at every interval.  positive integer  
PollOrderAlgorithm  Order of poll directions in pattern search. For an options structure, use 

ScaleMesh  Automatic scaling of variables. For an options structure, use 

SearchFcn  Type of search used in pattern search. Specify as a name or a function handle. For an options structure, use 

StepTolerance  Tolerance on the variable. Iterations stop if both the change in position and the mesh
size are less than For an options structure, use
 Positive scalar  
TolBind  Binding tolerance. See Constraint Parameters.  Positive scalar  
UseCompletePoll  Complete poll around the current point. See How Pattern Search Polling Works. For an
options structure, use 

UseCompleteSearch  Complete search around current point when the search method is a poll method. See Searching and Polling. For an options structure, use 

Example: options =
optimoptions('paretosearch','Display','none','UseParallel',true)
problem
— Problem structureProblem structure, specified as a structure with 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
—
'paretosearch'
options
— Options created with optimoptions
rngstate
— Optional field to reset the
state of the random number generator
All fields in problem
are required, except for
rngstate
, which is optional.
Data Types: struct
x
— Pareto pointsm
bynvars
arrayPareto points, returned as an m
bynvars
array, where
m
is the number of points on the Pareto front. Each row of
x
represents one point on the Pareto front.
fval
— Function values on Pareto frontm
bynf
arrayFunction values on the Pareto front, returned as an
m
bynf
array. m
is the
number of points on the Pareto front, and nf
is the number of fitness
functions. Each row of fval
represents the function values at one
Pareto point in x
.
exitflag
— Reason paretosearch
stoppedReason paretosearch
stopped, returned as one of the
integer values in this table.
Exit Flag  Stopping Condition 

1  One of the following conditions is met.

0  Number of iterations exceeds
options.MaxIterations , or the number
of function evaluations exceeds
options.MaxFunctionEvaluations . 
1  Optimization is stopped by an output function or plot function. 
2  Solver cannot find a point satisfying all the constraints. 
5  Optimization time exceeds
options.MaxTime . 
output
— Information about the optimization processInformation about the optimization process, returned as a structure with these fields:
iterations
— Total number of
iterations.
funccount
— Total number of function
evaluations.
volume
— Hypervolume of the set formed
from the Pareto points in function space. See Definitions for paretosearch Algorithm.
averagedistance
— Average distance
measure of the Pareto points in function space. See Definitions for paretosearch Algorithm.
spread
— Average spread measure of the
Pareto points. See Definitions for paretosearch Algorithm.
maxconstraint
— Maximum constraint
violation, if any.
message
— Reason why the algorithm
terminated.
rngstate
— State of the MATLAB random number generator just before the algorithm
starts. You can use the values in rngstate
to
reproduce the output when you use a random poll method such as
'MADSPositiveBasis2N'
or when you use the
default quasirandom method of creating the initial population. See
Reproduce Results, which
discusses the identical technique for
ga
.
residuals
— Constraint residuals at x
Constraint residuals at x
, returned as a structure
with these fields (a glossary of the field size terms and entries follows
the table).
Field Name  Field Size  Entries 

lower  m bynvars  lb – x 
upper  m bynvars  x – ub 
ineqlin  m byncon  A*x  b 
eqlin  m byncon  Aeq*x  b 
ineqnonlin  m byncon  c(x) 
m
— Number of returned points
x
on the Pareto front
nvars
— Number of control variables
ncon
— Number of constraints of the relevant
type (such as number of rows of A
or number of
returned nonlinear equalities)
c(x)
— Numeric values of the nonlinear
constraint functions
Nondominated points, also called noninferior points, are points for which no other point has lower values of all objective functions. In other words, for nondominated points, none of the objective function values can be improved (lowered) without raising other objective function values. See What Is Multiobjective Optimization?.
paretosearch
uses a pattern search to search for points on the
Pareto front. For details, see paretosearch Algorithm.
To run in parallel, set the 'UseParallel'
option to true
.
options = optimoptions('
solvername
','UseParallel',true)
For more information, see How to Use Parallel Processing in Global Optimization Toolbox.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
Select web siteYou can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.