⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.m

📁 使用遗传算法求一个多项式函数在区间[0
💻 M
字号:
% this file is test cases
%%%%%%%%%%%%%% test function [y]=flip(x)
% x=zeros(1,10);
% for m=1:10
%     x(m)=flip(0.5);
% end
% x
%%%%%%%%%%%%%% test function [y]=randint(low,high)
% x=zeros(1,10);
% for m=1:10
%     x(m)=randint(1,50);
% end
% x
%%%%%%%%%%%%%% test function [y]=b2d(x)
cls
x=[0 0 0 0,0 0 0 1]&1;
y=b2d(x)
%%%% test
% cls
% count=0;
% for m=4:1       % This way is wrong!
%     count=count+1
% end
%%%%%%%%%%%%%% test function [sumfit maxfit maxsite fitness]=cfitness(x,lchrom)
% cls
% x=[0 1 2 3 7]';
% lchrom=3;
% [sumfit maxfit maxsite fitness]=cfitness(x,lchrom)
%%%%%%%%%%%%%% test function [y]=select(x,sumfit)
% cls
% x=[0 100 20 60 70]';
% lchrom=20;
% [sumfit maxfit maxsite fitness]=cfitness(x,lchrom);
% select(fitness,sumfit)
%%%%%%%%%%%%%% test 
% function [child1,child2]=cross(parent1,parent2,pcross,lchrom)
% cls
% pcross=0.7;
% lchrom=4;
% parent1=[0 0 0 0];
% parent2=[1 1 1 1];
% child1=zeros(1,4);
% child2=zeros(1,4);
% [child1,child2]=cross(parent1,parent2,pcross,lchrom);
% [parent1;parent2;child1;child2]
%%%%%%%%%%%%%% test function [y]=mutation(x,pmutation,lchrom)
% cls
% pmutation=0.05;
% lchrom=5;
% x=[1 1 1 1 1];
% [y]=mutation(x,pmutation,lchrom)
%%%%%%%%%%%%%% test function [y]=inital(popsize,lchrom)
% cls
% popsize=10;
% lchrom=5;
% [y]=inital(popsize,lchrom)
%%%%%%%%%%%%%% test
%%%%%%%%%%%%%% test

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -