Last active
April 26, 2016 01:04
-
-
Save ahmedengu/15aa8913eebed13773bbabac480a4803 to your computer and use it in GitHub Desktop.
Sudoku Genetic Algorithm java
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
import java.util.Random; | |
public class GeneticOperators { | |
public static int[] initialize(int[] gene) { | |
int dimensions = (int) Math.sqrt(gene.length); | |
for (int i = 0; i < gene.length; i++) { | |
if (gene[i] == 0) gene[i] = new Random().nextInt(dimensions) + 1; | |
} | |
return gene; | |
} | |
public static int[] randomMutation(int[] gene) { | |
int dimensions = (int) Math.sqrt(gene.length); | |
int[] mutation = gene; | |
int rand = new Random().nextInt(gene.length); | |
for (int i = 0; i < rand; i++) | |
mutation = mutation(gene, new Random().nextInt(gene.length), new Random().nextInt(dimensions) + 1); | |
return mutation; | |
} | |
public static int[] mutation(int[] gene) { | |
int dimensions = (int) Math.sqrt(gene.length); | |
int[] mutation = mutation(gene, new Random().nextInt(gene.length), new Random().nextInt(dimensions) + 1); | |
return mutation; | |
} | |
public static int[] mutation(int[] gene, int index, int value) { | |
gene[index] = value; | |
return gene; | |
} | |
public static int[][] crossover(int[] gene1, int[] gene2) { | |
int start = new Random().nextInt(gene1.length); | |
int end = new Random().nextInt(gene1.length - start) + start; | |
return crossover(gene1, gene2, start, end); | |
} | |
public static int[][] crossover(int[] gene1, int[] gene2, boolean singlePoint) { | |
int start = (singlePoint) ? 0 : new Random().nextInt(gene1.length); | |
int end = new Random().nextInt(gene1.length - start) + start; | |
return crossover(gene1, gene2, start, end); | |
} | |
public static int[][] crossover(int[] gene1, int[] gene2, int start, int end) { | |
int[][] newGene = new int[2][gene1.length]; | |
for (int i = 0; i < gene1.length; i++) { | |
newGene[0][i] = (i >= start && i <= end) ? gene2[i] : gene1[i]; | |
newGene[1][i] = (i >= start && i <= end) ? gene1[i] : gene2[i]; | |
} | |
return newGene; | |
} | |
} |
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
import java.util.Random; | |
import java.util.Vector; | |
public class Main { | |
public static void main(String[] args) { | |
Random random = new Random(); | |
int populationSize = 50; | |
int maxIterations = 5000; | |
int iteration = 0; | |
Sudoku.setInitialGene(new int[]{1, 0, 0, 4, 0, 0, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0}); | |
Sudoku currentSudoku = new Sudoku(GeneticOperators.initialize(Sudoku.getInitialGene().clone())); | |
while (currentSudoku.getFitnessValue() != 0 && iteration < maxIterations) { | |
System.out.println("current: " + currentSudoku + ", iteration: " + iteration); | |
Vector<Sudoku> population = new Vector<>(); | |
for (int i = 0; i < populationSize; i++) population.add(new Sudoku(currentSudoku.getGene().clone())); | |
for (int i = 0; i < population.size(); i++) { | |
if (random.nextBoolean()) | |
population.get(i).mutation(); | |
else | |
population.get(i).crossover(population.get(random.nextInt(population.size()))); | |
} | |
if (random.nextBoolean()) | |
currentSudoku = Sudoku.bestSelection(population); | |
else | |
currentSudoku = Sudoku.rouletteSelection(population); | |
iteration++; | |
} | |
System.out.println("goal: " + currentSudoku + ", iteration: " + iteration); | |
} | |
} |
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
import java.util.Vector; | |
public class Sudoku { | |
private static int[] initialGene; | |
private int[] gene; | |
private int fitnessValue; | |
private double probability; | |
public Sudoku(int[] gene) { | |
this.gene = gene; | |
fitnessValue = fitness(); | |
} | |
public static Sudoku bestSelection(Vector<Sudoku> sudokus) { | |
Sudoku min = sudokus.firstElement(); | |
for (Sudoku sudoku : sudokus) | |
if (sudoku.fitnessValue < min.fitnessValue) | |
min = sudoku; | |
return min; | |
} | |
public static Sudoku rouletteSelection(Vector<Sudoku> sudokus) { | |
int max = 0; | |
for (Sudoku sudoku : sudokus) | |
if (sudoku.fitnessValue > max) max = sudoku.fitnessValue; | |
// int sum = 0; | |
// for (Sudoku sudoku : sudokus) | |
// sum += sudoku.getFitnessValue(); | |
// for (Sudoku sudoku : sudokus) | |
// sudoku.setProbability(sudoku.getFitnessValue() / (sum * 1.0)); | |
int sum = 0; | |
for (Sudoku sudoku : sudokus) | |
sum += max - sudoku.fitnessValue; | |
for (Sudoku sudoku : sudokus) | |
sudoku.setProbability((max - sudoku.fitnessValue) / (sum * 1.0)); | |
double random = Math.random() * sum; | |
int i; | |
for (i = 0; i < sudokus.size() && random > 0; i++) { | |
random -= max - sudokus.get(i).fitnessValue; | |
} | |
return sudokus.get(i - 1); | |
} | |
public void randomMutation() { | |
int[] mutation = GeneticOperators.randomMutation(this.getGene()); | |
this.setGene(mutation); | |
} | |
public void mutation() { | |
int[] mutation = GeneticOperators.mutation(this.getGene()); | |
this.setGene(mutation); | |
} | |
public void mutation(int index, int value) { | |
int[] mutation = GeneticOperators.mutation(this.getGene(), index, value); | |
this.setGene(mutation); | |
} | |
public static void randomMutation(Sudoku sudoku) { | |
int[] mutation = GeneticOperators.randomMutation(sudoku.getGene()); | |
sudoku.setGene(mutation); | |
} | |
public static void mutation(Sudoku sudoku) { | |
int[] mutation = GeneticOperators.mutation(sudoku.getGene()); | |
sudoku.setGene(mutation); | |
} | |
public static void mutation(Sudoku sudoku, int index, int value) { | |
int[] mutation = GeneticOperators.mutation(sudoku.getGene(), index, value); | |
sudoku.setGene(mutation); | |
} | |
public void crossover(Sudoku sudoku1, boolean singlePoint) { | |
int[][] crossover = GeneticOperators.crossover(this.getGene(), sudoku1.getGene(), singlePoint); | |
this.setGene(crossover[0]); | |
sudoku1.setGene(crossover[1]); | |
} | |
public void crossover(Sudoku sudoku1) { | |
int[][] crossover = GeneticOperators.crossover(this.getGene(), sudoku1.getGene()); | |
this.setGene(crossover[0]); | |
sudoku1.setGene(crossover[1]); | |
} | |
public void crossover(Sudoku sudoku1, int start, int end) { | |
int[][] crossover = GeneticOperators.crossover(this.getGene(), sudoku1.getGene(), start, end); | |
this.setGene(crossover[0]); | |
sudoku1.setGene(crossover[1]); | |
} | |
public static void crossover(Sudoku sudoku, Sudoku sudoku1, boolean singlePoint) { | |
int[][] crossover = GeneticOperators.crossover(sudoku.getGene(), sudoku1.getGene(), singlePoint); | |
sudoku.setGene(crossover[0]); | |
sudoku1.setGene(crossover[1]); | |
} | |
public static void crossover(Sudoku sudoku, Sudoku sudoku1) { | |
int[][] crossover = GeneticOperators.crossover(sudoku.getGene(), sudoku1.getGene()); | |
sudoku.setGene(crossover[0]); | |
sudoku1.setGene(crossover[1]); | |
} | |
public static void crossover(Sudoku sudoku, Sudoku sudoku1, int start, int end) { | |
int[][] crossover = GeneticOperators.crossover(sudoku.getGene(), sudoku1.getGene(), start, end); | |
sudoku.setGene(crossover[0]); | |
sudoku1.setGene(crossover[1]); | |
} | |
public int fitness() { | |
return fitness(this.gene); | |
} | |
public static int fitness(int[] gene) { | |
int fitness = 0; | |
int[][] newGene = oneDToTwoD(gene); | |
int[][] newInitialGene = oneDToTwoD(initialGene); | |
for (int i = 0; i < newGene.length; i++) { | |
boolean[] rowFlag = new boolean[newGene.length + 1]; | |
boolean[] colFlag = new boolean[newGene.length + 1]; | |
for (int j = 0; j < newGene.length; j++) { | |
if (rowFlag[newGene[i][j]]) | |
fitness++; | |
if (colFlag[newGene[j][i]]) | |
fitness++; | |
if ((newInitialGene[i][j] != 0 && newInitialGene[i][j] != newGene[i][j]) || newGene[i][j] == 0) | |
fitness += 1000; | |
rowFlag[newGene[i][j]] = true; | |
colFlag[newGene[j][i]] = true; | |
} | |
} | |
int blockSize = (int) Math.sqrt(newGene.length); | |
for (int i = 0; i < newGene.length; i += blockSize) { | |
for (int j = 0; j < newGene.length; j += blockSize) { | |
boolean[] blockFlag = new boolean[newGene.length + 1]; | |
for (int k = 0; k < blockSize; k++) { | |
for (int l = 0; l < blockSize; l++) { | |
if (blockFlag[newGene[i + k][j + l]]) | |
fitness++; | |
blockFlag[newGene[i + k][j + l]] = true; | |
} | |
} | |
} | |
} | |
return fitness; | |
} | |
public static int[] twoDToOneD(int[][] twoD) { | |
int[] oneD = new int[twoD.length * twoD.length]; | |
for (int i = 0; i < oneD.length; i++) | |
oneD[i] = twoD[i / twoD.length][i % twoD.length]; | |
return oneD; | |
} | |
public static int[][] oneDToTwoD(int[] oneD) { | |
int[][] twoD = new int[(int) Math.sqrt(oneD.length)][(int) Math.sqrt(oneD.length)]; | |
for (int i = 0; i < oneD.length; i++) | |
twoD[i / twoD.length][i % twoD.length] = oneD[i]; | |
return twoD; | |
} | |
public static int[] getInitialGene() { | |
return initialGene; | |
} | |
public static void setInitialGene(int[] initialGene) { | |
Sudoku.initialGene = initialGene; | |
} | |
public int[] getGene() { | |
return gene; | |
} | |
public void setGene(int[] gene) { | |
this.gene = gene; | |
fitnessValue = fitness(); | |
} | |
public int getFitnessValue() { | |
return fitnessValue; | |
} | |
public void setFitnessValue(int fitnessValue) { | |
this.fitnessValue = fitnessValue; | |
} | |
public double getProbability() { | |
return probability; | |
} | |
public void setProbability(double probability) { | |
this.probability = probability; | |
} | |
@Override | |
public String toString() { | |
String string = "Gene: "; | |
int dimensions = (int) Math.sqrt(gene.length); | |
for (int i : gene) { | |
string += i; | |
} | |
for (int i = 0; i < gene.length; i++) | |
string += ((i % dimensions == 0) ? "\n" : "") + gene[i] + " "; | |
string += "\nFitness: " + fitnessValue; | |
return string; | |
} | |
} |
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
current: Gene: 1334134243241432 | |
1 3 3 4 | |
1 3 4 2 | |
4 3 2 4 | |
1 4 3 2 | |
Fitness: 14, iteration: 0 | |
current: Gene: 1314134243241432 | |
1 3 1 4 | |
1 3 4 2 | |
4 3 2 4 | |
1 4 3 2 | |
Fitness: 13, iteration: 1 | |
current: Gene: 1314234243241432 | |
1 3 1 4 | |
2 3 4 2 | |
4 3 2 4 | |
1 4 3 2 | |
Fitness: 12, iteration: 2 | |
current: Gene: 1314214243241432 | |
1 3 1 4 | |
2 1 4 2 | |
4 3 2 4 | |
1 4 3 2 | |
Fitness: 11, iteration: 3 | |
current: Gene: 1314214243241432 | |
1 3 1 4 | |
2 1 4 2 | |
4 3 2 4 | |
1 4 3 2 | |
Fitness: 11, iteration: 4 | |
current: Gene: 1314224243241432 | |
1 3 1 4 | |
2 2 4 2 | |
4 3 2 4 | |
1 4 3 2 | |
Fitness: 12, iteration: 5 | |
current: Gene: 1314324243241432 | |
1 3 1 4 | |
3 2 4 2 | |
4 3 2 4 | |
1 4 3 2 | |
Fitness: 11, iteration: 6 | |
current: Gene: 1314324343241432 | |
1 3 1 4 | |
3 2 4 3 | |
4 3 2 4 | |
1 4 3 2 | |
Fitness: 10, iteration: 7 | |
current: Gene: 1314324343241432 | |
1 3 1 4 | |
3 2 4 3 | |
4 3 2 4 | |
1 4 3 2 | |
Fitness: 10, iteration: 8 | |
current: Gene: 1314324343241433 | |
1 3 1 4 | |
3 2 4 3 | |
4 3 2 4 | |
1 4 3 3 | |
Fitness: 12, iteration: 9 | |
current: Gene: 1314324343211433 | |
1 3 1 4 | |
3 2 4 3 | |
4 3 2 1 | |
1 4 3 3 | |
Fitness: 10, iteration: 10 | |
current: Gene: 1314324343211433 | |
1 3 1 4 | |
3 2 4 3 | |
4 3 2 1 | |
1 4 3 3 | |
Fitness: 10, iteration: 11 | |
current: Gene: 1314324343211432 | |
1 3 1 4 | |
3 2 4 3 | |
4 3 2 1 | |
1 4 3 2 | |
Fitness: 8, iteration: 12 | |
current: Gene: 1314324343211432 | |
1 3 1 4 | |
3 2 4 3 | |
4 3 2 1 | |
1 4 3 2 | |
Fitness: 8, iteration: 13 | |
current: Gene: 1314324343211432 | |
1 3 1 4 | |
3 2 4 3 | |
4 3 2 1 | |
1 4 3 2 | |
Fitness: 8, iteration: 14 | |
current: Gene: 1314323343211432 | |
1 3 1 4 | |
3 2 3 3 | |
4 3 2 1 | |
1 4 3 2 | |
Fitness: 10, iteration: 15 | |
current: Gene: 1314321343211432 | |
1 3 1 4 | |
3 2 1 3 | |
4 3 2 1 | |
1 4 3 2 | |
Fitness: 9, iteration: 16 | |
current: Gene: 1314321343211432 | |
1 3 1 4 | |
3 2 1 3 | |
4 3 2 1 | |
1 4 3 2 | |
Fitness: 9, iteration: 17 | |
current: Gene: 1314321343211432 | |
1 3 1 4 | |
3 2 1 3 | |
4 3 2 1 | |
1 4 3 2 | |
Fitness: 9, iteration: 18 | |
current: Gene: 1314421343211432 | |
1 3 1 4 | |
4 2 1 3 | |
4 3 2 1 | |
1 4 3 2 | |
Fitness: 8, iteration: 19 | |
current: Gene: 1314424343211432 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
1 4 3 2 | |
Fitness: 8, iteration: 20 | |
current: Gene: 1314424343211132 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
1 1 3 2 | |
Fitness: 9, iteration: 21 | |
current: Gene: 1314424343211132 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
1 1 3 2 | |
Fitness: 9, iteration: 22 | |
current: Gene: 1314424343211132 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
1 1 3 2 | |
Fitness: 9, iteration: 23 | |
current: Gene: 1314424343211132 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
1 1 3 2 | |
Fitness: 9, iteration: 24 | |
current: Gene: 1314424343212132 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
2 1 3 2 | |
Fitness: 7, iteration: 25 | |
current: Gene: 1314424343212132 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
2 1 3 2 | |
Fitness: 7, iteration: 26 | |
current: Gene: 1314424343212132 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
2 1 3 2 | |
Fitness: 7, iteration: 27 | |
current: Gene: 1314424343212134 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
2 1 3 4 | |
Fitness: 6, iteration: 28 | |
current: Gene: 1314424343212134 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
2 1 3 4 | |
Fitness: 6, iteration: 29 | |
current: Gene: 1314424343212134 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
2 1 3 4 | |
Fitness: 6, iteration: 30 | |
current: Gene: 1314424323212134 | |
1 3 1 4 | |
4 2 4 3 | |
2 3 2 1 | |
2 1 3 4 | |
Fitness: 8, iteration: 31 | |
current: Gene: 1314424323212134 | |
1 3 1 4 | |
4 2 4 3 | |
2 3 2 1 | |
2 1 3 4 | |
Fitness: 8, iteration: 32 | |
current: Gene: 1314424323212234 | |
1 3 1 4 | |
4 2 4 3 | |
2 3 2 1 | |
2 2 3 4 | |
Fitness: 11, iteration: 33 | |
current: Gene: 1314424323232234 | |
1 3 1 4 | |
4 2 4 3 | |
2 3 2 3 | |
2 2 3 4 | |
Fitness: 14, iteration: 34 | |
current: Gene: 1314424323232234 | |
1 3 1 4 | |
4 2 4 3 | |
2 3 2 3 | |
2 2 3 4 | |
Fitness: 14, iteration: 35 | |
current: Gene: 1314424343232234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 3 | |
2 2 3 4 | |
Fitness: 12, iteration: 36 | |
current: Gene: 1314424343222234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
2 2 3 4 | |
Fitness: 11, iteration: 37 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 38 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 39 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 40 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 41 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 42 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 43 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 44 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 45 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 46 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 47 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 48 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 49 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 50 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 51 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 52 | |
current: Gene: 1314424343221234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 10, iteration: 53 | |
current: Gene: 1314424343221232 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 2 | |
Fitness: 12, iteration: 54 | |
current: Gene: 1314424343221232 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 2 | |
1 2 3 2 | |
Fitness: 12, iteration: 55 | |
current: Gene: 1314424343241232 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 4 | |
1 2 3 2 | |
Fitness: 11, iteration: 56 | |
current: Gene: 1314424343211232 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
1 2 3 2 | |
Fitness: 9, iteration: 57 | |
current: Gene: 1314424343211232 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
1 2 3 2 | |
Fitness: 9, iteration: 58 | |
current: Gene: 1314424343213232 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
3 2 3 2 | |
Fitness: 10, iteration: 59 | |
current: Gene: 1314424343213232 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
3 2 3 2 | |
Fitness: 10, iteration: 60 | |
current: Gene: 1314424343213232 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
3 2 3 2 | |
Fitness: 10, iteration: 61 | |
current: Gene: 1314424343213234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
3 2 3 4 | |
Fitness: 9, iteration: 62 | |
current: Gene: 1314424343211234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 8, iteration: 63 | |
current: Gene: 1314424343211234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 8, iteration: 64 | |
current: Gene: 1314424343211234 | |
1 3 1 4 | |
4 2 4 3 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 8, iteration: 65 | |
current: Gene: 1314324343211234 | |
1 3 1 4 | |
3 2 4 3 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 8, iteration: 66 | |
current: Gene: 1414324343211234 | |
1 4 1 4 | |
3 2 4 3 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 67 | |
current: Gene: 1414324243211234 | |
1 4 1 4 | |
3 2 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 68 | |
current: Gene: 1414324243211234 | |
1 4 1 4 | |
3 2 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 69 | |
current: Gene: 1414324243211234 | |
1 4 1 4 | |
3 2 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 70 | |
current: Gene: 1414324243211234 | |
1 4 1 4 | |
3 2 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 71 | |
current: Gene: 1414324243211234 | |
1 4 1 4 | |
3 2 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 72 | |
current: Gene: 1414324243211234 | |
1 4 1 4 | |
3 2 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 73 | |
current: Gene: 1414324243211234 | |
1 4 1 4 | |
3 2 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 74 | |
current: Gene: 1414324243211234 | |
1 4 1 4 | |
3 2 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 75 | |
current: Gene: 1414324243211234 | |
1 4 1 4 | |
3 2 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 76 | |
current: Gene: 1414324243211234 | |
1 4 1 4 | |
3 2 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 77 | |
current: Gene: 1414314243211234 | |
1 4 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 78 | |
current: Gene: 1414314243211234 | |
1 4 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 79 | |
current: Gene: 1414314243211234 | |
1 4 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 80 | |
current: Gene: 1414344243211234 | |
1 4 1 4 | |
3 4 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 8, iteration: 81 | |
current: Gene: 1414314243211234 | |
1 4 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 82 | |
current: Gene: 1414314243211231 | |
1 4 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 1 | |
Fitness: 8, iteration: 83 | |
current: Gene: 1414314243211231 | |
1 4 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 1 | |
Fitness: 8, iteration: 84 | |
current: Gene: 1414314243211231 | |
1 4 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 1 | |
Fitness: 8, iteration: 85 | |
current: Gene: 1414314243211231 | |
1 4 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 1 | |
Fitness: 8, iteration: 86 | |
current: Gene: 1414314243211231 | |
1 4 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 1 | |
Fitness: 8, iteration: 87 | |
current: Gene: 1414314243211231 | |
1 4 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 1 | |
Fitness: 8, iteration: 88 | |
current: Gene: 1414314243211233 | |
1 4 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 3 | |
Fitness: 7, iteration: 89 | |
current: Gene: 1414314343211233 | |
1 4 1 4 | |
3 1 4 3 | |
4 3 2 1 | |
1 2 3 3 | |
Fitness: 9, iteration: 90 | |
current: Gene: 1114314343211233 | |
1 1 1 4 | |
3 1 4 3 | |
4 3 2 1 | |
1 2 3 3 | |
Fitness: 11, iteration: 91 | |
current: Gene: 1114314343211233 | |
1 1 1 4 | |
3 1 4 3 | |
4 3 2 1 | |
1 2 3 3 | |
Fitness: 11, iteration: 92 | |
current: Gene: 1214314343211233 | |
1 2 1 4 | |
3 1 4 3 | |
4 3 2 1 | |
1 2 3 3 | |
Fitness: 9, iteration: 93 | |
current: Gene: 1214314343211233 | |
1 2 1 4 | |
3 1 4 3 | |
4 3 2 1 | |
1 2 3 3 | |
Fitness: 9, iteration: 94 | |
current: Gene: 1214314343211233 | |
1 2 1 4 | |
3 1 4 3 | |
4 3 2 1 | |
1 2 3 3 | |
Fitness: 9, iteration: 95 | |
current: Gene: 1214314343211234 | |
1 2 1 4 | |
3 1 4 3 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 96 | |
current: Gene: 1214314343211234 | |
1 2 1 4 | |
3 1 4 3 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 97 | |
current: Gene: 1214314343211234 | |
1 2 1 4 | |
3 1 4 3 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 98 | |
current: Gene: 1214314343211234 | |
1 2 1 4 | |
3 1 4 3 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 99 | |
current: Gene: 1214314343211234 | |
1 2 1 4 | |
3 1 4 3 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 7, iteration: 100 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 101 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 102 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 103 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 104 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 105 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 106 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 107 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 108 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 109 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 110 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 111 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 112 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 113 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 114 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 115 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 116 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 117 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 118 | |
current: Gene: 1214314243211234 | |
1 2 1 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 119 | |
current: Gene: 1234314243211234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 120 | |
current: Gene: 1234314243221234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 9, iteration: 121 | |
current: Gene: 1234314243221234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 2 | |
1 2 3 4 | |
Fitness: 9, iteration: 122 | |
current: Gene: 1234314243211234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 123 | |
current: Gene: 1234314243211214 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 1 4 | |
Fitness: 7, iteration: 124 | |
current: Gene: 1234314243211234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 125 | |
current: Gene: 1234314243211234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 126 | |
current: Gene: 1234314243211234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 127 | |
current: Gene: 1234314243211234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 128 | |
current: Gene: 1234314243211234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 129 | |
current: Gene: 1234314243211234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 130 | |
current: Gene: 1234314243211234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 131 | |
current: Gene: 1234314243211234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 132 | |
current: Gene: 1234314243211234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
1 2 3 4 | |
Fitness: 6, iteration: 133 | |
current: Gene: 1234314243214234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
4 2 3 4 | |
Fitness: 8, iteration: 134 | |
current: Gene: 1234314243214234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
4 2 3 4 | |
Fitness: 8, iteration: 135 | |
current: Gene: 1234314243214234 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
4 2 3 4 | |
Fitness: 8, iteration: 136 | |
current: Gene: 1234314243214231 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
4 2 3 1 | |
Fitness: 8, iteration: 137 | |
current: Gene: 1234314243214231 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
4 2 3 1 | |
Fitness: 8, iteration: 138 | |
current: Gene: 1234314243214233 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
4 2 3 3 | |
Fitness: 8, iteration: 139 | |
current: Gene: 1234314243214233 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
4 2 3 3 | |
Fitness: 8, iteration: 140 | |
current: Gene: 1234314243214433 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
4 4 3 3 | |
Fitness: 9, iteration: 141 | |
current: Gene: 1234314243214233 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
4 2 3 3 | |
Fitness: 8, iteration: 142 | |
current: Gene: 1234314243214233 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
4 2 3 3 | |
Fitness: 8, iteration: 143 | |
current: Gene: 1234314243214243 | |
1 2 3 4 | |
3 1 4 2 | |
4 3 2 1 | |
4 2 4 3 | |
Fitness: 7, iteration: 144 | |
current: Gene: 1234311243214243 | |
1 2 3 4 | |
3 1 1 2 | |
4 3 2 1 | |
4 2 4 3 | |
Fitness: 6, iteration: 145 | |
current: Gene: 1234311243212243 | |
1 2 3 4 | |
3 1 1 2 | |
4 3 2 1 | |
2 2 4 3 | |
Fitness: 5, iteration: 146 | |
current: Gene: 1234311243212243 | |
1 2 3 4 | |
3 1 1 2 | |
4 3 2 1 | |
2 2 4 3 | |
Fitness: 5, iteration: 147 | |
current: Gene: 1234341243212243 | |
1 2 3 4 | |
3 4 1 2 | |
4 3 2 1 | |
2 2 4 3 | |
Fitness: 3, iteration: 148 | |
current: Gene: 1234341243212243 | |
1 2 3 4 | |
3 4 1 2 | |
4 3 2 1 | |
2 2 4 3 | |
Fitness: 3, iteration: 149 | |
current: Gene: 1234441243212243 | |
1 2 3 4 | |
4 4 1 2 | |
4 3 2 1 | |
2 2 4 3 | |
Fitness: 6, iteration: 150 | |
current: Gene: 1234441243211243 | |
1 2 3 4 | |
4 4 1 2 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 5, iteration: 151 | |
current: Gene: 1244441243211243 | |
1 2 4 4 | |
4 4 1 2 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 8, iteration: 152 | |
current: Gene: 1244341243211243 | |
1 2 4 4 | |
3 4 1 2 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 5, iteration: 153 | |
current: Gene: 1244321243211243 | |
1 2 4 4 | |
3 2 1 2 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 8, iteration: 154 | |
current: Gene: 1234321243211243 | |
1 2 3 4 | |
3 2 1 2 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 5, iteration: 155 | |
current: Gene: 1234321243211243 | |
1 2 3 4 | |
3 2 1 2 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 5, iteration: 156 | |
current: Gene: 1234341243211243 | |
1 2 3 4 | |
3 4 1 2 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 2, iteration: 157 | |
current: Gene: 1234341243211243 | |
1 2 3 4 | |
3 4 1 2 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 2, iteration: 158 | |
current: Gene: 1244341243211243 | |
1 2 4 4 | |
3 4 1 2 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 5, iteration: 159 | |
current: Gene: 1244341443211243 | |
1 2 4 4 | |
3 4 1 4 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 8, iteration: 160 | |
current: Gene: 1244341443211243 | |
1 2 4 4 | |
3 4 1 4 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 8, iteration: 161 | |
current: Gene: 1224341443211243 | |
1 2 2 4 | |
3 4 1 4 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 7, iteration: 162 | |
current: Gene: 1224341443211243 | |
1 2 2 4 | |
3 4 1 4 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 7, iteration: 163 | |
current: Gene: 1224341343211243 | |
1 2 2 4 | |
3 4 1 3 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 6, iteration: 164 | |
current: Gene: 1234341343211243 | |
1 2 3 4 | |
3 4 1 3 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 5, iteration: 165 | |
current: Gene: 1234341343211243 | |
1 2 3 4 | |
3 4 1 3 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 5, iteration: 166 | |
current: Gene: 1234341343211243 | |
1 2 3 4 | |
3 4 1 3 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 5, iteration: 167 | |
current: Gene: 1234341343211243 | |
1 2 3 4 | |
3 4 1 3 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 5, iteration: 168 | |
current: Gene: 1234341343211243 | |
1 2 3 4 | |
3 4 1 3 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 5, iteration: 169 | |
current: Gene: 1234341343211243 | |
1 2 3 4 | |
3 4 1 3 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 5, iteration: 170 | |
current: Gene: 1234341343211243 | |
1 2 3 4 | |
3 4 1 3 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 5, iteration: 171 | |
current: Gene: 1234341343211243 | |
1 2 3 4 | |
3 4 1 3 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 5, iteration: 172 | |
current: Gene: 1234341243211243 | |
1 2 3 4 | |
3 4 1 2 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 2, iteration: 173 | |
current: Gene: 1234341243211243 | |
1 2 3 4 | |
3 4 1 2 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 2, iteration: 174 | |
current: Gene: 1234341243231243 | |
1 2 3 4 | |
3 4 1 2 | |
4 3 2 3 | |
1 2 4 3 | |
Fitness: 5, iteration: 175 | |
current: Gene: 1234341243211243 | |
1 2 3 4 | |
3 4 1 2 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 2, iteration: 176 | |
current: Gene: 1234341243211243 | |
1 2 3 4 | |
3 4 1 2 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 2, iteration: 177 | |
current: Gene: 1234341243211243 | |
1 2 3 4 | |
3 4 1 2 | |
4 3 2 1 | |
1 2 4 3 | |
Fitness: 2, iteration: 178 | |
current: Gene: 1234341243213243 | |
1 2 3 4 | |
3 4 1 2 | |
4 3 2 1 | |
3 2 4 3 | |
Fitness: 4, iteration: 179 | |
current: Gene: 1234341243212243 | |
1 2 3 4 | |
3 4 1 2 | |
4 3 2 1 | |
2 2 4 3 | |
Fitness: 3, iteration: 180 | |
current: Gene: 1234341243212243 | |
1 2 3 4 | |
3 4 1 2 | |
4 3 2 1 | |
2 2 4 3 | |
Fitness: 3, iteration: 181 | |
goal: Gene: 1234341243212143 | |
1 2 3 4 | |
3 4 1 2 | |
4 3 2 1 | |
2 1 4 3 | |
Fitness: 0, iteration: 182 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment