Code covered by the BSD License  

Highlights from
Genetic Algorithm to Optimise Schaffer's F6 Function

image thumbnail

Genetic Algorithm to Optimise Schaffer's F6 Function

by

 

11 Apr 2013 (Updated )

A basic GA with a real-time plotting of evaluation funtion inputs and outputs

f6Bin2Dec(popSize,chromoChild,method)
function [x,y] = f6Bin2Dec(popSize,chromoChild,method)
if strcmp('bin',method)==1
    %CHILDREN POPULATION - BINARY CODE TO DECIMAL
    chromoDec=zeros(popSize,2);
    for a=1:popSize
        for k=1:2
            chromoDec(a,k)=bin2dec(num2str((chromoChild(a,k*18-17:k*18))));
        end
    end
end
if strcmp('gray',method)==1
    %CHILDREN POPULATION - GRAY CODE TO DECIMAL
    %gra=zeros(popSize,2);
    for a=1:popSize
        for k=1:2
            gra(k,:)=((chromoChild(a,k*18-17:k*18)));
        end
        
        chromoDec(a,:)=gc2dec(gra)';
    end
end

%F6 inputs
x1=(chromoDec(:,1)); 
y1=(chromoDec(:,2));

x2=0.000762942363519148.*x1;
y2=0.000762942363519148.*y1;

x=x2-100;
y=y2-100;

Contact us