フィルターのクリア

genetic algorithm

1 回表示 (過去 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 Center および File ExchangeGenetic Algorithm についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by