EE4047 Poject Report - E E4047 P roject Report ZHOU Zefang...

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

View Full Document Right Arrow Icon
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 representation for the individuals is used. format long e; clear; NIND = 10; % Number of individuals per subpopulations 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; % Generation gap, how many new individuals are created % Build field description matrix FieldD = [22; -1; 2; 0; 0; 1; 1]; % Initialize the first population Chrom = crtbp(NIND, NVAR*PRECI); % Convert into real number Pheno = bs2rv(Chrom, FieldD); % Evaluate the first population ObjV = obj1(Pheno); % reset count variables gen = 0; maxO=[]; avgO=[]; % Generational Loop while gen < MAXGEN, % Assign Fitness values to entire population FitnV = ObjV;
Image of page 1

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

View Full Document Right Arrow Icon
% 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' );
Image of page 2
hold on ; plot(x,y, 'ok' ); hold off ; legend( 'theoretical curve' , 'maximum solution by GA' ); grid on ; title( 'Case 1' ) xlabel( 'x' ); ylabel( 'f(x)' ); % OBJ1.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. Figure-1 The maximum solution obtained by GA v.s. theoretical curve 1. Chromosome Coding
Image of page 3

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

View Full Document Right Arrow Icon
Number of Bits to meet the requirement of precision of six decimal places for maximum x = -- × = × = . = N log22 1 106 log23 106 21 51 22 By hand calculation = - + - + - + - + - + - + - + - + - + - + - + - × - Pheno 2 1 2 5 2 7 2 8 2 9 2 11 2 12 2 14 2 16 2 20 2 21 2 22 3 = . × - = . 1 0 5457322597503662 3 1 0 6371971695893215 By MATLAB Commend with GA Toolbox format long e; Chrom=[1 0 0 0 1 0 1 1 1 0 1 1 0 1 0 1 0 0 0 1 1 1]; Field=[22;-1;2;0;0;1;1]; Pheno=bs2rv(Chrom, Field) By MATLAB Commend without using GA Toolbox Pheno=0; for i=1:22
Image of page 4
Image of page 5
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