如何在Java中实现遗传算法的高斯变异算子 [英] How to implement the Gaussian mutation operator for a genetic algorithm in Java

查看:423
本文介绍了如何在Java中实现遗传算法的高斯变异算子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试为我的项目学习并实现一个简单的遗传算法库。在这个时候,进化,人口的选择已经准备就绪,我正在尝试实现一个简单的好变异算子,如高斯变异算子(GMO)用于Java和Scala中的遗传进化引擎。

I try to learn and implement a simple genetic algorithm library for my project. At this time, evolution, selection of population is ready, and I'm trying to implement a simple good mutation operator like the Gaussian mutation operator (GMO) for my genetic evolution engine in Java and Scala.

我找到了一些关于高斯变异算子(GMO)进入论文 基于帕累托排名的变异算子对于多目标进化算法 (PM Mateo,I。Alberto),第6页和第7页。

I find some information on Gaussian mutation operator (GMO) into the paper A mutation operator based on a Pareto ranking for multi-objective evolutionary algorithms (P.M. Mateo, I. Alberto), page 6 and 7.

但我有一些问题要找关于如何在Java中实现此高斯变异运算符和此运算符的其他有用变体的其他信息。我该怎么办?

But I have some problem to find other information on how to implement this Gaussian mutation operator and other useful variants of this operator in Java. What should I do?

我正在使用随机Java util的 random.nextGaussian()函数,但是此方法仅返回0到1之间的随机数。

I'm using the random.nextGaussian() function of random Java util, but this method only returns a random number between 0 and 1.

所以,

a)如何修改在这种情况下返回数字的精度? (例如,我想获得一个介于0和1之间的随机双数,步长等于0.00001。)

a) How can I modify the precision of the return number in this case? (For example, I want to get a random double number between 0 and 1 with step equal to 0.00001.)

b)如何指定 mu sigma 这个函数,因为我想在本地搜索我的基因组的值,而不是在-1和1之间。怎么能我是否只围绕我的基因组价值进行本地研究?

b) and how can I specify mu and sigma for this function, because I want to search locally about a value of my genome, not between -1 and 1. How can I ajust that local research around my genome value?

经过研究,我找到了b)问题的答案。我似乎可以取代这样的高斯随机数:

After research, I found an answer for the b) question. It seems I can displace the Gaussian random number like this:

 newGenomeValue = oldGenomeValue + (( gaussiandRndNumber * sigma ) + mean )

其中表示 =我的基因组值。

where mean = my genome value.

(参见如何使用底页的方法我可以生成普通或高斯分布的随机数吗?

推荐答案

要回答问题a,你们所有人必须做的是舍入到最接近的0.00001以获得这些单位的答案。例如:

To answer question a, all you have to do is round to the nearest 0.00001 to get your answer in those units. For example:

  step = 0.00001;
  quantized_x = step * Math.rint(x / step);

现在对于b部分,你有正确的想法,你提交的代码应该有效。您需要做的就是将变量重新调整到所需范围。我唯一可以补充的是,其工作的根本原因是微积分变量定理的变化: http:/ /en.wikipedia.org/wiki/Integration_by_substitution

Now for part b, you have the right idea and the code you presented should work. All you need to do is rescale your variable to the desired range. The only thing I can add is that the underlying reason this works is the change of variables theorem from calculus: http://en.wikipedia.org/wiki/Integration_by_substitution

如果你在高斯分布的情况下计算出这个公式,其中0均值和标准差为1通过线性移位和重新缩放转换,然后您将看到您写出的内容确实是正确的。

If you work out this formula in the case of a Gaussian distribution with 0 mean and standard deviation 1 being transformed by a linear shift and a rescaling, then you will see that what you wrote out was indeed correct.

总而言之,这里有一些代码可以执行技巧:

Putting it all together, here is some code that should do the trick:

double next_gaussian()
{
    double x = rng.nextGaussian();  //Use whichever method you like 
                                    //here to generate an initial [-1,1] gaussian distribution

    y = (x * 0.5) + 0.5;                //Rescale to [0,1]

    return Math.rint(y * 100000.0) * 0.00001; //Quantize to step size 0.00001
}

这篇关于如何在Java中实现遗传算法的高斯变异算子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆