Documentation 
Find minima of multiple functions using genetic algorithm
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,nonlcon)
X = gamultiobj(FITNESSFCN,NVARS,A,b,Aeq,beq,LB,UB,options)
X
= gamultiobj(FITNESSFCN,NVARS,A,b,Aeq,beq,LB,UB,nonlcon,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. For details on writing FITNESSFCN, see Compute Objective Functions. NVARS is the dimension of the optimization problem (number of decision variables). 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 $$A\ast x\le b$$, see Linear Inequality Constraints. 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 $$Aeq\ast x=beq$$ as well as the linear inequalities $$A\ast x\le b$$, see Linear Equality Constraints. (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 $$LB\le x\le UB$$, see Bound Constraints. Use empty matrices for LB and UB if no bounds exist. 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,nonlcon) subjects the minimization to the constraints defined in nonlcon. The function nonlcon accepts x and returns vectors C and Ceq, representing the nonlinear inequalities and equalities respectively. gamultiobj minimizes the fitnessfcn such that C(x) ≤ 0 and Ceq(x) = 0. (Set LB=[] and UB=[] if no bounds exist.)
X = gamultiobj(FITNESSFCN,NVARS,A,b,Aeq,beq,LB,UB,options) or X = gamultiobj(FITNESSFCN,NVARS,A,b,Aeq,beq,LB,UB,nonlcon,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  Aeq matrix for linear equality constraints 
beq  beq vector for linear equality constraints 
lb  Lower bound on x 
ub  Upper bound on x 
nonlcon  Nonlinear constraint function (optional) 
solver  'gamultiobj' 
rngstate  Optional field to reset the state of the random number generator 
options  Options structure created using gaoptimset 
Create the structure problem by exporting a problem from Optimization app, as described in Importing and Exporting Your Work in the Optimization Toolbox™ documentation.
[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 over options.StallGenLimit generations less than options.TolFun, and the final spread is less than the average spread over the past options.StallGenLimit generations 
0  Maximum number of generations exceeded 
1  Optimization terminated by an output function or 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 

problemtype  Type of problem:

rngstate  State of the MATLAB^{®} random number generator, just before the algorithm started. You can use the values in rngstate to reproduce the output of ga. See Reproduce Results. 
generations  Total number of generations, excluding HybridFcn iterations 
funccount  Total number of function evaluations 
message  gamultiobj termination message 
averagedistance  Average "distance," which by default is the standard deviation of the norm of the difference between Pareto front members and their mean 
spread  Combination of the "distance," and a measure of the movement of the points on the Pareto front between the final two iterations 
maxconstraint  Maximum constraint violation at the final Pareto set 
[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.
This example optimizes two objectives defined by Schaffer's second function, which has two objectives and a scalar input argument. The Pareto front is disconnected. Define this function in a file:
function y = schaffer2(x) % y has two columns % Initialize y for two objectives and for all x y = zeros(length(x),2); % ready for vectorization % 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 Paretooptimal 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 example solves a simple problem with one decision variable and two objectives.
The gamultiobjoptionsdemo example shows how to set options for multiobjective optimization.
[1] Deb, Kalyanmoy. MultiObjective Optimization Using Evolutionary Algorithms. John Wiley & Sons, 2001.
ga  gaoptimget  gaoptimset  patternsearch  rand  randn  Special Characters