Created
June 18, 2015 22:56
-
-
Save cbedoy/32c1394511c696454410 to your computer and use it in GitHub Desktop.
Some utils by usage chromosomes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package self.cbedoy.utils; | |
/** | |
* Created by Carlos Bedoy on 17/06/2015. | |
* | |
*/ | |
public class Utils | |
{ | |
public static void printChromosomeWithTitle(int[] chromosome, String title){ | |
System.out.println(); | |
System.out.println(title); | |
for (int index = 0 ; index < chromosome.length; index++){ | |
System.out.print(chromosome[index] + " - "); | |
} | |
} | |
public static int[] removeOnesFromChromosome(int[] chromosome){ | |
int[] newChromosome = new int[chromosome.length - 2]; | |
System.arraycopy(chromosome, 1, newChromosome, 0, newChromosome.length); | |
return newChromosome; | |
} | |
public static int[] fillWithLessOnesToChromosome(int[] chromosome) { | |
int[] newChromosome = new int[chromosome.length + 2]; | |
newChromosome[0] = 1; | |
System.arraycopy(chromosome, 0, newChromosome, 1, newChromosome.length - 1 - 1); | |
newChromosome[newChromosome.length - 1] = 1; | |
return newChromosome; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment