1

我正在使用 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)进行突变?提前致谢。

4

1 回答 1

1

我对 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

于 2015-04-06T13:55:12.650 回答