Genetic Algorithm and direct search toolbox learning notes 8-Overview of Genetic Algorithm

Source: Internet
Author: User

What is genetic algorithm?

Genetic algorithm is an algorithm that solves the optimization problem based on the natural selection mechanism in the biological evolution process. The optimization problems solved include both non-constrained and constrained optimization problems. The genetic algorithm constantly updates and modifies the population of potential solutions. In each step of algorithm iteration, the algorithm randomly selects some individuals as the parent in the current population, and then generates some child generations for these parent generations. After consecutive generations of operation, the population will evolve towards the optimal solution. You can use genetic algorithms to solve various optimization problems that traditional methods cannot solve. These problems include the discrete, non-micro, highly nonlinear, and random objective functions.

In the current population,
Genetic algorithms use three types of rules to generate the next generation:

1. Select: Select parent.

2. Crossover: two individuals in the parent generation are combined to generate the next generation of individuals, who are children of the parent generation.

3. Variation: randomly change some parent individuals to become child individuals in the next generation.


Run the Genetic Algorithm

There are two methods to execute the genetic algorithm: 1 command line mode and 2. graphical interface mode.

1. Command Line

Enter the statement in the following format in the command line.

[X fval] = Ga (@ fitnessfun, nvars, options)

Among them: @ fitnessfun is the handle of the fitness function (if you do not know the concept of the handle, you need to supplement the knowledge of MATLAB ),

Nvars is the number of independent variables in the fitness function, and options is all the options during Algorithm Execution. Of course, you can

Enter this parameter, because the Genetic Algorithm Toolbox will provide us with some default options. These default options are intended for most problems.

It is feasible, unless you want to implement some of your own unique methods, you need to modify these options.
In the returned value:
X is the coordinate of the vertex when the algorithm is alive.
Fval is the final result of the fitness function.
2. graphical interface
If you want to use the GUI, you can enter optimtool ('ga ') in the command line window or in the MATLAB Start Menu.
Select the optimization tool. For more information about how to start the tool, see note 4. In this way, you will get the graphic user interface of the genetic algorithm.

Are you familiar with this interface? well, by the way, this is also seen in pattern search, but in the solver column, 'gal' is selected here ',
On the Right of the graphic interface, there are still some selectable control panels for the algorithm. If you want to adjust the running parameters of the genetic algorithm, you can
Search on the right of the graphic interface.
Okay. Let's continue!
In the following figure

Fill in the handle of the fitness function and the number of independent variables in the fitness function. I still remember that we wrote a function named mytest In the second note,
We will still use this function to test it. Enter @ mytest In the first input box and 2 in the second input column,
Click the "Start" button to start running. The result is as follows:

The minimum value found by the genetic algorithm is-8.99999, And the point of this value is [-0.536, 2.463]. To compare and verify the result,
I used the Pattern Search Method to run the same function. The start point starts from [0 0]. The following figure shows the result of the Pattern Search.

The results are similar. It seems that pattern search is better.


 




 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.