Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public Population getElite(int n){
  2. Individual po[]=new Individual[n];
  3. if (n==1){
  4. po[1]=bestInd;
  5. return new Population(po);
  6. }else{
  7. Individual p[]=new Individual[n];;
  8. pop.toArray(p);
  9. for (int i = p.length - 1; i >= 1; i--) {
  10. for (int j = 1; j <= i; j++) {
  11. if (p[j - 1].compareTo(p[j])>0) {
  12. Individual aux = p[j];
  13. p[j] = p[j - 1];
  14. p[j - 1] = aux;
  15. }
  16. }
  17. }
  18. for(int i=0;i<n;i++)
  19. p[i]=po[i];
  20. return new Population(po);
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement