hadi
hadi

Reputation: 57

R: Can I use values in a data frame instead of objective functions to run NSGA-II via MCO package?

Considering the sample data frame below, is there a way to use these values to run NSGA-II (from the MCO package)?

df.sample <- data.frame("A" = c(10, 15, 13, 100, 1000, 75, 1, 0.6, 99, 64, 2, 123),
                   "B" = c(12, 10000, 0.01, 99, 1, 2, 3, 47, 99, 1, 82, 1))

I'm currently using the code below to identify the Pareto optimal solutions of the sample data frame - which is doing the job, but I was thinking whether using NSGA-II (from MCO package) would return the same results (and be more efficient?).

#Function to check Pareto optimality    
is_pareto_optimal <- function(row, data) {
      pareto <- TRUE
      for (i in 1:nrow(data)) {
        if (all(row >= data[i, 1:2]) && any(row > data[i, 1:2])) {
          pareto <- FALSE
          break
        }
      }
      return(pareto)
    }

# Identify Pareto optimal solutions
sample2_pareto_optimal <- apply(df.sample[, 1:2], 1, is_pareto_optimal, data = df.sample)

# Extract Pareto optimal solutions
sample2_pareto_solutions <- df.sample[sample2_pareto_optimal, ]

I know that using NSGA-II would need you to specify objective functions, but I don't have these, instead I only have two columns of values representing my objective values (as shown in the sample data frame).

Upvotes: 0

Views: 35

Answers (0)

Related Questions