simhwk6 - TAREA: Simulaciones Computacionales Matlab...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/01/2011 for the course SIMULACION SEM2 taught by Professor Hernandez during the Spring '11 term at ITESM.

Page1 / 5

simhwk6 - TAREA: Simulaciones Computacionales Matlab...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online