aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/modules/ea/TournamentSelection.java
blob: baf6704373067b1a7f006fb849e2bbf5f24ea57b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package jcgp.backend.modules.ea;

import java.util.HashMap;

import jcgp.backend.modules.mutator.Mutator;
import jcgp.backend.population.Population;
import jcgp.backend.resources.Resources;
import jcgp.backend.resources.parameters.IntegerParameter;
import jcgp.backend.resources.parameters.Parameter;

public class TournamentSelection implements EvolutionaryAlgorithm {
	
	private int fittestChromosome;
	
	private IntegerParameter tournament;
	private HashMap<String, Parameter> localParameters;
	
	public TournamentSelection() {		
		tournament = new IntegerParameter(1, "Tournament size") {
			@Override
			public void validate(int newValue) {
				// TODO this
			}
		};
		
		localParameters = new HashMap<String, Parameter>();
		localParameters.put("tournament", tournament);
	}

	@Override
	public Parameter[] getLocalParameters() {
		return new Parameter[] {tournament};
	}

	@Override
	public void evolve(Population population, Mutator mutator,
			Resources parameters) {
		tournament.set(tournament.get() + 1);
		fittestChromosome = 0;
		// TODO implement this

	}

	@Override
	public int getFittestChromosome() {
		return fittestChromosome;
	}
	
	@Override
	public String toString() {
		return "Tournament";
	}
}