Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. library(genalg)
  2.  
  3.  
  4. evalFunc <- function(x)
  5. {
  6. #x <- c(0,0,1,1)
  7. xx <- ""
  8.  
  9. for (a in 1:length(x))
  10. {
  11. xx <- paste(xx, x[a], sep="")
  12. }
  13. xx.val <- strtoi(xx, base=2)
  14. return(abs((xx.val-2)^2))
  15. }
  16.  
  17.  
  18. iter <- 100
  19. GAmodel <- rbga.bin(size = 16, popSize = 58, iters = iter, mutationChance = 0.01, elitism = T, evalFunc = evalFunc)
  20. cat(summary(GAmodel))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement