using matlab global optimization toolbox for genetic algorithms

15
Using Matlab Global Optimization Toolbox for Genetic Algorithms Ranga Rodrigo April 6, 2014 Most of the sides are from the Matlab tutorial. 1

Upload: gerek

Post on 24-Feb-2016

228 views

Category:

Documents


1 download

DESCRIPTION

Using Matlab Global Optimization Toolbox for Genetic Algorithms. Ranga Rodrigo April 6, 2014 Most of the sides are from the Matlab tutorial. Introduction. Global Optimization Toolbox provides methods that search for global solutions to problems that contain multiple maxima or minima. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

1

Using Matlab Global Optimization Toolbox for Genetic Algorithms

Ranga RodrigoApril 6, 2014

Most of the sides are from the Matlab tutorial.

Page 2: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

2

Introduction• 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

Page 3: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

3

What Is Global Optimization?• 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.

Page 4: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

4

What is the Genetic Algorithm (GA)?• 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.

Page 5: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

5

Applicability of GA• 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.

Page 6: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

6

Applicability of GA• 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.

Page 7: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

7

PERFORMING A GENETIC ALGORITHM OPTIMIZATION

Page 8: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

8

Using Optimization Tool• optimtool('ga')

Page 9: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

9

Page 10: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

10

Inputs• 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.

Page 11: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

11

Inputs• 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.

Page 12: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

12

Example: Rastrigin's Function• 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:)2cos2(cos1020)Ras( 21

22

21 xxxxx

Page 13: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

13

In the Fitness function field, enter @rastriginsfcn.In the Number of variables field, enter 2, the number of independent variables for Rastrigin's function

Page 14: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

14

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 valueless than options.TolFun.

The final point, which in this example is [-0.021 0.018].

Page 15: Using  Matlab  Global Optimization Toolbox for Genetic Algorithms

15

The Optimization Tool Plot functions pane enables you to display various plots that provide information about the genetic algorithm while it is running. This information can help you change options to improve the performance of the algorithm. For example, to plot the best and mean values of the fitness function at each generation, select the box next to Best fitness, as shown in the following figure