ga - Find minimum of function using genetic algorithm

Syntax

x = ga(fitnessfcn,nvars)
x = ga(fitnessfcn,nvars,A,b)
x = ga(fitnessfcn,nvars,A,b,Aeq,beq)
x = ga(fitnessfcn,nvars,A,b,Aeq,beq,LB,UB)
x = ga(fitnessfcn,nvars,A,b,Aeq,beq,LB,UB,nonlcon)
x = ga(fitnessfcn,nvars,A,b,Aeq,beq,LB,UB,nonlcon,options)
x = ga(problem)
[x,fval] = ga(...)
[x,fval,exitflag] = ga(...)

Description

ga implements the genetic algorithm at the command line to minimize an objective function.

x = ga(fitnessfcn,nvars) finds a local unconstrained minimum, x, to the objective function, fitnessfcn. nvars is the dimension (number of design variables) of fitnessfcn. The objective function, fitnessfcn, accepts a vector x of size 1-by-nvars, and returns a scalar evaluated at x.

x = ga(fitnessfcn,nvars,A,b) finds a local minimum x to fitnessfcn, subject to the linear inequalities . fitnessfcn accepts input x and returns a scalar function value evaluated at x.

If the problem has m linear inequality constraints and n variables, then

Note that the linear constraints are not satisfied when the PopulationType option is set to 'bitString' or 'custom'.

x = ga(fitnessfcn,nvars,A,b,Aeq,beq) finds a local minimum x to fitnessfcn, subject to the linear equalities as well as . (Set A=[] and b=[] if no inequalities exist.)

If the problem has r linear equality constraints and n variables, then

Note that the linear constraints are not satisfied when the PopulationType option is set to 'bitString' or 'custom'.

x = ga(fitnessfcn,nvars,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 . 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.

x = ga(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 the vectors C and Ceq, representing the nonlinear inequalities and equalities respectively. ga minimizes the fitnessfcn such that C(x)≤0 and Ceq(x)=0. (Set LB=[] and UB=[] if no bounds exist.)

Note that the nonlinear constraints are not satisfied when the PopulationType option is set to 'bitString' or 'custom'.

x = ga(fitnessfcn,nvars,A,b,Aeq,beq,LB,UB,nonlcon,options) minimizes with the default optimization parameters replaced by values in the structure options, which can be created using the gaoptimset function. See the gaoptimset reference page for details.

x = ga(problem) finds the minimum for problem, where problem is a structure containing the following fields:

fitnessfcn

Fitness function

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

nonlcon

Nonlinear constraint function

randstate

Optional field to reset rand state

randnstate

Optional field to reset randn state

solver

'ga'

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] = ga(...) returns fval, the value of the fitness function at x.

[x,fval,exitflag] = ga(...) returns exitflag, an integer identifying the reason the algorithm terminated. The following lists the values of exitflag and the corresponding reasons the algorithm terminated.

[x,fval,exitflag,output] = ga(...) returns output, a structure that contains output from each generation and other information about the performance of the algorithm. The output structure contains the following fields:

[x,fval,exitflag,output,population] = ga(...) returns the matrix, population, whose rows are the final population.

[x,fval,exitflag,output,population,scores] = ga(...) returns scores the scores of the final population.

Example

Given the following inequality constraints and lower bounds

the following code finds the minimum of the function, lincontest6, that is provided your software:

A = [1 1; -1 2; 2 1];
b = [2; 2; 3];
lb = zeros(2,1);
[x,fval,exitflag] = ga(@lincontest6,... 
2,A,b,[],[],lb)

Optimization terminated: 
average change in the fitness value less than
 options.TolFun.

x =
   0.7794   1.2205

fval =
   -8.03916

exitflag =
1

References

[1] Goldberg, David E., Genetic Algorithms in Search, Optimization & Machine Learning, Addison-Wesley, 1989.

[2] A. R. Conn, N. I. M. Gould, and Ph. L. Toint. "A Globally Convergent Augmented Lagrangian Algorithm for Optimization with General Constraints and Simple Bounds", SIAM Journal on Numerical Analysis, Volume 28, Number 2, pages 545–572, 1991.

[3] A. R. Conn, N. I. M. Gould, and Ph. L. Toint. "A Globally Convergent Augmented Lagrangian Barrier Algorithm for Optimization with General Inequality Constraints and Simple Bounds", Mathematics of Computation, Volume 66, Number 217, pages 261–288, 1997.

See Also

gaoptimget, gaoptimset, patternsearch, simulannealbnd, threshacceptbnd

  


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