vohai611 / cvrp-genetic

Solve cvrp by genetic algorithm from GA package
1 stars 0 forks source link

Error when running genetic algorithm #1

Open Destaq opened 2 years ago

Destaq commented 2 years ago

I have installed the R project locally along with all of its packages. The nearest-neighbor and simulated annealing algorithms are working perfectly, but when trying to run the genetic algorithm, I get the following error message:

Warning: Error in gaperm_oxCrossover_Rcpp: index error
  172: <Anonymous>

This also shows up in the web app instead of a graph.

Is there any solution to this?

vohai611 commented 2 years ago

Do you run this app on M1? if so you can try

gaControl("useRcpp" = FALSE)

as report here

Destaq commented 2 years ago

I am indeed running on M1. However, adding the line of code above gives a new error message and the GA still does not work:

── Conflicts ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
vohai611 commented 2 years ago

This is a warning message of name space conflic rather than error message.

Destaq commented 2 years ago

When placing this line in the code, in the file test-ga.R, as so:

# generate initial population
suggest_pop = suggest_random_nn(100, capacity = df$capacity ,demand = df$file$demand,distance = df$distance)

# run GA
library(GA)

gaControl("useRcpp" = FALSE)

As you suggested, the original error shows up again:

Warning: Error in gaperm_oxCrossover_Rcpp: index error
  172: <Anonymous>

and there is not even a Run button available. So this is not a solution. Any other suggestions?

image