| Genetic Algorithm and Direct Search Toolbox™ | ![]() |
X = gamultiobj(FITNESSFCN,NVARS)
X = gamultiobj(FITNESSFCN,NVARS,A,b)
X = gamultiobj(FITNESSFCN,NVARS,A,b,Aeq,beq)
X = gamultiobj(FITNESSFCN,NVARS,A,b,Aeq,beq,LB,UB)
X = gamultiobj(FITNESSFCN,NVARS,A,b,Aeq,beq,LB,UB,options)
X = gamultiobj(problem)
[X,FVAL] = gamultiobj(FITNESSFCN,NVARS, ...)
[X,FVAL,EXITFLAG] = gamultiobj(FITNESSFCN,NVARS, ...)
[X,FVAL,EXITFLAG,OUTPUT] = gamultiobj(FITNESSFCN,NVARS,
...)
[X,FVAL,EXITFLAG,OUTPUT,POPULATION] = gamultiobj(FITNESSFCN,
...)
[X,FVAL,EXITFLAG,OUTPUT,POPULATION,SCORE] = gamultiobj(FITNESSFCN,
...)
gamultiobj implements the genetic algorithm at the command line to minimize a multicomponent objective function.
X = gamultiobj(FITNESSFCN,NVARS) finds a local Pareto set X of the objective functions defined in FITNESSFCN. NVARS is the dimension of the optimization problem (number of decision variables). FITNESSFCN accepts a vector X of size 1-by-NVARS and returns a vector of size 1-by-numberOfObjectives evaluated at a decision variable. X is a matrix with NVARS columns. The number of rows in X is the same as the number of Pareto solutions. All solutions in a Pareto set are equally optimal; it is up to the designer to select a solution in the Pareto set depending on the application.
X = gamultiobj(FITNESSFCN,NVARS,A,b) finds
a local Pareto set X of the objective functions
defined in FITNESSFCN, subject to the linear inequalities
. Linear constraints are supported
only for the default PopulationType option ('doubleVector'). Other population types, e.g., 'bitString' and 'custom', are not supported.
X = gamultiobj(FITNESSFCN,NVARS,A,b,Aeq,beq) finds a local Pareto set X of the objective functions
defined in FITNESSFCN, subject to the linear equalities
as well as the linear inequalities
. (Set A=[] and b=[] if no inequalities exist.) Linear constraints
are supported only for the default PopulationType option ('doubleVector'). Other population types,
e.g., 'bitString' and 'custom', are not supported.
X = gamultiobj(FITNESSFCN,NVARS,A,b,Aeq,beq,LB,UB) defines a set of lower and upper bounds on the design variables X so that a local Pareto set is found in the range
. Use empty matrices for LB and UB if no bounds exist. Set LB(i) = -Inf if X(i) is unbounded below;
set UB(i) = Inf if X(i) is
unbounded above. Bound constraints are supported only for the default PopulationType option ('doubleVector'). Other population types, e.g., 'bitString' and 'custom', are not supported.
X = gamultiobj(FITNESSFCN,NVARS,A,b,Aeq,beq,LB,UB,options) finds a Pareto set X with the default optimization parameters replaced by values in the structure options. options can be created with the gaoptimset function.
X = gamultiobj(problem) finds the Pareto set for problem, where problem is a structure containing the following fields:
| fitnessfcn | Fitness functions |
| nvars | Number of design variables |
| Aineq | A matrix for linear inequality constraints |
| bineq | b vector for linear inequality constraints |
| Aeq | A matrix for linear equality constraints |
| beq | b vector for linear equality constraints |
| lb | Lower bound on x |
| ub | Upper bound on x |
| randstate | Optional field to reset rand state |
| randnstate | Optional field to reset randn state |
| options | Options structure created using gaoptimset |
Create the structure problem by exporting a problem from Optimization Tool, as described in Importing and Exporting Your Work in the Optimization Toolbox™ User's Guide.
[X,FVAL] = gamultiobj(FITNESSFCN,NVARS, ...) returns a matrix FVAL, the value of all the objective functions defined in FITNESSFCN at all the solutions in X. FVAL has numberOfObjectives columns and same number of rows as does X.
[X,FVAL,EXITFLAG] = gamultiobj(FITNESSFCN,NVARS, ...) returns EXITFLAG, which describes the exit condition of gamultiobj. Possible values of EXITFLAG and the corresponding exit conditions are listed in this table.
| EXITFLAG Value | Exit Condition |
|---|---|
| 1 | Average change in value of the spread of Pareto set over options.StallGenLimit generations less than options.TolFun |
| 0 | Maximum number of generations exceeded |
| -1 | Optimization terminated by the output or by the plot function |
| -2 | No feasible point found |
| -5 | Time limit exceeded |
[X,FVAL,EXITFLAG,OUTPUT] = gamultiobj(FITNESSFCN,NVARS, ...) returns a structure OUTPUT with the following fields:
| OUTPUT Field | Meaning |
|---|---|
| Output.randstate | State of the function rand used before the genetic algorithm started |
| Output.randnstate | State of the function randn used before the genetic algorithm started |
| Output.generations | Total number of generations, excluding HybridFcn iterations |
| Output.funccount | Total number of function evaluations |
| Output.maxconstraint | Maximum constraint violation, if any |
| Output.message | gamultiobj termination message |
[X,FVAL,EXITFLAG,OUTPUT,POPULATION] = gamultiobj(FITNESSFCN, ...) returns the final POPULATION at termination.
[X,FVAL,EXITFLAG,OUTPUT,POPULATION,SCORE] = gamultiobj(FITNESSFCN, ...) returns the SCORE of the final POPULATION.
GA Multiobjective
This example optimizes two objectives defined by Schaffer's second function: a vector-valued function of two components and one input argument. The Pareto front is disconnected. Define this function in an M-file:
function y = schaffer2(x) % y has two columns
% Initialize y for two objectives and for all x
y = zeros(length(x),2);
% Evaluate first objective.
% This objective is piecewise continuous.
for i = 1:length(x)
if x(i) <= 1
y(i,1) = -x(i);
elseif x(i) <=3
y(i,1) = x(i) -2;
elseif x(i) <=4
y(i,1) = 4 - x(i);
else
y(i,1) = x(i) - 4;
end
end
% Evaluate second objective
y(:,2) = (x -5).^2;First, plot the two objectives:
x = -1:0.1:8; y = schaffer2(x); plot(x,y(:,1),'.r'); hold on plot(x,y(:,2),'.b');
The two component functions compete in the range [1, 3] and [4, 5]. But the Pareto-optimal front consists of only two disconnected regions: [1, 2] and [4, 5]. This is because the region [2, 3] is inferior to [1, 2].
Next, impose a bound constraint on x,
setting
lb = -5; ub = 10;
The best way to view the results of the genetic algorithm is to visualize the Pareto front directly using the @gaplotpareto option. To optimize Schaffer's function, a larger population size than the default (15) is needed, because of the disconnected front. This example uses 60. Set the optimization options as:
options = gaoptimset('PopulationSize',60,'PlotFcns',...
@gaplotpareto);
Now call gamultiobj, specifying one independent variable and only the bound constraints:
[x,f,exitflag] = gamultiobj(@schaffer2,1,[],[],[],[],... lb,ub,options); Optimization terminated: average change in the spread of Pareto solutions less than options.TolFun. exitflag exitflag = 1
The vectors x, f(:,1), and f(:,2) respectively contain the Pareto set and both objectives evaluated on the Pareto set.
The gamultiobjfitness demo solves a simple problem with one decision variable and two objectives.
The gamultiobjoptionsdemo demo shows how to set options for multiobjective optimization.
[1] Deb, Kalyanmoy. Multi-Objective Optimization Using Evolutionary Algorithms. John Wiley & Sons, 2001.
ga, gaoptimget, gaoptimset, patternsearch, @ (Special Characters), rand, randn
![]() | ga | gaoptimget | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |