Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 28th, 2020 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. clear,clc;
  2. numcykle=1000; % pocet cyklov hladania
  3. lpop=500;        % velkost  populacie - kolko retazcov naraz testujem
  4. psub = 5;       %pocet subpopulacii
  5. migr = 50;      %pocet generacii, po ktorych nastane migracia
  6.  
  7. minFit = -10.^11;
  8. Space=[ones(1,5)*(0);ones(1,5)*10000000];   % rozsah prvkov v retazci
  9.  
  10.  
  11. Pop = zeros(lpop/psub,5,psub);
  12. Fit = zeros(lpop/psub,psub);
  13. for i=1:psub
  14.     Pop(:,:,i)=genrpop((lpop/psub),Space);
  15. end
  16.  
  17. grafFit=zeros(1,numcykle);
  18. for j=1:numcykle
  19.     for i=1:psub
  20.         for x=1:lpop/psub
  21.             Fit(x,i)=0.04*Pop(x,1,i) + 0.07*Pop(x,2,i) + 0.11*Pop(x,3,i) + 0.06*Pop(x,4,i) + 0.05*Pop(x,5,i);
  22.         end
  23.        
  24.         for i=1:psub
  25.             for x=1:lpop/psub
  26.                 a = (Pop(x,1,i) + Pop(x,2,i) + Pop(x,3,i) + Pop(x,4,i) + Pop(x,5,i));
  27.                 if a > 10000000
  28.                     Fit(x,i) = Fit(x,i) - (a - 10000000);
  29.                 end
  30.  
  31.                 a = (Pop(x,1,i) + Pop(x,2,i));
  32.                 if a > 2500000
  33.                     Fit(x,i) = Fit(x,i) - (a - 2500000);
  34.                 end
  35.  
  36.                 a = (-Pop(x,4,i) + Pop(x,5,i));
  37.                 if a > 0
  38.                     Fit(x,i) = Fit(x,i) - a;
  39.                 end
  40.  
  41.                 a = (-0.5*Pop(x,1,i) - 0.5*Pop(x,2,i) + 0.5*Pop(x,3,i) + 0.5*Pop(x,4,i) - 0.5*Pop(x,5,i));
  42.                 if a > 0
  43.                     Fit(x,i) = Fit(x,i) - a;
  44.                 end
  45.             end
  46.             BestSub(i,:)=selbest(Pop(:,:,i),Fit(:,i)*(-1),1);
  47.             FitSub(i)=0.04*BestSub(i,1) + 0.07*BestSub(i,2) + 0.11*BestSub(i,3) + 0.06*BestSub(i,4) + 0.05*BestSub(i,5);
  48.             GrafSub(j,i)=FitSub(i);
  49.             %x = (lpop/psub-10)/2;
  50.             Best=selbest(Pop(:,:,i),Fit(:,i)*(-1),lpop/psub*0.15);
  51.             Work=selrand(Pop(:,:,i),Fit(:,i)*(-1),(lpop/psub*0.7));
  52.             Work = [Work;Best];
  53.             Work=crossov(Work,4,0);
  54.             Work=mutx(Work,0.1,Space);
  55.             Work=muta(Work,0.3,ones(1,5)*100000,Space);
  56.             Pop(:,:,i)= [Best;Work];
  57.            
  58.             %disp(Pop(:,:,i));
  59.         end
  60.        
  61.        
  62.         end
  63.         BestOne=selbest(BestSub(:,:),FitSub(:)*(-1),1);
  64.         GrafFit(j)=0.04*BestOne(1) + 0.07*BestOne(2) + 0.11*BestOne(3) + 0.06*BestOne(4) + 0.05*BestOne(5);
  65.  
  66.        
  67.        
  68. end
  69.  
  70.  
  71. disp(BestOne);
  72. for b=1 : psub
  73.     plot(GrafSub(b,:));
  74.    hold on;
  75. end
  76. %plot(GrafFit);
  77. %hold on;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top