我正在Matlab中使用遗传算法优化图像重建算法。我在没有使用Matlab中的"ga"工具包的情况下对两个种群进行了交叉并生成了两个后代。因此,目前我有两个1*n矩阵,其整数值范围为0-255(它们是按行大顺序排列的两个图像)
population_1 = [1 2 3 4 5 6 7 8 9 10]
population_2 = [10 20 30 40 50 60 70 80 90 100]
我做了单点顺序传中,得到了的后代
Off_1 = 1 2 3 4 5 60 70 80 90 100
Off_2 = 10 20 30 40 50 6 7 8 9 10
接下来,我需要做概率率为0.02的突变。我在这里使用了"gaoptimset",并编码如下。
mutated_child = gaoptimset('MutationFcn', {@mutationuniform, .02})
我打印了结果。它给出了这样一个没有任何值的结构。
mutated_child =
PopulationType: []
PopInitRange: []
PopulationSize: []
EliteCount: []
CrossoverFraction: []
ParetoFraction: []
MigrationDirection: []
MigrationInterval: []
MigrationFraction: []
Generations: []
TimeLimit: []
FitnessLimit: []
StallGenLimit: []
StallTimeLimit: []
TolFun: []
TolCon: []
InitialPopulation: []
InitialScores: []
InitialPenalty: []
PenaltyFactor: []
PlotInterval: []
CreationFcn: []
FitnessScalingFcn: []
SelectionFcn: []
CrossoverFcn: []
MutationFcn: {[@mutationuniform] [0.0200]}
DistanceMeasureFcn: []
HybridFcn: []
Display: []
PlotFcns: []
OutputFcns: []
Vectorized: []
UseParallel: []
有人能帮我对交叉的孩子(Off_1和Off_2)进行突变吗?提前谢谢。
我对GA工具箱一无所知。但如果没有它,你可以做一些类似的事情:
% for offspring 1:
p_m = 0.02;
for i = 1:length(Off_1)
if rand(1) < p_m
Off_1(i) = randi([0,255],1);
end
end
您应该对后代2号做同样的事情