PHP Write Genetic algorithm

Source: Internet
Author: User

This article mainly introduces the PHP write genetic algorithm, has a certain reference value, now share to everyone, the need for friends can refer to

This paper attempts to write genetic algorithm in PHP language

The specific introduction of genetic algorithms, please self-search, this article is not exactly in line with the wording of the network, the author level is limited, the use of intermediate algorithms are not very clever, please take criticism to read the article.

The genetic algorithm steps used in this paper
- ① Initial population
- ② Elimination
- ③ Crossover
- ④ variants
- ⑤ Rebuild the population and iterate the ②-④ step
- ⑥ drawings and other additional operations

The first section of the story previously and algorithm outline

First, the story previously

This article introduces the story of a great God about scallops, which is roughly what the PHP code says.
There's a group of scallops on a beach with no worries, and God has nothing to do with Bob. Using genetic algorithms to complete the scallops, Bob came and asked for scallops:
① you can only have 16 scallops, each generation I want to kill 2, which 2 shells on the pattern most unlike Google browser icon I kill who;

② the remaining 14 of the 4 scallops 22 combined with 2 children, and then gather enough 16, so cycle;
These scallops are very distressed, but what is the way, some scallops left, and then just left 16, that is, these scallops, created the later Chrome scallops.

Second, the algorithm outline

Genetic algorithm simulates the genetic law of the Man of God of Darwin Montesquieu, screening, breeding and mutation of the population, so that after many generations, they can cultivate those goals that conform to the rules.
of genetic algorithms
The first step is to establish the initial population, which can be randomly established, such as the first 16 scallops in the story.
The second step is to set up the elimination mechanism, that is, the screening process, for which we add a fitness attribute for scallops, that is, the pattern on the scallop back, and how much like our chrome icon, where the fitness is calculated as the Pixel 4 channel difference (absolute value) of the sum of 4 channels containing transparent channels.

This paper attempts to write genetic algorithm in PHP language

The specific introduction of genetic algorithms, please self-search, this article is not exactly in line with the wording of the network, the author level is limited, the use of intermediate algorithms are not very clever, please take criticism to read the article.

The genetic algorithm steps used in this paper
- ① Initial population
- ② Elimination
- ③ Crossover
- ④ variants
- ⑤ Rebuild the population and iterate the ②-④ step
- ⑥ drawings and other additional operations

The first section of the story previously and algorithm outline

First, the story previously

This article introduces the story of a great God about scallops, which is roughly what the PHP code says.
There's a group of scallops on a beach with no worries, and God has nothing to do with Bob. Using genetic algorithms to complete the scallops, Bob came and asked for scallops:
① you can only have 16 scallops, each generation I want to kill 2, which 2 shells on the pattern most unlike Google browser icon I kill who;

② the remaining 14 of the 4 scallops 22 combined with 2 children, and then gather enough 16, so cycle;
These scallops are very distressed, but what is the way, some scallops left, and then just left 16, that is, these scallops, created the later Chrome scallops.

Second, the algorithm outline

The

Genetic algorithm simulates the genetic law of the man-of-God of Darwin Montesquieu, screening, breeding, and mutation of the population, so that after many generations, those goals that meet the rules can be cultivated.
Genetic algorithm
The first step is to establish the initial population, the initial population can be randomly established, such as the first 16 scallops in the story.
The second step is to set up the elimination mechanism, that is, to filter the program, for which we add a fitness property for scallops, that is, the pattern on the scallop back, and our chrome icon is much like, where the fitness is calculated as the Pixel 4 channel difference (absolute value) of the sum of 4 channels containing transparent channels.

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.