我不知道,这个情节是否合适,因为我创建的适应度函数是这样的?输出图
这是代码:
library(GA)
frame_uji <- data.matrix(data_uji)
sum_fu <- matrix(0, nrow = 350, ncol = 1)
sum_fu <- c(rowSums(frame_uji))
setup <- function(x)
{
output_fitness <- numeric()
for (i in 1:350) {
output_fitness <- c(output_fitness, 1 / (1 + sum_fu[i]))
}
output_fitness
}
gann <- ga(type = "real-valued", population = , fitness = setup, lower = 1, upper = 5,
selection = gareal_rwSelection, crossover = gareal_spCrossover,
mutation = gareal_rsMutation, popSize = 350, maxiter = 350,
pcrossover = 0.6 , pmutation = 0.1, run = 30)
summary(gann)
plot(gann)
注意:虽然我要显示的代码是这样的(https://rpubs.com/Argaadya/550805),但来自网络 rpubs 的 Fitness_function。这是我应用的一个数学方程Fitness_math_equation;
如果我将设置功能分开在另一个块中,它看起来像这样'output_fitness'