📄 first2.m
字号:
%the ga program
%the program for the y=x^(-x/2) to research the bigest or mallest
%one at [-1,2]
clc
XDtotall=2^16; % totall group for code for 16 bin
XDchoisesnum=XDtotall/2^8; %first for selection or the group is 2^8 num
temptime(XDtotall)=0; %for selection
XDtemp(XDchoisesnum)=0; % seclection for rocerding
inheritproble=0.25;
XDstart=5;
XDchanges=0.01;
%choice the first time
for i=0:XDchoisesnum-1 % rand make the bin to the array XDtemp
tempk=fix(rand(1,1)*8);
XDtemp(i+1)=i*2^8; %the rand find the number
end
%choice for circle
for wholei=1:8
wholej=9-wholei; % the half for cirlce so have eight circle
XDchoisesnum=2^wholej; %the decide how many for next circle
%select the half group
XDtemp1=XDtemp(1:XDchoisesnum);
wholenumber=1+65535.*XDtemp1/(XDtotall-1); %bin to the real
XDeval=wholenumber.^(-wholenumber/2); %the adapt
[temptime1,numtime]=sort(XDeval); % the order and the numtime record the bigs
for i=1:2^wholej/2
XDtemp(i)=XDtemp1(numtime(i+2^wholej/2));%update for the large one if you want the small one,please cut off the '+2^wholej/2'
end
%for the two for their children
for i=1:XDchoisesnum*inheritproble/2
inheritnum1=ceil(rand(1,1)*XDchoisesnum); %to choise the parents
inheritnum2=ceil(rand(1,1)*XDchoisesnum);
k1=XDtemp(inheritnum1);
k2=XDtemp(inheritnum2);
inherit1=binnum(k1,16); %for bin
inherit2=binnum(k2,16);
[kk1,kk2]=wssinherit(inherit1,inherit2,XDstart); %for making
%inherit1,inherit2
XDtemp(inheritnum1)=wssnumber(kk1,16); %return the number
XDtemp(inheritnum2)=wssnumber(kk2,16);
end
% the anther variation
XDchangerand=fix(rand(1,1)*16)+1;
for i=1:XDchoisesnum*XDchanges
k=ceil(rand(1,1)*XDchoisesnum);
XDchangebin=binnum(XDtemp(k),16);
XDchangebin(XDchangerand)= ~XDchangebin(XDchangerand); %variable
XDtemp(k)=wssnumber(XDchangebin,16);
end
end %class over
% XDtemp(1)=50300;
resultx=1+65535*XDtemp(1)/(XDtotall-1)
resulty=resultx.^(-resultx/2)
%i have two lines to work out this program 1: the x , only for first
%selection 2: bin number for change,vary
%the important things is the well using the array XDtemp, XDtemp1 to
%record the results of the bin numbers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -