简体   繁体   English

如何在R中的GA包中的遗传算法函数中将变量设置为整数

[英]How to set the variables as integers in a Genetic Algorithm Function in GA package in R

Have a look at documentation of GA package in R 看看R中GA包的文档

ftp://cran.r-project.org/pub/R/web/packages/GA/GA.pdf ftp://cran.r-project.org/pub/R/web/packages/GA/GA.pdf

The only solution I have found so far is to use a ceiling, floor, or round function in order to convert the decimal value to an integer within the fitness function--before passing it to the actual function being optimized. 到目前为止,我发现的唯一解决方案是使用天花板,地板或圆形函数,以便将十进制值转换为适应度函数内的整数 - 然后将其传递给正在优化的实际函数。

This, however, slows down the GA function greatly. 然而,这大大减慢了GA功能。

There is another genetic algorithm that might be useful if you only wish to use integers. 如果您只想使用整数,还有另一种遗传算法可能会有用。 It is called GeneticAlg.int from the gramEvol package. 它被称为gramEvol包中的GeneticAlg.int。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM