KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > examples > supergene > SupergeneSampleApplicationTest


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

10 package examples.supergene;
11
12 import junit.framework.*;
13 import org.jgap.*;
14 import org.jgap.supergenes.*;
15
16 /**
17  * Test Supergene sample application, verifying the "make change"
18  * supergene and non-supergene versions. Both must return a zero error.
19  * Performance is not verified.
20  *
21  * @author Meskauskas Audrius
22  * @since 2.0
23  */

24 public class SupergeneSampleApplicationTest
25     extends JGAPTestCase {
26   /** String containing the CVS revision. Read out via reflection!*/
27   private final static String JavaDoc CVS_REVISION = "$Revision: 1.1 $";
28
29   public void testSupergeneTotal() {
30     int E_s = Integer.MAX_VALUE;
31     Test:
32         for (int i = 0; i < 2; i++) {
33       AbstractSupergeneTest.EXISTING_SOLUTIONS_ONLY = true;
34       AbstractSupergeneTest.REPORT_ENABLED = false;
35       Force.REPORT_ENABLED = false;
36       AbstractSupergeneTest.MAX_ALLOWED_EVOLUTIONS = 512;
37       AbstractSupergeneTest.POPULATION_SIZE = 256;
38       AbstractSupergene.reset();
39       E_s = new SupergeneSample().test();
40       if (E_s == 0) {
41         break Test;
42       }
43       assertTrue("Correctness of solution: supergene " + E_s, E_s < 3);
44     }
45     assertTrue("Correctness of solution: supergene " + E_s, E_s == 0);
46   }
47
48   public static Test suite() {
49     TestSuite suite =
50         new TestSuite(SupergeneSampleApplicationTest.class);
51     return suite;
52   }
53 }
54
Popular Tags