资源简介

改进遗传算法的C++实现。种群初始化采用联赛竞争,保证种群基因优良;轮盘赌选择略有改进;交叉变异概率自适应,相比固定的概率效果提升极为明显。变异步长自适应,避免固定步长找不到最优解的风险。用复杂变态多峰函数测试效果十分不错,相比二进制编码遗传算法精度优势明显。

资源截图

代码片段和文件信息

clc;
clear all;

% %三维网格使用 mesh函数 surf函数   matlab三维图学习画法
% [xy] = meshgrid(0:0.08:2*pi);
% z = sin(x).*cos(y);
% figure(1);
% mesh(xyz);
% xlabel(‘长为x‘);ylabel(‘宽为y‘);
% zlabel(‘高为t‘);
% title(‘z = sin(x)*cos(y)‘);
% grid on;
% box on;
% figure(2);
% mesh(z)box on;
% figure(3);
% surf(xyz);
% grid onbox on;

%测试函数的绘制
xx = -3.0:0.001:12.1;
yy = 4.1:0.001:5.8;
[xy] = meshgrid(xxyy);
z = 21.5+(x.*sin(4.*pi.*x)) + (y.*sin(20.*pi.*y));
figure(1);
mesh(xyz);
xlabel(‘长为x‘);ylabel(‘宽为y‘);
zlabel(‘高为z‘);title(‘z = 21.5 + x sin(4πx) +y sin(20πy)‘)
grid on;box on;

% xx = -10.0:0.01:10.0;
% yy = -10.0:0.01:10.0;
% [xy] = meshgrid(xxyy);

% z = 1.0 + (x.*exp(-x.*x - y.*y));
% figure(2);
% mesh(xyz);
% xlabel(‘长为x‘);ylabel(‘宽为y‘);
% zlabel(‘高为z‘);title(‘z = 1 + x*e^(-x^2 -y^2)‘);
% grid on;box on;

% z = 1.0 + sin(sqrt(x.*x + y.*y))/sqrt(x.*x + y.*y);
% figure(3);
% mesh(xyz);
% xlabel(‘长为x‘);ylabel(‘宽为y‘);
% zlabel(‘高为z‘);title(‘z = 1.0 + sin(sqrt(x^2 + y^2))/sqrt(x^2 + y^2)‘);
% grid on;box on;




 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     38400  2018-05-03 21:30  Genetic_Algorithm\.vs\Project_GA\v14\.suo

     文件     171008  2018-01-14 00:37  Genetic_Algorithm\Debug\Project_GA.exe

     文件     733732  2018-01-14 00:37  Genetic_Algorithm\Debug\Project_GA.ilk

     文件    1224704  2018-01-14 00:37  Genetic_Algorithm\Debug\Project_GA.pdb

     文件       1121  2018-01-14 10:28  Genetic_Algorithm\MatlabGraph.m

     文件     424222  2018-01-14 00:37  Genetic_Algorithm\Project_GA\Debug\GAlgorithm.obj

     文件       1023  2018-01-14 00:37  Genetic_Algorithm\Project_GA\Debug\Project_GA.Build.CppClean.log

     文件        243  2018-01-14 00:37  Genetic_Algorithm\Project_GA\Debug\Project_GA.log

     文件       1394  2018-01-14 00:37  Genetic_Algorithm\Project_GA\Debug\Project_GA.tlog\CL.command.1.tlog

     文件      23602  2018-01-14 00:37  Genetic_Algorithm\Project_GA\Debug\Project_GA.tlog\CL.read.1.tlog

     文件       1362  2018-01-14 00:37  Genetic_Algorithm\Project_GA\Debug\Project_GA.tlog\CL.write.1.tlog

     文件       1396  2018-01-14 00:37  Genetic_Algorithm\Project_GA\Debug\Project_GA.tlog\link.command.1.tlog

     文件       3146  2018-01-14 00:37  Genetic_Algorithm\Project_GA\Debug\Project_GA.tlog\link.read.1.tlog

     文件        664  2018-01-14 00:37  Genetic_Algorithm\Project_GA\Debug\Project_GA.tlog\link.write.1.tlog

     文件        207  2018-01-14 00:37  Genetic_Algorithm\Project_GA\Debug\Project_GA.tlog\Project_GA.lastbuildstate

     文件     431185  2018-01-14 00:37  Genetic_Algorithm\Project_GA\Debug\Test.obj

     文件     470016  2018-01-14 00:37  Genetic_Algorithm\Project_GA\Debug\vc140.idb

     文件     430080  2018-01-14 00:37  Genetic_Algorithm\Project_GA\Debug\vc140.pdb

     文件      12571  2018-01-13 21:13  Genetic_Algorithm\Project_GA\GAlgorithm.cpp

     文件       3392  2018-01-13 22:04  Genetic_Algorithm\Project_GA\GAlgorithm.h

     文件       1284  2018-04-20 21:19  Genetic_Algorithm\Project_GA\MatlabFigure.m

     文件       7497  2017-12-15 19:09  Genetic_Algorithm\Project_GA\Project_GA.vcxproj

     文件       1162  2017-12-15 19:09  Genetic_Algorithm\Project_GA\Project_GA.vcxproj.filters

     文件       3372  2018-01-12 09:59  Genetic_Algorithm\Project_GA\Test.cpp

     文件       5797  2018-01-12 10:14  Genetic_Algorithm\Project_GA\TestData1.txt

     文件       5876  2018-01-12 10:36  Genetic_Algorithm\Project_GA\TestData10.txt

     文件       5772  2018-01-12 10:37  Genetic_Algorithm\Project_GA\TestData11.txt

     文件       5631  2018-01-12 10:38  Genetic_Algorithm\Project_GA\TestData12.txt

     文件       5639  2018-01-12 10:40  Genetic_Algorithm\Project_GA\TestData13.txt

     文件       5819  2018-01-12 10:41  Genetic_Algorithm\Project_GA\TestData14.txt

............此处省略36个文件信息

评论

共有 条评论