필터 지우기
필터 지우기

genetic algorithm

조회 수: 10 (최근 30일)
Kugen Raj
Kugen Raj 2012년 3월 29일
im new to the genetic algorithm. here is a sample code of a genetic algorithm for an antenna array.
%This is a simple genetic algorithm written in MATLAB
N=8; %number of bits in a gene
M=N; %number of genes
last=20; %number of iterations
M2=M/2;
%creates M random genes having N bits
Gene=round(rand(M,N)); %gene is an MxN matrix
for ib=1:last
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% cost=function (Gene) %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%ranks results and discards bottom 50%
[cost,ind]=sort(cost); %sorts costs from best to worst
Gene=Gene(ind(l:M2),:); %sorts Gene according to costs and discard bottom half.
%mate
cross=ceil((N-l)+rand(M2,1)); %selects random cross over points
%pairs genes and swaps binary digits to the right of the
%cross over points to form the offspring
for ic=1:2:M2
Gene (M2+ic,1:cross)= Gene (ic,1:cross) ;%offspring #1
Gene (MZ+ic,cross+l:N)=Gene (ic+l,cross+l:N) ;
Gene (M2+ic+l,1 :cross)=Gene (ic+l,1:cross) ;%offspring #2
Gene (M2+ic+l,cross+l:N)=Gene (ic,cross+l:N) ;
end
% mutate
ix=ceil (M*rand) ;% randam gene
iy=ceil (N*rand) ;% randam bit in gene
Gene(ix,iy)=l-Gene(ix,iy);% mutate bit iy in gene ix
end %for ib-1:last
how can I identify that this a binary or decimal genetic algorithm.

답변 (1개)

Thomas
Thomas 2012년 3월 29일
I would guess Binary, since your gene is binary encoded..
  댓글 수: 1
Kugen Raj
Kugen Raj 2012년 3월 29일
how cn I manipulate this into decimal encoding GA? what do I need to change.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by