📄 ui_mutate.m
字号:
function minfo = ui_mutate(chr)
% UI_MUTATE - interface for specifying mutate ratios.
% minfo = ui_mutate(chr) returns a structure with the mutation
% information for the different species. The input argument chr
% are the prototypes for the species. The structure has the
% following fields.
%
% name - the name of the species
% mut_lim - limits of mutation used when calculating the
% probability of mutation using the diversity of one species.
% pc - constant probability of mutation.
% trans - probability of transmutation, i.e the probability
% for one species to transmutate into another.
% relive - NOT YET IMPLEMENTED
for k=1:length(chr);
clc;
minfo(k).name=get(chr(k),'name');
fprintf('Current chromosome: %s\n',minfo(k).name);
fprintf('-------------------------------------\n')
%pm=input('give the limits of mutation: ');
pm=pm_check;
minfo(k).mut_lim=pm;
if isempty(pm)
pconstant=input('give constant probability of mutation: ');
minfo(k).pc=pconstant;
else
minfo(k).pc=0;
end
minfo(k).trans=input('give probability for transmutation: ');
if isempty(minfo(k).trans)
minfo(k).trans=0;
end
minfo(k).relive=input('give probability of re-live ');
if isempty(minfo(k).relive)
minfo(k).relive=0;
end
end
clc;
tst=input('Save information: ? y/n ','s');
if strcmp(tst,'y')
fname=input('Give filename: ','s');
fid=fopen(fname,'w');
fprintf(fid,'File created: %s\n',datestr(now));
fprintf(fid,'----------------------------------\n');
for k=1:length(minfo)
fprintf(fid,'Name: %s\n',minfo(k).name);
fprintf(fid,'Limits: %g %g\n',minfo(k).mut_lim);
if isempty(minfo(k).mut_lim)
fprintf(fid,'\n');
end
fprintf(fid,'pc: %g\n',minfo(k).pc);
fprintf(fid,'transmutate: %g\n',minfo(k).trans);
fprintf(fid,'relive: %g\n',minfo(k).relive);
fprintf(fid,'-------------\n');
end
fclose(fid);
end
function pm = pm_check()
% PM_CHECK -
%
pm=input('give the limits of mutation: ');
if isempty(pm)
return
elseif length(pm)~=2
display('The limits are incorrect, press return to continue');
input('');
pm=pm_check;
elseif pm(1)>=pm(2)
display('The limits are incorrect, press return to continue');
input('');
pm=pm_check;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -