Last change
on this file since 10138 was
6152,
checked in by bfarka, 14 years ago
|
added ecj and custom statistics to communicate with the okb services #1441
|
File size:
1.9 KB
|
Rev | Line | |
---|
[6152] | 1 | /* |
---|
| 2 | Copyright 2006 by Sean Luke |
---|
| 3 | Licensed under the Academic Free License version 3.0 |
---|
| 4 | See the file "LICENSE" for more information |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | package ec.select; |
---|
| 9 | import ec.*; |
---|
| 10 | import ec.util.*; |
---|
| 11 | import ec.steadystate.*; |
---|
| 12 | |
---|
| 13 | /* |
---|
| 14 | * FirstSelection.java |
---|
| 15 | * |
---|
| 16 | * Created: Mon Aug 30 19:27:15 1999 |
---|
| 17 | * By: Sean Luke |
---|
| 18 | */ |
---|
| 19 | |
---|
| 20 | /** |
---|
| 21 | * Always picks the first individual in the subpopulation. This is mostly |
---|
| 22 | * for testing purposes. |
---|
| 23 | * |
---|
| 24 | |
---|
| 25 | <p><b>Default Base</b><br> |
---|
| 26 | select.first |
---|
| 27 | |
---|
| 28 | * |
---|
| 29 | * @author Sean Luke |
---|
| 30 | * @version 1.0 |
---|
| 31 | */ |
---|
| 32 | |
---|
| 33 | public class FirstSelection extends SelectionMethod implements SteadyStateBSourceForm |
---|
| 34 | { |
---|
| 35 | /** default base */ |
---|
| 36 | public static final String P_FIRST = "first"; |
---|
| 37 | |
---|
| 38 | public Parameter defaultBase() |
---|
| 39 | { |
---|
| 40 | return SelectDefaults.base().push(P_FIRST); |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | // I hard-code both produce(...) methods for efficiency's sake |
---|
| 44 | |
---|
| 45 | public int produce(final int subpopulation, |
---|
| 46 | final EvolutionState state, |
---|
| 47 | final int thread) |
---|
| 48 | { |
---|
| 49 | return 0; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | // I hard-code both produce(...) methods for efficiency's sake |
---|
| 54 | |
---|
| 55 | public int produce(final int min, |
---|
| 56 | final int max, |
---|
| 57 | final int start, |
---|
| 58 | final int subpopulation, |
---|
| 59 | final Individual[] inds, |
---|
| 60 | final EvolutionState state, |
---|
| 61 | final int thread) |
---|
| 62 | { |
---|
| 63 | int n = 1; |
---|
| 64 | if (n>max) n = max; |
---|
| 65 | if (n<min) n = min; |
---|
| 66 | |
---|
| 67 | for(int q = 0; q < n; q++) |
---|
| 68 | { |
---|
| 69 | // pick size random individuals, then pick the best. |
---|
| 70 | Individual[] oldinds = state.population.subpops[subpopulation].individuals; |
---|
| 71 | inds[start+q] = oldinds[0]; // note it's a pointer transfer, not a copy! |
---|
| 72 | } |
---|
| 73 | return n; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | public void individualReplaced(final SteadyStateEvolutionState state, |
---|
| 77 | final int subpopulation, |
---|
| 78 | final int thread, |
---|
| 79 | final int individual) |
---|
| 80 | { return; } |
---|
| 81 | |
---|
| 82 | public void sourcesAreProperForm(final SteadyStateEvolutionState state) |
---|
| 83 | { return; } |
---|
| 84 | |
---|
| 85 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.