01: /*
02: * This file is part of JGAP.
03: *
04: * JGAP offers a dual license model containing the LGPL as well as the MPL.
05: *
06: * For licensing information please see the file license.txt included with JGAP
07: * or have a look at the top of class org.jgap.Chromosome which representatively
08: * includes the JGAP license policy applicable for any file delivered with JGAP.
09: */
10: package examples.supergene;
11:
12: import org.jgap.*;
13: import org.jgap.impl.*;
14: import org.jgap.super genes.*;
15:
16: /**
17: * Supergene to hold pennies and nickels. Valid if the number of
18: * nickels and pennies is either both odd or both even.
19: *
20: * @author Audrius Meskauskas
21: * @since 2.0
22: */
23: public class NickelsPenniesSupergene extends AbstractSupergene {
24: /** String containing the CVS revision. Read out via reflection!*/
25: private final static String CVS_REVISION = "$Revision: 1.3 $";
26:
27: /**
28: * Default constructor for dynamic instantiation
29: *
30: * @throws InvalidConfigurationException
31: *
32: * @author Klaus Meffert
33: * @since 3.0
34: */
35: public NickelsPenniesSupergene()
36: throws InvalidConfigurationException {
37: super ();
38: }
39:
40: public NickelsPenniesSupergene(final Configuration a_conf)
41: throws InvalidConfigurationException {
42: super (a_conf);
43: }
44:
45: public NickelsPenniesSupergene(final Configuration a_conf,
46: Gene[] a_genes) throws InvalidConfigurationException {
47: super (a_conf, a_genes);
48: }
49:
50: public boolean isValid(Gene[] a_genes, Supergene a_super gene) {
51: IntegerGene nickels = (IntegerGene) a_genes[0];
52: IntegerGene pennies = (IntegerGene) a_genes[1];
53: boolean valid = nickels.intValue() % 2 == pennies.intValue() % 2;
54: return valid;
55: }
56: }
|