遗传算法图解

In the previous post, We discussed what Artificial Intelligence (AI) in general. It would be less informative if we only know the information from the outside. So in this post, I will go into a little more detail into one of the methods that exist in the AI ​​field.

在上一篇文章中,我们讨论了什么是人工智能 (AI)。 如果我们仅从外部知道信息,则信息量会减少。 所以在这篇文章中,我将更详细地介绍AI领域中存在的一种方法。

On this occasion, I will discuss an algorithm that is included in the AI ​​field, namely Genetic Algorithms. The genetic algorithm is a part of Evolutionary Computation (EC) which is inspired by the process of evolution and natural selection of living things.

在这种情况下,我将讨论AI领域中包含的一种算法,即遗传算法 。 遗传算法是进化计算 (EC)的一部分,它受到进化过程和生物自然选择的启发。

Genetic algorithms are generally used to overcome optimization and search problems. This algorithm is a general algorithm so that it can be easily implemented in various problems and can provide better results for each iteration of the search solution. Genetic algorithms can find the best solutions from candidate sets that are broad and have many optimum points and also the results tend to go to the global optimum compared to similar methods such as hill-climbing, depth-first search, etc.

遗传算法通常用于克服优化和搜索问题。 该算法是一种通用算法,因此可以轻松地在各种问题中实现,并且可以为搜索解决方案的每次迭代提供更好的结果。 遗传算法可以从广泛且具有许多最佳点的候选集中找到最佳解决方案,并且与类似的方法(例如爬山深度优先搜索等)相比,结果倾向于趋于全局最优。

Genetic algorithms can be used to solve a number of cases due to the following advantages.

由于以下优点,遗传算法可用于解决许多情况。

  • Consists of many prospective solutions that are raised at once由一次提出的许多预期解决方案组成
  • Each iteration provides a candidate for a better solution每次迭代都为更好的解决方案提供了候选者
  • Large solution space is not a problem解决方案空间大不是问题
  • A fast and efficient algorithm快速高效的算法

遗传算法中的术语 (Terms in Genetic Algorithms)

Before we go any further, we must know first about the terms that are commonly used in Genetic Algorithms.

在继续进行之前,我们必须首先了解遗传算法中常用的术语。

Population, chromosome, genotype, and phenotype
群体,染色体,基因型和表型
  • Population, collection of possible solutions.人口,可能的解决方案的集合。
  • Chromosome, one possible solution染色体,一种可能的解决方案
  • Genotype, elements contained in chromosomes基因型,染色体中包含的元素
  • Phenotype, value of genotype表型,基因型值

In addition, there are also other terms that are often used in this algorithm.

另外,在此算法中还经常使用其他术语。

  • Fitness function, function that determines the weight of each chromosome适应度函数,决定每个染色体重量的函数
  • Fitness Value, value obtained from the results of the fitness function适应度值,从适应度函数的结果中获得的值
  • Decoding and Encoding, in some cases, the phenotype can be changed to other forms. For example binary, real, permutation, and integer. Decoding and encoding is the process of changing it from one form to another.解码和编码,在某些情况下,表型可以更改为其他形式。 例如二进制,实数,置换和整数。 解码和编码是将其从一种形式更改为另一种形式的过程。
  • Generation, number of iterations in the genetic algorithm process.生成,遗传算法过程中的迭代次数。

For more details and examples of its use, I will explain in the next section.

有关更多详细信息及其使用示例,我将在下一部分中进行解释。

遗传算法的各个阶段 (Stages in Genetic Algorithms)

After we learned about the advantages and terms in the Genetic Algorithm, now we will describe the stages carried out by the genetic algorithm to produce a solution.

在了解了遗传算法的优点和术语之后,现在我们将描述遗传算法执行以产生解决方案的各个阶段。

Here, I will explain these stages in general terms. For specific cases, maybe I’ll explain in the next article. In general, genetic algorithms consist of the following steps.

在这里,我将大致解释这些阶段。 对于特定情况,也许我将在下一篇文章中进行解释。 通常,遗传算法包括以下步骤。

初始化人口 (Initialize Population)

The initial stage in genetic algorithms is to initialize populations. At this stage, we must determine the population and length of the chromosomes to be used. For determining the number of the population itself there is no provision for the amount. The greater the number of population will produce more variety of solutions, thus increasing the possibility of achieving the best solution.

遗传算法的初始阶段是初始化种群。 在这个阶段,我们必须确定要使用的染色体的数量和长度。 为了确定人口本身的数量,没有规定数量。 人口数量越大,产生的解决方案种类就越多,从而增加了获得最佳解决方案的可能性。

The determination of the length of the chromosome is usually adjusted to the case being handled. For example, if in the case of the maximization of the function f(x,y) = 5 * x — 10 * y, then the length of the chromosome is two because there are two variables namely x and y which we will look for. Another example is if the case is the Traveling Salesman Problem (TSP) then the length of the chromosome is adjusted to the number of places to be visited.

染色体长度的确定通常根据要处理的情况进行调整。 例如,如果在函数f(x,y) = 5 * x — 10 * y最大化的情况下,那么染色体的长度为2,因为我们将寻找两个变量,即x和y 。 另一个示例是,如果情况是旅行商问题(TSP) ,则将染色体的长度调整为要访问的地点数。

In addition, we also have to determine the representation of the chromosomes to be used. There are some commonly used representations such as binary, integer, float, and permutation representations. The determination of representation is adjusted to the case to be resolved.

此外,我们还必须确定要使用的染色体的表示形式。 有一些常用的表示形式,例如二进制,整数,浮点和置换表示形式。 代表的确定会根据要解决的情况进行调整。

Representation
表示

We also have to determine when this genetic algorithm process stops. There are 2 commonly used methods, the first is to determine the threshold on the fitness value, the second is to determine the number of generations.

我们还必须确定该遗传算法过程何时停止。 共有2种常用方法,第一种是确定适应度值的阈值,第二种是确定世代数。

In addition, we must also determine the value of the crossover probability and the mutation probability. For this reason, it will be explained further along with the process.

另外,还必须确定交叉概率和突变概率的值。 因此,将与过程一起进行进一步说明。

适应度计算 (Fitness calculation)

After we initialize the population, the next step is to calculate the fitness value for each chromosome. Fitness functions can vary, depending on the problem to be solved. For example, if we want to find the maximal value of the function f(x,y) = 5 * x — 10 * y, then the way to calculate it is to include the x and y values ​​in the function.

初始化种群后,下一步是计算每个染色体的适应度值。 健身功能会有所不同,具体取决于要解决的问题。 例如,如果我们要查找函数f(x,y) = 5 * x — 10 * y的最大值,则计算该函数的方法是在函数中包含xy值。

选拔 (Selection)

After all fitness values ​​are obtained, then parents are chosen. Determine the number of parent pairs you want to choose then make the selection in the following way. There are several ways to choose parent chromosomes.

获得所有适合度值后,再选择父母。 确定要选择的父对的数量,然后按以下方式进行选择。 有几种选择亲本染色体的方法。

  1. Random Selection, a way to randomly choose pairs of chromosomes from parents without the effect of fitness values. More simply, it just needs to generate random values ​​to select the index as the parent chromosome.随机选择,一种在不影响适应度值的情况下从父母中随机选择染色体对的方法。 更简单地说,只需要生成随机值以选择索引作为父染色体即可。
  2. Tournament selection, this selection method makes a selection based on fitness values. The selection begins by displaying some random values ​​as an index to select several prospective parents, then selected with the best fitness value.比赛选择,此选择方法基于适合度值进行选择。 选择首先显示一些随机值作为选择几个潜在父母的索引,然后以最佳适应性值进行选择。
  3. Roulette Wheel Selection, the use of this selection method is based on the probability of each chromosome. The size of the proportion of chromosomes in the roulette wheel will vary depending on the fitness value. The selection is made by raising a random value from the range of all fitness.轮盘赌选择,这种选择方法的使用是基于每个染色体的概率。 轮盘中染色体比例的大小将根据适应度值而变化。 通过从所有适用范围内增加一个随机值来进行选择。
Roulette wheel selection
轮盘选择

交叉 (Crossover)

After selecting parents, the next step we will do is to do a crossover. Crossover is a process for producing new chromosomes. Crossover is done between two chromosomes, and the result of the crossover is two chromosomes.

选择了父母之后,我们下一步要做的是交叉。 交叉是产生新染色体的过程。 在两个染色体之间进行交换,并且交换的结果是两个染色体。

There are two types of approaches for determining new chromosomes, namely generational and steady-state.

确定新染色体的方法有两种,即世代和稳态。

  1. Generational. Using this method, new chromosomes are made in the same number as the old chromosomes, and at the end of the iteration, the old population is replaced by the new population.世代相传。 使用此方法,可以生成与旧染色体数量相同的新染色体,并且在迭代结束时,将旧种群替换为新种群。
  2. Steady-state. Unlike the generational method, in the steady-state, the number of new chromosomes made is not the same as the old chromosome, but only one or two. The new chromosome will replace the old chromosome.稳定状态。 与世代方法不同,在稳态下,新染色体的生成数量与旧染色体数量不同,只有一两个。 新染色体将取代旧染色体。
generational vs steady state
世代与稳态

If you still remember, during the initialization process we must determine the probability of the crossover. Here is the function of the probability. The probability is used to determine whether a crossover occurs or not. In general, the crossover probability used is 0.8, but you are free to determine the probability because there is no certainty of the best probability.

如果您还记得,在初始化过程中,我们必须确定交叉的可能性。 这是概率的函数。 该概率用于确定是否发生交叉。 通常,使用的交叉概率为0.8,但是您可以自由确定概率,因为无法确定最佳概率。

We must generate random values ​​from 0 to 1, if the random value is smaller or equal to probabilities then a crossover is performed. The types of crossovers that can be done are as follows.

我们必须生成从0到1的随机值,如果随机值小于或等于概率,则将执行交叉运算。 可以进行的交叉类型如下。

  • One point crossover. This crossover exchanges genes from one chromosome to another to produce new chromosomes through one intersection point.一分频。 这种交叉将基因从一个染色体交换到另一个染色体,以通过一个交叉点产生新的染色体。
One point crossover
一分频
  • Multi-point crossover. This crossover exchanges genes from one chromosome to another to produce new chromosomes through several intersection points.多点交叉。 这种交叉将基因从一个染色体交换到另一个染色体,以通过几个交叉点产生新的染色体。
Multi-point crossover
多点交叉
  • Uniform crossover. This crossover exchanges genes from one chromosome to another through each index based on probability. Each gene has a probability like a coin, for example, if the head appears then it is exchanged and if a tail appears, the position of the gene remains.均匀的交叉。 这种交叉基于概率通过每个索引将基因从一个染色体交换到另一个染色体。 每个基因都有一个像硬币一样的概率,例如,如果出现头部,则将其交换,如果出现尾部,则该基因的位置仍然存在。
Uniform crossover
均匀交叉

All the cut points are obtained randomly.

所有切割点都是随机获得的。

突变 (Mutation)

Almost the same as a crossover, mutations are not always done due to the probability of mutations. The probability of mutation common being used is 0.1. As with crossover probabilities, there are no definite provisions regarding the value of mutation probabilities.

几乎与交叉相同,由于突变的可能性,并非总是进行突变。 共同使用突变的概率为0.1。 与交叉概率一样,对于突变概率的值也没有明确的规定。

In the process, mutations change the phenotype of genes (change the value of genes). mutations can be done with one point or can also be with many points, can also be swapped points.

在此过程中,突变会改变基因的表型(改变基因的值)。 突变可以用一个点完成,也可以用很多点进行,也可以交换点。

  • One point mutation一分突变
One point mutation
一分突变
  • Multi-point mutation多点突变
Multi-point mutation
多点突变
  • Swap mutation交换突变
Swap mutation
交换突变

幸存者选择 (Survivor selection)

Next is to get another population for the next iteration. Some chromosomes that are not important will be discarded and replaced with new chromosomes that have gone through a process of crossover and mutation.

接下来是为下一次迭代获取另一个种群。 一些不重要的染色体将被丢弃,并被经历了交叉和突变过程的新染色体取代。

In the application of genetic algorithms, it is better to use the principle of elitism, which always stores the best chromosomes during the process so that there will always be chromosomes with the highest fitness. If a newer chromosome combination appears better, then one chromosome stored previously is exchanged with the new chromosome.

在遗传算法的应用中,最好使用精英原则,该原则在此过程中始终存储最佳染色体,从而始终存在适应性最高的染色体。 如果较新的染色体组合看起来更好,则将先前存储的一个染色体与新染色体交换。

After determining the new population, the next process is to calculate the fitness value of the new population. This will continue to be repeated until the termination conditions are met. As explained earlier, the termination condition that is commonly used is to use a threshold fitness value or determine the maximum number of generations.

确定新人口后,下一步是计算新人口的适应度值。 这将继续重复直到满足终止条件。 如前所述,通常使用的终止条件是使用阈值适合度值或确定最大世代数。

If the process has stopped, then the solution of this genetic algorithm is the chromosome with the greatest fitness value.

如果该过程已停止,则此遗传算法的解决方案是适应性值最大的染色体。

翻译自: https://towardsdatascience.com/an-illustrated-guide-to-genetic-algorithm-ec5615c9ebe

遗传算法图解


http://www.taodudu.cc/news/show-2015780.html

相关文章:

  • RSA 算法图解+数学证明
  • BM算法图解
  • 算法图解第一章笔记与习题(算法简介)
  • 算法图解--python
  • Dijkstra算法图解
  • 算法图解第九章笔记与习题(动态规划)
  • 算法图解第八章笔记与习题(贪婪算法)
  • 算法图解第四章笔记与习题(快速排序)
  • A*算法图解
  • 01背包算法图解
  • 《算法图解》笔记与总结
  • 《算法图解》---笔记
  • 算法图解-----十种常用算法
  • 十大经典算法图解(详细版)
  • 算法图解
  • 五子棋初步以及对五子棋的局面估值
  • 吴昊品游戏核心算法 Round 5 —— 五子棋(无禁手)后台的判胜负AI(bfs+queue容器)(HDOJ 2699)...
  • (转载)十四步实现拥有强大AI的五子棋游戏
  • 十四步实现强大的五子棋AI
  • 吴昊品游戏核心算法 Round 5 —— (转载)十四步实现拥有强大AI的五子棋游戏...
  • 博弈算法实现简单五子棋
  • AI实现五子棋机器人(一)
  • 十四步实现拥有强大AI的五子棋游戏
  • canvas简易人机五子棋
  • 极大值极小值搜索设计五子棋
  • 十四步实现拥有强大AI的五子棋游
  • 基于java五子棋游戏设计与实现
  • 小程序“成语猜题”部分答案,总共28667题
  • 十四步实现高智能
  • 双人五子棋(C++游戏)游戏代码在最底下

遗传算法图解_遗传算法图解指南相关推荐

  1. java遗传算法编程_遗传算法示例程序

    评论 # re: 遗传算法示例程序  回复  更多评论 2007-05-06 00:18 by 橙子的希望 我可不可以表示晕倒? # re: 遗传算法示例程序[未登录]  回复  更多评论 2007- ...

  2. 协同进化遗传算法 代码_遗传算法在组卷中的应用

    最近看到之前做的项目,是关于使用遗传算法实现智能组卷的.所以这次为大家分享遗传算法的基本原理,以及在实际场景中的应用. "揭开算法神秘的面纱" 在学习计算机相关知识时,我们必定会遇 ...

  3. 185电缆的接法图解_详细图解!原来电线接头有这么多接法……

    电线接头如何接?很多电工尤其是新人都会有这个疑惑,那么今天小妹就为大家整理了非常详尽的图解各种电线接头的接法,很实用哦~ 一.导线连接的基本要求 导线连接是电工作业的一项基本工序,也是一项十分重要的工 ...

  4. python 遗传算法 字符串_遗传算法——Python

    好久没写博客了,最近看了个东西,觉得不错,整理了一下: 遗传算法 遗传算法 ( GA , Genetic Algorithm ) ,也称进化算法 . 遗传算法是受达尔文的进化论的启发,借鉴生物进化过程 ...

  5. 支持向量机概念图解_支持向量机:基本概念

    支持向量机概念图解 One of the Dual purposes Supervised Machine Learning Algorithms, serves as both a Regressi ...

  6. 韩顺平php可爱屋源码_韩顺平_php从入门到精通_视频教程_第20讲_仿sohu主页面布局_可爱屋首页面_学习笔记_源代码图解_PPT文档整理...

    韩顺平_php从入门到精通_视频教程_第20讲_仿sohu首页面布局_可爱屋首页面_学习笔记_源代码图解_PPT文档整理 对sohu页面的分析 注释很重要 经验:写一点,测试一点,这是一个很好的方法. ...

  7. Java实现一元函数遗传算法_遗传算法的基本概念和实现,附Java实现案例!

    基因遗传算法是一种灵感源于达尔文自然进化理论的启发式搜索算法.该算法反映了自然选择的过程,即最适者被选定繁殖,并产生下一代.本文简要地介绍了遗传算法的基本概念和实现,希望能为读者展示启发式搜索的魅力. ...

  8. rsatool使用步骤图解_工作中想要事半功倍?图解来助你

    一次会议上,老板让我们进行一场头脑风暴,然后将脑中浮现出来的想法以ppt的形式,在会议上与大家分享.在会上我看到其他区域的同事做的ppt,真的叫一个精美啊,有图形对比.有案例分析.有未来展望.反观自己 ...

  9. 循环首次适应算法_遗传算法 | 了解底层, 摆脱工具箱

    点击上方" 剑指数模 ",选择" 置顶 / 星标 " 回复『进群』,加入高手如云 关于遗传算法,弈笙在一篇博客中看到了比较形象有趣的讲法,适合初学者理解,并用C ...

  10. 遗传算法 python 简书_遗传算法入门

    遗传算法简介: 遗传算法(Genetic algorithm)属于演化计算( evolutionary computing),是随着人工智能领域发展而来的一种智能算法.正如它的名字所示,遗传算法是受达 ...

最新文章

  1. C# Task的用法
  2. java类同步,Java同步工具類(一)
  3. 多核处理器_多核处理器还能走多远?2050年用上1024核CPU
  4. 怎么修改提交git是的用户名_git 修改提交邮箱以及用户名-亲测
  5. Spring Cloud Alibaba迁移指南(四):零代码兼容 Api-Gateway 1
  6. Primefaces,Hibernate和SpringRoo集成
  7. Golang gRPC实践 连载七 HTTP协议转换
  8. bzoj 1263: [SCOI2006]整数划分
  9. Vim 和 NeoVim 曝出高危漏洞
  10. 月薪多少最幸福,离你有多远?
  11. java dem数据格式解析_【转载】DEM数据的介绍,获取,处理
  12. 微信公众号-网页内实现微信支付
  13. Java多线程系列--【JUC线程池 03】- 线程池原理(二)
  14. PHP中smart原则,目标smart原则 “smart原则”什么意思?
  15. 2001-2019年中国境内企业并购数据
  16. 六级词汇天天练(12.11)
  17. 织梦配置多个mysql_织梦教程:DEDECMS中MYSQL修复表的两个小技巧
  18. 云计算实战:Amazon EC2之初体验
  19. 将各种格式flv,avi,mp4等的文件,转码成MP4(无音频)
  20. MongoDB的安全认证

热门文章

  1. 谷歌被墙,如何给谷歌浏览器添加迅雷下载插件
  2. DOS MASM 安装
  3. 《Java 核心技术 卷1》 笔记 第八章 事件处理
  4. plSQL中修改代码字体的大小
  5. android跳转到地图app
  6. Perl入门学习(一)运行和基本语法
  7. 树莓派+ L298N 控制二相四线步进电机
  8. 【联合路由频谱分配】多跳认知无线电网络中的联合路由和动态频谱分配的matlab仿真与分析
  9. GPS定位RTK解决方案
  10. 安装delphi 10.4 社区版