#### Transcript Using Matlab Global Optimization Toolbox for Genetic Algorithms

```Ranga Rodrigo
April 6, 2014
Most of the sides are from the Matlab
tutorial.
1
• Global Optimization Toolbox provides methods that
search for global solutions to problems that contain
multiple maxima or minima.
• This includes the solvers:
– global search
– multistart
– pattern search
– genetic algorithm, and
– simulated annealing
2
• Optimization is the process of finding the point that
minimizes a function. More specifically:
– A local minimum of a function is a point where the
function value is smaller than or equal to the value at
nearby points, but possibly greater than at a distant
point.
– A global minimum is a point where the function value is
smaller than or equal to the value at all other feasible
points.
– Genetic algorithms is able to find global minima.
3
• The GA is a method for solving both constrained
and unconstrained optimization problems that is
based on natural selection, the process that drives
biological evolution.
• The GA repeatedly modifies a population of
individual solutions.
• At each step, the GA selects individuals at random
from the current population to be parents and uses
them to produce the children for the next
generation.
• Over successive generations, the population
"evolves" toward an optimal solution.
4
• You can apply the genetic algorithm to solve a
variety of optimization problems that are not well
suited for standard optimization algorithms,
including problems in which the objective function
is discontinuous, nondifferentiable, stochastic, or
highly nonlinear.
• The genetic algorithm can address problems of
mixed integer programming, where some
components are restricted to be integer-valued.
5
• The GA uses three main types of rules at each step
to create the next generation from the current
population:
– Selection rules select the individuals, called parents, that
contribute to the population at the next generation.
– Crossover rules combine two parents to form children
for the next generation.
– Mutation rules apply random changes to individual
parents to form children.
6
7
• optimtool('ga')
8
9
• To use the Optimization Tool, wemust first enter the
following information:
• Fitness function:
– The objective function you want to minimize. Enter the
fitness function in the form @fitnessfun, where
fitnessfun.m is a file that computes the fitness function.
Computing Objective Functions explains how write this
file. The @ sign creates a function handle to fitnessfun.
• Number of variables:
– The length of the input vector to the fitness function.
10
• You can enter constraints or a nonlinear constraint
function for the problem in the Constraints pane. If
the problem is unconstrained, leave these fields
blank.
• To run the genetic algorithm, click the Start button.
The tool displays the results of the optimization in
the Run solver and view results pane.
• You can change the options for the genetic
algorithm in the Options pane.
• To view the options in one of the categories listed in
the pane, click the + sign next to it.
11
• Lets go through example that shows how to find the
minimum of Rastrigin's function, a function that is
often used to test the genetic algorithm.
• For two independent variables, Rastrigin's function:
Ras( x)  20  x12  x22 10(cos2x1  cos2x2 )
12
In the Fitness function field, enter
@rastriginsfcn.
In the Number of variables field, enter 2, the
number of independent variables for
Rastrigin's function
13
While the algorithm is running, the Current
iteration field displays the number of the
current generation. You can temporarily pause
the algorithm by clicking the Pause button.
When you do so, the button name changes to
Resume. To resume the algorithm from the
point at which you paused it, click Resume.
When the algorithm is finished, the Run solver
and view results pane appears as shown in the
following figure. Your numerical results might
differ from those in the figure, since ga is
stochastic
The display shows:
The final value of the fitness function when the algorithm terminated:
Objective function value: 0.15078442701228667
The reason the algorithm terminated.
Optimization terminated: average change in the fitness value
less than options.TolFun.
The final point, which in this example is [-0.021 0.018].
14
The Optimization Tool Plot functions
pane enables you to display various
plots that provide information about
the genetic algorithm while it is
running.