Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Population getElite(int n){
- Individual po[]=new Individual[n];
- if (n==1){
- po[1]=bestInd;
- return new Population(po);
- }else{
- Individual p[]=new Individual[n];;
- pop.toArray(p);
- for (int i = p.length - 1; i >= 1; i--) {
- for (int j = 1; j <= i; j++) {
- if (p[j - 1].compareTo(p[j])>0) {
- Individual aux = p[j];
- p[j] = p[j - 1];
- p[j - 1] = aux;
- }
- }
- }
- for(int i=0;i<n;i++)
- p[i]=po[i];
- return new Population(po);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement