KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > distr > Problem


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 org.jgap.distr;
11
12 import org.jgap.*;
13
14 /**
15  * A problem to be solved by a worker.
16  *
17  * @author Klaus Meffert
18  * @since 3.0
19  */

20 public class Problem {
21   /** String containing the CVS revision. Read out via reflection!*/
22   private final static String JavaDoc CVS_REVISION = "$Revision: 1.2 $";
23
24   private FitnessFunction m_fitFunc;
25
26   private int m_populationSize;
27
28   private Object JavaDoc m_ID;
29
30   private Chromosome[] m_initialChroms;
31
32   public Problem() {
33   }
34
35   /**
36    * @param a_fitFunc the fitness function to use
37    * @param a_popSize the population size to use by/suggest to the worker
38    * @param a_initialChroms initial chromosomes to use (e.g. from previous
39    * evolutions), or empty
40    * @throws IllegalArgumentException
41    *
42    * @author Klaus Meffert
43    * @since 3.0
44    */

45   public Problem(FitnessFunction a_fitFunc, int a_popSize,
46                  Chromosome[] a_initialChroms) throws IllegalArgumentException JavaDoc {
47     if (a_fitFunc == null) {
48       throw new IllegalArgumentException JavaDoc("Fitness function must not be null!");
49     }
50     if (a_popSize <= 0) {
51       throw new IllegalArgumentException JavaDoc("Population size must be greater zero.");
52     }
53     m_fitFunc = a_fitFunc;
54     m_populationSize = a_popSize;
55     m_initialChroms = a_initialChroms;
56   }
57
58   /**
59    * @param a_ID internal ID of the problem, should be unique
60    *
61    * @author Klaus Meffert
62    * @since 3.0
63    */

64   public void setID(Object JavaDoc a_ID) {
65     m_ID = a_ID;
66   }
67
68   /**
69    * @return internal ID of the problem, should be unique
70    *
71    * @author Klaus Meffert
72    * @since 3.0
73    */

74   public Object JavaDoc getID() {
75     return m_ID;
76   }
77
78   /**
79    * @return population size to use
80    *
81    * @author Klaus Meffert
82    * @since 3.0
83    */

84   public int getPopulationSize() {
85     return m_populationSize;
86   }
87
88   /**
89    * @return FitnessFunction to use
90    *
91    * @author Klaus Meffert
92    * @since 3.0
93    */

94   public FitnessFunction getFitnessFunction() {
95     return m_fitFunc;
96   }
97
98   /**
99    * @return Chromosome[] initial chromosomes to use, may be empty
100    *
101    * @author Klaus Meffert
102    * @since 3.0
103    */

104   public Chromosome[] getChromosomes() {
105     return m_initialChroms;
106   }
107 }
108
Popular Tags