Products & Services Industries Academia Support User Community Company

Learn more about Genetic Algorithm and Direct Search Toolbox   

gamultiobj - Find minima of multiple functions using genetic algorithm

Syntax

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, ...)

Description

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

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 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 ValueExit 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 FieldMeaning
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 Reproducing Your Results.

generationsTotal number of generations, excluding HybridFcn iterations
funccountTotal number of function evaluations
maxconstraintMaximum constraint violation, if any
messagegamultiobj 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.

Example

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.

Demos

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.

Algorithm

gamultiobj uses a controlled elitist genetic algorithm (a variant of NSGA-II [1]). An elitist GA always favors individuals with better fitness value (rank). A controlled elitist GA also favors individuals that can help increase the diversity of the population even if they have a lower fitness value. It is important to maintain the diversity of population for convergence to an optimal Pareto front. Diversity is maintained by controlling the elite members of the population as the algorithm progresses. Two options, ParetoFraction and DistanceFcn, control the elitism. ParetoFraction limits the number of individuals on the Pareto front (elite members). The distance function, selected by DistanceFcn, helps to maintain diversity on a front by favoring individuals that are relatively far away on the front.

References

[1] Deb, Kalyanmoy. Multi-Objective Optimization Using Evolutionary Algorithms. John Wiley & Sons, 2001.

See Also

ga, gaoptimget, gaoptimset, patternsearch, @ (Special Characters), rand, randn

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS