conf.set(EvalMapper.MAHOUT_GA_EVALUATOR, StringUtils.toString(evaluator));
mapper.configure(conf);
// evaluate the population using the mapper
for (int index = 0; index < population.size(); index++) {
DummyCandidate candidate = population.get(index);
mapper.map(new LongWritable(index), new Text(StringUtils
.toString(candidate)), collector, null);
}
// check that the evaluations are correct
Set<String> keys = collector.getKeys();
assertEquals("Number of evaluations", populationSize, keys.size());
for (String key : keys) {
DummyCandidate candidate = population.get(Integer.parseInt(key));
assertEquals("Values for key " + key, 1, collector.getValue(key).size());
double fitness = collector.getValue(key).get(0).get();
assertEquals("Evaluation of the candidate " + key, DummyEvaluator
.getFitness(candidate.getIndex()), fitness);
}
}