View Javadoc
1   package com.delhezi.ga.crossover.standard;
2   
3   import com.delhezi.ga.Chromosome;
4   import com.delhezi.ga.ChromosomeProperties;
5   import com.delhezi.ga.exception.GeneticAlgorithmException;
6   
7   import org.junit.After;
8   import org.junit.AfterClass;
9   import static org.junit.Assert.*;
10  import org.junit.Before;
11  import org.junit.BeforeClass;
12  import org.junit.Test;
13  
14  public class UniformCrossoverTest {
15      public UniformCrossoverTest() {
16      }
17  
18      @Before
19      public void setUp() throws Exception {
20      }
21  
22      @After
23      public void tearDown() throws Exception {
24      }
25  
26      @BeforeClass
27      public static void setUpBeforeClass() throws Exception {
28      }
29  
30      @AfterClass
31      public static void tearDownAfterClass() throws Exception {
32      }
33  
34      /**
35       * @see UniformCrossover#crossover(com.delhezi.ga.Chromosome,com.delhezi.ga.Chromosome)
36       */
37      @Test
38      public void testCrossover() {
39        System.out.println("crossover");
40        ChromosomeProperties chromosomeProperties = ChromosomeProperties.getInstance();
41        //TODO zamockowac geny
42        Integer[] genes1 = {6, 11, 8, 5, 9, 7, 1, 4, 10, 2, 3};
43        Chromosome<Integer> chromosome1 =
44                new Chromosome<Integer>(genes1, chromosomeProperties);
45  
46        Integer[] genes2 = {5, 11, 3, 9, 8, 6, 7, 1, 10, 4, 2};
47        Chromosome<Integer> chromosome2 =
48                new Chromosome<Integer>(genes2, chromosomeProperties);
49  
50          UniformCrossover instance = new UniformCrossover();
51          instance.crossover(chromosome1, chromosome2);
52  
53          //for (int i = 0; i < genes1.length; i++) {
54          //    System.out.println("getGene(" + i + ") = " +
55          //                       chromosome1.getGene(i).toString());
56          //}
57  
58          //for (int i = 0; i < genes2.length; i++) {
59          //    System.out.println("getGene(" + i + ") = " +
60          //                       chromosome2.getGene(i).toString());
61          //}
62      }
63  }