EE4047 Poject Report - EE4047 Project Report ZHOU Zefang...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: EE4047 Project Report ZHOU Zefang 50914137 1 Objectives 1. To get familiar with GA concept and procedures; 2. To visualize the effect of parameter setting on the performance of a GA; 3. To design a simple GA to solve specified optimization problems. 2 Results and Discussions CASE 1 Maximum solution to a function of x The objective is to find the value of ∈- x 112 , such that the function value = + . fx xsin10πx 2 0 is maximum. The code to achieve the above objective is % Case1.m % This script implements the Simple Genetic Algorithm for CASE 1 % Binary representat ion for the individuals is used. format long e; clear; NIND = 10; % Number of individuals per subpopulat ions MAXGEN = 100; % maximal Number of generations NVAR = 1; % Number of variables of objective function PRECI = 22; % Precision of binary representation of each variable in NVAR GGAP = .4; % Generat ion gap, how many new individuals are created % Build field description mat rix FieldD = [22; -1; 2; 0; 0; 1; 1]; % Init ialize the first populat ion Chrom = crtbp(NIND, NVAR* PRECI); % Convert into real number Pheno = bs2rv(Chrom, FieldD); % Evaluate the first populat ion ObjV = obj1(Pheno); % reset count variables gen = 0; maxO= ; avgO= ; % Generat ional Loop while gen < MAXGEN, % Assign Fit ness values to entire populat ion Fit nV = ObjV; % Select individuals from population SelCh = select( 'rws' , Chrom, FitnV, GGAP); % Recombine selected individuals (crossover) SelCh= xovsp(SelCh, 0.9); % Mutate offspring SelCh = mut(SelCh,0.01); % Evaluate the objective values of offspring ObjVSel = obj1(bs2rv(SelCh, FieldD)); % Insert offspring in population replacing parents. % ¡§reins¡¨ is designed for minimization problem in the toolbox [Chrom ObjV] = reins(Chrom, SelCh, 1, 1, -ObjV, -ObjVSel); ObjV = -ObjV; % counter increment gen=gen+1; maxO=[maxO;max(ObjV)]; avgO=[avgO;mean(ObjV)]; end ; figure(1); plot(maxO, 'k-' ); hold on ; plot(avgO, 'k-.' ); hold off ; legend( 'maximum' , 'average' ); title( 'Case 1' ); xlabel( 'generation' ); ylabel( 'evaluatoin value of f(x)' ); y=max(ObjV); y pheno=bs2rv(Chrom,FieldD); objv=obj1(pheno); i=1; while i<=NIND if objv(i)==max(ObjV) x=pheno(i); i=NIND+1; x end i=i+1; end figure(2); a=-1:1e-3:2; b=obj1(a); plot(a,b, 'k' ); hold on ; plot(x,y, 'ok' ); hold off ; legend( 'theoretical curve' , 'maximum solut ion by GA' ); grid on ; t it le( 'Case 1' ) xlabel( 'x' ); ylabel( 'f(x)' ); % OB J1.M (Objective function for CASE 1) function ObjVal = obj1(Pheno); ObjVal = Pheno .* sin(10.*pi.* Pheno)+ 2.0; The output shown in the MATLAB command window is y = 3.850268035054924e+ 000 x = 1.850626671463650e+ 000 Theoretically, the maximum value of y= f(x) for x in the domain from -1 to 2 is f(x)= 3.85027 when x= 1.850547. The experimental value of x is approximately equal to the theoretical one of x, while the experimental value of y is the same as the theoretical one of y....
View Full Document

This note was uploaded on 01/11/2011 for the course EE 4047 taught by Professor Kitsangtsang during the Fall '09 term at City University of Hong Kong.

Page1 / 27

EE4047 Poject Report - EE4047 Project Report ZHOU Zefang...

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

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