DE2.m - function DE2 clear all clc%Common Parameter Setting...

Info icon This preview shows pages 1–3. Sign up to view the full content.

function DE2() clear all clc %Common Parameter Setting N=2; % Number of variables M=50; % Populations size F=0.5; % Mutation factor C=0.9; % Crossover rate I_max=200; % Max iteration time Run=1; % The number of test time X_max=[5.12,5.12]; X_min=[-5.12,-5.12]; [email protected]; % 2.The whole test loop for r=1:Run iter=0; % 1.Generate MxN matrix for m=1:M for n=1:N X(m,n)=X_min(n)+rand()*(X_max(n)-X_min(n)); end end for i=1:I_max % Stop when the iteration large than the max iteration time iter=iter+1; for m=1:M % For each individual % Mutation %[V]=rand1(X,M,F,m); %{--- R=randperm(M);%returns a row vector containing a random permutation of the integers from 1 to M inclusive (sampling without replacement). Example: randperm(6)might be the vector [3 2 6 4 1 5] j=R(1); k=R(2); p=R(3); u=R(4); v=R(5); if j==m j=R(6); elseif k==m k=R(6); elseif p==m p=R(6); elseif u==m u=R(6); elseif v==m v=R(6); end V=X(j,:)+F*(X(k,:)-X(p,:)); %} % Check if the element in the V matrix beyond the boundary. for n=1:N if V(1,n)>X_max(1,n) V(1,n)=X_max(1,n); end if V(1,n)<X_min(1,n) V(1,n)=X_min(1,n);
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

end end % Crossover put the result in the U matrix jrand=floor(rand()*N+1); for n=1:N R1=rand(); if (R1<C || n==jrand) U(1,n)=V(1,n); else U(1,n)=X(m,n);
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern