I have a set of 31390 individuals with an associated weight (kg) and I want to select a number of them such that the maximum weight is 3000kgs and that the weight distribution around several variables describing the sample are close to some targets.I was approaching the problem by considering each individual as a gene of a chromosome and then multiplying the chromosome by the weight of the sample. In this case 1 is for being included in the sample while 0 is being excluded from the sample.I followed the example used in https://www.r-bloggers.com/genetic-algorithms-a-simple-r-example/ although my constraint is different as I want to minimize the difference between the weight distribution I get from the selected sample and my target. Taking 1000 iterations and populations of 50 and 100 I don't get satisfactory solutions. I have read that people take populations that are (# genes)^2 but I will run out of memory if I take a population of that size.I think crossover could help but it seems as if the genalg library only uses mutation.Any suggestions on how to solve the problem? Thanks. I have posted the code belowWeight.Limit<-30*100evalFunc <- function(x) {  current_weight <- as.numeric(x %*% ind.data$weight)  sample.dist<-x %*% as.matrix(ind.data[,4:ncol(ind.data)])/current_weight  current_solution_dist <-  sum(sqrt(abs(constraints.data-sample.dist)))  if (current_weight> Weight.Limit)     return(0) else return(current_solution_dist)}GAmodel <- rbga.bin(size = 31390, popSize = PopSize, iters = iter, mutationChance = MutationChance, elitism = T, evalFunc = evalFunc)cat(summary(GAmodel))
selecting sample from population using genetic algorithm
r;genetic algorithms