Last change
on this file since 28 was
28,
checked in by mszubert, 16 years ago
|
cecj - coEvolutionary Computation in Java with additional games package
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Id Revision
|
File size:
1.2 KB
|
Line | |
---|
1 | package cecj.eval; |
---|
2 | |
---|
3 | import cecj.problems.CoevolutionaryProblem; |
---|
4 | import cecj.problems.TestBasedProblem; |
---|
5 | import ec.Evaluator; |
---|
6 | import ec.EvolutionState; |
---|
7 | import ec.util.Parameter; |
---|
8 | |
---|
9 | /** |
---|
10 | * The base class for all coevolutionary evaluators. |
---|
11 | * |
---|
12 | * @author Marcin Szubert |
---|
13 | * |
---|
14 | */ |
---|
15 | public abstract class CoevolutionaryEvaluator extends Evaluator { |
---|
16 | |
---|
17 | private static final String P_POP = "pop"; |
---|
18 | private static final String P_SIZE = "subpops"; |
---|
19 | |
---|
20 | /** |
---|
21 | * Number of subpopulations. |
---|
22 | */ |
---|
23 | protected int numSubpopulations; |
---|
24 | |
---|
25 | @Override |
---|
26 | public void setup(final EvolutionState state, final Parameter base) { |
---|
27 | super.setup(state, base); |
---|
28 | |
---|
29 | if (!(p_problem instanceof CoevolutionaryProblem)) { |
---|
30 | state.output |
---|
31 | .fatal("Coevolutionary evaluator is dedicated to coevolutionary problems\n"); |
---|
32 | } |
---|
33 | |
---|
34 | Parameter popSizeParameter = new Parameter(P_POP).push(P_SIZE); |
---|
35 | numSubpopulations = state.parameters.getInt(popSizeParameter, null, 0); |
---|
36 | if (numSubpopulations <= 0) { |
---|
37 | state.output.fatal("Population size must be > 0.\n", popSizeParameter); |
---|
38 | } |
---|
39 | } |
---|
40 | |
---|
41 | @Override |
---|
42 | public boolean runComplete(EvolutionState state) { |
---|
43 | return false; |
---|
44 | } |
---|
45 | |
---|
46 | public TestBasedProblem getProblem() { |
---|
47 | return (TestBasedProblem) p_problem; |
---|
48 | } |
---|
49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.