Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKBJavaConnector/ECJClient/src/ec/parsimony/LexicographicTournamentSelection.java @ 13229

Last change on this file since 13229 was 6152, checked in by bfarka, 14 years ago

added ecj and custom statistics to communicate with the okb services #1441

File size: 2.0 KB
Line 
1/*
2  Copyright 2006 by Sean Luke and George Mason University
3  Licensed under the Academic Free License version 3.0
4  See the file "LICENSE" for more information
5*/
6
7
8package ec.parsimony;
9
10import ec.*;
11import ec.util.*;
12import ec.steadystate.*;
13import ec.select.*;
14
15/*
16 * LexicographicTournamentSelection.java
17 *
18 * Created: Mon Aug 30 19:27:15 1999
19 * By: Liviu Panait & Sean Luke
20 */
21
22/**
23 * Does a simple tournament selection, limited to the subpopulation it's
24 * working in at the time.
25 *
26 * <p>Tournament selection works like this: first, <i>size</i> individuals
27 * are chosen at random from the population.  Then of those individuals,
28 * the one with the best fitness is selected.  If two individuals have the
29 * same fitness, the one with smaller size is prefered.
30 *
31 * The default tournament size is 7.
32 *
33 *
34
35 <p><b>Typical Number of Individuals Produced Per <tt>produce(...)</tt> call</b><br>
36 Always 1.
37
38 <p><b>Parameters</b><br>
39 <table>
40 <tr><td valign=top><i>base.</i><tt>size</tt><br>
41 <font size=-1>int &gt;= 1</font></td>
42 <td valign=top>(the tournament size)</td></tr>
43
44 <tr><td valign=top><i>base.</i><tt>pick-worst</tt><br>
45 <font size=-1> bool = <tt>true</tt> or <tt>false</tt> (default)</font></td>
46 <td valign=top>(should we pick the <i>worst</i> individual in the tournament instead of the <i>best</i>?)</td></tr>
47
48 </table>
49
50 <p><b>Default Base</b><br>
51 select.lexicographic-tournament
52
53 *
54 * @author Sean Luke
55 * @version 1.0
56 */
57
58public class LexicographicTournamentSelection extends TournamentSelection
59    {
60    /** default base */
61    public static final String P_TOURNAMENT = "lexicographic-tournament";
62
63    public Parameter defaultBase()
64        {
65        return SelectDefaults.base().push(P_TOURNAMENT);
66        }
67   
68    public boolean betterThan(Individual first, Individual second, int subpopulation, EvolutionState state, int thread)
69        {
70        return (first.fitness.betterThan(second.fitness) ||
71            (first.fitness.equivalentTo(second.fitness) && first.size() < second.size()));
72        }
73               
74    }
Note: See TracBrowser for help on using the repository browser.