{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# simhwk6 - TAREA Simulaciones Computacionales Matlab...

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

TAREA: Simulaciones Computacionales VICTOR R. GONZÁLEZ L. - MAT: 805386 Matlab %function [f,X] = DE % f - optimal fitness % X - optimal solution % CONTROL PARAMETERS % D = 10; % dimension of problem NP = 60; % size of population F = 0.9; % differentiation constant CR = 0.5; % crossover constant GEN = 10000; % number of generations L = -2.048; % low boundary constraint H = 2.048; % high boundary constraint % *************************** % % ** ALGORITHM’S VARIABLES ** % % *************************** % X = zeros(D,1); % trial vector Pop = zeros(D,NP); % population Fit = zeros(1,NP); % fitness of the population iBest = 1; % index of the best solution r = zeros(3,1); % randomly selected indices % *********************** % % ** CREATE POPULATION ** % % *********************** % % initialize random number generator rand( 'state' ,sum(100*clock)); for j = 1:NP % initialize each individual Pop(:,j) = L + (H-L)*rand(D,1); % within b.constraints Fit(1,j) = fnc(Pop(:,j)); % and evaluate fitness end % ****************** % % ** OPTIMIZATION ** % % ****************** % for g = 1:GEN % for each generation for j = 1:NP % for each individual % choose three random individuals from population, % mutually different and different from j r(1) = floor(rand()* NP) + 1; while r(1)==j r(1) = floor(rand()* NP) + 1; end r(2) = floor(rand()* NP) + 1; while (r(2)==r(1))||(r(2)==j) r(2) = floor(rand()* NP) + 1; end r(3) = floor(rand()* NP) + 1; while (r(3)==r(2))||(r(3)==r(1))||(r(3)==j) r(3) = floor(rand()* NP) + 1; end % create trial individual % in which at least one parameter is changed Rnd = floor(rand()*D) + 1; for i = 1:D if ( rand()<CR ) || ( Rnd==i ) X(i) = Pop(i,r(3)) + F * (Pop(i,r(1)) - Pop(i,r(2))); else X(i) = Pop(i,j); end end % verify boundary constraints for i = 1:D

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

View Full Document
TAREA: Simulaciones Computacionales VICTOR R. GONZÁLEZ L. - MAT: 805386
This is the end of the preview. Sign up to access the rest of the document.
• Spring '11
• Hernandez
• Randomness, Hardware random number generator, R. GONZÁLEZ L., VICTOR R. GONZÁLEZ, Simulaciones Computacionales, VICTOR R. GONZÁLEZ L.

{[ snackBarMessage ]}

### Page1 / 5

simhwk6 - TAREA Simulaciones Computacionales Matlab...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online