?? morph.m
字號:
function n = morph(chr1,chr2,pmut)% MORPH - Metamorphose transforms one design (chromosome) into another. % % c=morph(chromosome_1,chromosome_2,pmut) transforms% chromosome_1 into type 2 keeping only the genes that are common% between the chromosomes and adds or discards any extra. The% argument pmut is the probability of mutation.%% See also MUTATE,PROBMUT,UI_MUTATE%----------Check the argumentsif and(~isa(chr1,'chrom'),~isa(chr2,'chrom')) error('arguments need to be of valid type')end%----------no need for morphingif strcmp(get(chr1,'name'),get(chr2,'name')) n=chr1; return;endfor k=1:length(pmut) if strcmp(pmut(k).name,get(chr1,'name')) if isempty(pmut(k).trans) pm_trans=[]; else pm_trans=pmut(k).trans; end break endendif rand<=pm_trans %----------Extract data c1_cdvs=get(chr1,'cdvs'); c1_ddvs=get(chr1,'ddvs'); c2_cdvs=get(chr2,'cdvs'); c2_ddvs=get(chr2,'ddvs'); %----------CDVS for k=1:length(c2_cdvs) % chr2 decides k_ind=find(c1_cdvs,get(c2_cdvs(k),'name')); % common dna if k_ind c(k)=c1_cdvs(k_ind); % yes keep it else c(k)=c2_cdvs(k); % no keep chrom_2 end end %----------DDVS for k=1:length(c2_ddvs) k_ind=find(c1_ddvs,get(c2_ddvs(k),'name')); if k_ind d(k)=c1_ddvs(k_ind); else d(k)=c2_ddvs(k); end end %----------Rebuild and return n=chrom(get(chr2,'name'),c,d);else n=chr1;end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -