crossover matlab,Vary Mutation and Crossover

Setting the Amount of Mutation

The genetic algorithm applies mutations using the MutationFcn option. The

default mutation option, @mutationgaussian, adds a random number,

or mutation, chosen from a Gaussian distribution, to each entry

of the parent vector. Typically, the amount of mutation, which is proportional to

the standard deviation of the distribution, decreases at each new generation. You

can control the average amount of mutation that the algorithm applies to a parent in

each generation through the Scale and Shrink

inputs that you include in a cell array:

options = optimoptions('ga',...

'MutationFcn',{@mutationgaussian Scale Shrink});

Scale and Shrink are scalars with default

values 1 each.

Scale controls the standard deviation of the mutation

at the first generation. This value is Scale multiplied

by the range of the initial population, which you specify by the

InitialPopulationRange option.

Shrink controls the rate at which the average amount of

mutation decreases. The standard deviation decreases linearly so that its

final value equals 1 – Shrink times its

initial value at the first generation. For example, if

Shrink has the default value of

1, then the amount of mutation decreases to 0 at the

final step.

You can see the effect of mutation by selecting the plot functions

@gaplotdistance and @gaplotrange, and then

running the genetic algorithm on a problem such as the one described in Minimize Rastrigin's Function. The following figure shows the plot

after setting the random number generator.

rng default % For reproducibility

options = optimoptions('ga','PlotFcn',{@gaplotdistance,@gaplotrange},...

'MaxStallGenerations',200); % to get a long run

[x,fval] = ga(@rastriginsfcn,2,[],[],[],[],[],[],[],options);

a11851e27a1398cb9d4c04a17b36e234.png

The upper plot displays the average distance between points

in each generation. As the amount of mutation decreases, so does the

average distance between individuals, which is approximately 0 at

the final generation. The lower plot displays a vertical line at each

generation, showing the range from the smallest to the largest fitness

value, as well as mean fitness value. As the amount of mutation decreases,

so does the range. These plots show that reducing the amount of mutation

decreases the diversity of subsequent generations.

For comparison, the following figure shows the same plots when you set

Shrink to 0.5.

options = optimoptions('ga',options,...

'MutationFcn',{@mutationgaussian,1,.5});

[x,fval] = ga(@rastriginsfcn,2,[],[],[],[],[],[],[],options);

da8f0f5586ef029965401aae32936b79.png

This time, the average amount of mutation decreases by a factor of 1/2 by the final

generation. As a result, the average distance between individuals decreases less

than before.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值