Noval
Noval

Reputation: 1

what is the cause of my GA plot only shows straight lines

i have no idea, Is this plot appropriate because the fitness function I created is like that? output plot

here is the code:

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)

note: whereas the code I want to display is like this (https://rpubs.com/Argaadya/550805), fitness_function from web rpubs. and this is a mathematical equation that I applied fitness_math_equation;

if i separate the setup function in another chunk, it looks like this'output_fitness'

frame_uji;data_uji

Upvotes: 0

Views: 42

Answers (0)

Related Questions