├── .gitattributes ├── LICENSE ├── README.md ├── 和声算法 ├── Caseone.m ├── Casetwo.m ├── HS.m ├── HS_evolve.m ├── Init.m └── fitness.m ├── 图片 ├── 1.png ├── 2.png ├── 3.png ├── 4.PNG └── 5.png ├── 基于仿真方法的CNC刀片选择策略 ├── Caseone.m ├── Casetwo.m ├── Random.m └── random_group.m ├── 基于和声算法改进的自适应遗传算法 ├── Caseone.m ├── Casetwo.m ├── GA.m ├── GA_evolve.m ├── GA_evolve_pro.m ├── Init.m └── fitness.m ├── 无故障_随机生成算法 ├── Caseone.m ├── Casetwo.m ├── Random.m └── main.m ├── 有故障_随机生成算法 ├── Caseone_error.m ├── Casetwo_error.m ├── Random.m └── main_error.m └── 遗传算法 ├── Caseone.m ├── Casetwo.m ├── GA.m ├── GA_evolve.m ├── GA_evolve_pro.m ├── Init.m └── fitness.m /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 KenyonZhao233 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Adaptive genetic algorithm based on improved harmony algorithm 2 | 3 | ![Image text](https://github.com/KenyonZhao233/An-improved-genetic-algorithm-based-on-harmony-algorithm/blob/master/图片/1.png) 4 | 5 | 遗传算法是一种借鉴生物界自然选择和自然遗传机制的随机化搜索算法。 6 | 由于其适应不同任务的泛化能力较强,被广泛应用于非线性、多目标、多变量、复杂的自适应系统中。 7 | 但是传统遗传算法收敛速度慢、容易陷入局部最优解,尤其在复杂问题中,收敛时间长且很难得到全局最优解。 8 | 9 | 为了解决这两个问题,我们采取了两种不同的改进优化方案:自适应遗传算法优化与基于和声算法的遗传算法优化。 10 | 11 | # 1.自适应遗传算法优化 12 | 即是通过计算种群中心区域密度,判断种群是否接近或者到达了某个局部最优解区域。 13 | 此时如果种群内部已经相对稳定,难以发生实质进化和走出局部最优解。我们选择设置类似于自然界中的“天灾”设定,一定程度上将旧种群初始化为新的种群,从而走出此处局部最优解,并试图寻找下一个可能的局部最优解,从而使模型更有希望与能力达到全局最优解。 14 | 同时我们也设置在正常的种群中心区域密度下,密度越高时,变异概率也会随之上升,尽量减少种群“灭亡与重生”的次数。 15 | 16 | ![Image text](https://github.com/KenyonZhao233/An-improved-genetic-algorithm-based-on-harmony-algorithm/blob/master/图片/2.png)![Image text](https://github.com/KenyonZhao233/An-improved-genetic-algorithm-based-on-harmony-algorithm/blob/master/图片/3.png) 17 | 18 | ![Image text](https://github.com/KenyonZhao233/An-improved-genetic-algorithm-based-on-harmony-algorithm/blob/master/图片/4.PNG) 19 | 20 | 21 | # 2.基于和声算法的遗传算法优化 22 | (1)和声搜索算法(HS) 23 | 简介:是一种新的启发式全局搜索算法,智能模拟了音乐演奏的原理。 24 | 25 | ![Image text](https://github.com/KenyonZhao233/An-improved-genetic-algorithm-based-on-harmony-algorithm/blob/master/图片/5.png) 26 | 27 | (2)和声算法的推广 28 | 自适应遗传算法在接近局部最优解区域时存在可能并未达到局部最优解点便被“灭亡与重生”为新的种群,进而错过某个可能的全局最优解。 29 | 而结合和声算法,其记忆库中的优秀和声不断参加迭代,保证着最优解的收敛速度,使种群有能力在“灭亡与重生”前达到局部最优。 30 | 同时其带来的容易陷入局部最优解的劣势可以被自适应遗传算法一定程度上的弥补,二者的结合,使改良后的遗传算法具有更强的寻找全局最优解能力与较快的收敛速度。 31 | -------------------------------------------------------------------------------- /和声算法/Caseone.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/和声算法/Caseone.m -------------------------------------------------------------------------------- /和声算法/Casetwo.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/和声算法/Casetwo.m -------------------------------------------------------------------------------- /和声算法/HS.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/和声算法/HS.m -------------------------------------------------------------------------------- /和声算法/HS_evolve.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/和声算法/HS_evolve.m -------------------------------------------------------------------------------- /和声算法/Init.m: -------------------------------------------------------------------------------- 1 | function X =Init(s) 2 | X = zeros(s, 1024); 3 | for k = 1 : s 4 | for i = 1 : 1024 5 | b = 0; 6 | a = mod(i ,256); 7 | while a > 0 8 | b = [b, mod(a, 2)]; 9 | if mod(a, 2) == 0 10 | a = a / 2; 11 | else 12 | a = (a - 1) / 2; 13 | end 14 | end 15 | if b == 0 16 | b = [0 0 0 0 0 0 0 0]; 17 | else 18 | b(1) = []; 19 | b = str2num(reverse(num2str(b))); 20 | size_b = size(b); 21 | while(size_b(2) < 8) 22 | b = [0, b]; 23 | size_b(2) = size_b(2) + 1; 24 | end 25 | end 26 | [~, maxn] = max(b .* rand(1, 8)); 27 | X(k, i) = maxn(1); 28 | end 29 | end 30 | X = uint16(X); 31 | end -------------------------------------------------------------------------------- /和声算法/fitness.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/和声算法/fitness.m -------------------------------------------------------------------------------- /图片/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/图片/1.png -------------------------------------------------------------------------------- /图片/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/图片/2.png -------------------------------------------------------------------------------- /图片/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/图片/3.png -------------------------------------------------------------------------------- /图片/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/图片/4.PNG -------------------------------------------------------------------------------- /图片/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/图片/5.png -------------------------------------------------------------------------------- /基于仿真方法的CNC刀片选择策略/Caseone.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/基于仿真方法的CNC刀片选择策略/Caseone.m -------------------------------------------------------------------------------- /基于仿真方法的CNC刀片选择策略/Casetwo.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/基于仿真方法的CNC刀片选择策略/Casetwo.m -------------------------------------------------------------------------------- /基于仿真方法的CNC刀片选择策略/Random.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/基于仿真方法的CNC刀片选择策略/Random.m -------------------------------------------------------------------------------- /基于仿真方法的CNC刀片选择策略/random_group.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/基于仿真方法的CNC刀片选择策略/random_group.m -------------------------------------------------------------------------------- /基于和声算法改进的自适应遗传算法/Caseone.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/基于和声算法改进的自适应遗传算法/Caseone.m -------------------------------------------------------------------------------- /基于和声算法改进的自适应遗传算法/Casetwo.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/基于和声算法改进的自适应遗传算法/Casetwo.m -------------------------------------------------------------------------------- /基于和声算法改进的自适应遗传算法/GA.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/基于和声算法改进的自适应遗传算法/GA.m -------------------------------------------------------------------------------- /基于和声算法改进的自适应遗传算法/GA_evolve.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/基于和声算法改进的自适应遗传算法/GA_evolve.m -------------------------------------------------------------------------------- /基于和声算法改进的自适应遗传算法/GA_evolve_pro.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/基于和声算法改进的自适应遗传算法/GA_evolve_pro.m -------------------------------------------------------------------------------- /基于和声算法改进的自适应遗传算法/Init.m: -------------------------------------------------------------------------------- 1 | function X =Init(s) 2 | X = zeros(s, 1024); 3 | for k = 1 : s 4 | for i = 1 : 1024 5 | b = 0; 6 | a = mod(i ,256); 7 | while a > 0 8 | b = [b, mod(a, 2)]; 9 | if mod(a, 2) == 0 10 | a = a / 2; 11 | else 12 | a = (a - 1) / 2; 13 | end 14 | end 15 | if b == 0 16 | b = [0 0 0 0 0 0 0 0]; 17 | else 18 | b(1) = []; 19 | b = str2num(reverse(num2str(b))); 20 | size_b = size(b); 21 | while(size_b(2) < 8) 22 | b = [0, b]; 23 | size_b(2) = size_b(2) + 1; 24 | end 25 | end 26 | [~, maxn] = max(b .* rand(1, 8)); 27 | X(k, i) = maxn(1); 28 | end 29 | end 30 | X = uint16(X); 31 | end -------------------------------------------------------------------------------- /基于和声算法改进的自适应遗传算法/fitness.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/基于和声算法改进的自适应遗传算法/fitness.m -------------------------------------------------------------------------------- /无故障_随机生成算法/Caseone.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/无故障_随机生成算法/Caseone.m -------------------------------------------------------------------------------- /无故障_随机生成算法/Casetwo.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/无故障_随机生成算法/Casetwo.m -------------------------------------------------------------------------------- /无故障_随机生成算法/Random.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/无故障_随机生成算法/Random.m -------------------------------------------------------------------------------- /无故障_随机生成算法/main.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/无故障_随机生成算法/main.m -------------------------------------------------------------------------------- /有故障_随机生成算法/Caseone_error.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/有故障_随机生成算法/Caseone_error.m -------------------------------------------------------------------------------- /有故障_随机生成算法/Casetwo_error.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/有故障_随机生成算法/Casetwo_error.m -------------------------------------------------------------------------------- /有故障_随机生成算法/Random.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/有故障_随机生成算法/Random.m -------------------------------------------------------------------------------- /有故障_随机生成算法/main_error.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/有故障_随机生成算法/main_error.m -------------------------------------------------------------------------------- /遗传算法/Caseone.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/遗传算法/Caseone.m -------------------------------------------------------------------------------- /遗传算法/Casetwo.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/遗传算法/Casetwo.m -------------------------------------------------------------------------------- /遗传算法/GA.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/遗传算法/GA.m -------------------------------------------------------------------------------- /遗传算法/GA_evolve.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/遗传算法/GA_evolve.m -------------------------------------------------------------------------------- /遗传算法/GA_evolve_pro.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/遗传算法/GA_evolve_pro.m -------------------------------------------------------------------------------- /遗传算法/Init.m: -------------------------------------------------------------------------------- 1 | function X =Init(s) 2 | X = zeros(s, 1024); 3 | for k = 1 : s 4 | for i = 1 : 1024 5 | b = 0; 6 | a = mod(i ,256); 7 | while a > 0 8 | b = [b, mod(a, 2)]; 9 | if mod(a, 2) == 0 10 | a = a / 2; 11 | else 12 | a = (a - 1) / 2; 13 | end 14 | end 15 | if b == 0 16 | b = [0 0 0 0 0 0 0 0]; 17 | else 18 | b(1) = []; 19 | b = str2num(reverse(num2str(b))); 20 | size_b = size(b); 21 | while(size_b(2) < 8) 22 | b = [0, b]; 23 | size_b(2) = size_b(2) + 1; 24 | end 25 | end 26 | [~, maxn] = max(b .* rand(1, 8)); 27 | X(k, i) = maxn(1); 28 | end 29 | end 30 | X = uint16(X); 31 | end -------------------------------------------------------------------------------- /遗传算法/fitness.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenyonZhao233/Adaptive-genetic-algorithm-based-on-improved-harmony-algorithm/77c461cb002e7fd47828d055cac3afb948ed37a7/遗传算法/fitness.m --------------------------------------------------------------------------------