calling a function for mutation operator but getting error
16 次查看(过去 30 天)
显示 更早的评论
I am calling following function, but getting error (Undefined function or variable 'parent_genotype')
genotype = mutation_new(parent_genotype,mutation_rate,n_genes_mutated,total_jobs);
data in mutation_new.m file is as under
function genotype = mutation_new(parent_genotype,mutation_rate,n_genes_mutated,total_jobs)
population_size = 5;
mutation_rate = 0.1;
total_jobs=50;
parent_genotype = randperm(total_jobs);
b = parent_genotype;
population_matrix = zeros(population_size,total_jobs);
n_genes_mutated = length(parent_genotype)*mutation_rate;
for i = 1:n_genes_mutated/2
num1 = randi(total_jobs,1);
num2 = randi(total_jobs,1);
b([num1 num2]) = b([num2 num1]);
end
genotype = b;
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!