?? test_2.m
字號:
function test_2()
i=0;
a=-0.5:0.02:0.5;
for x=a
i=i+1;
j=0;
for y=a
j=j+1;
sol=[x y];
numv = size(sol,2);
x=sol(1:numv);
d0=[1 1000 10 100 1 10 100 1000 1 10];
d=d0(1:numv);
c=0.15;
s=2*ones(1,numv);
t=0.05*ones(1,numv);
bk = s.*(round(x./s));
dev= (abs(bk-x)<t) & (bk~=0);
z=c*((bk+sign(bk).*t).^2).*d;
y=x.^2.*d;
z(i,j) = sum((dev.*z) + ((~dev).*y));
end
end
plot(z(:,1));
plot(z(1,:));
mesh(a,a,z);
view(30,60);
grid;
bounds = ones(4,1)*[-10000 10000];
%[x,endPop,bestSols,trace]=ga(bounds,'coranaMin');
evalFN='coranaMin';
evalOps=[];
opts = [1e-6 1 0];
e1str=['x=c1; c1(xZomeLength)=', evalFN ';'];
e2str=['x=c2; c2(xZomeLength)=', evalFN ';'];
%%%%%%%%%%%%%%%%%%
plot(trace(:,1),trace(:,3),'y-')
hold on
plot(trace(:,1),trace(:,2),'r-')
xlabel('Generation'); ylabel('Fittness');
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -