source: java/ecj/cecj/archive/IPCArchive.java @ 521

Last change on this file since 521 was 193, checked in by Maciej Komosinski, 11 years ago

Set svn:eol-style native for all textual files

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1/*
2  Copyright 2009 by Marcin Szubert
3  Licensed under the Academic Free License version 3.0
4 */
5
6package cecj.archive;
7
8import java.util.ArrayList;
9import java.util.List;
10
11import ec.EvolutionState;
12import ec.Individual;
13
14/**
15 * Incremental Pareto-Coevolution Archive.
16 *
17 * For each of the submitted candidates it is checked if any useful test exists in the archive or
18 * currently submitted population, that proves the candidate is non-dominated. If such test is
19 * found, the considered individual is added to the archive while all individuals that it dominates
20 * are removed.
21 *
22 * The implementation relies heavily on the methods provided by the superclass Ð
23 * <code>PareroCoevolutionArchive</code>.
24 *
25 * @author Marcin Szubert
26 *
27 */
28public class IPCArchive extends ParetoCoevolutionArchive {
29
30        @Override
31        protected void submit(EvolutionState state, List<Individual> candidates,
32                        List<Individual> cArchive, List<Individual> tests, List<Individual> tArchive) {
33                List<Individual> testsCopy = new ArrayList<Individual>(tests);
34                List<Individual> usefulTests;
35
36                /*
37                 * Is is a right sequence of operations? Dominated candidates are eliminated before new
38                 * tests are added to the test archive. New tests can make yet another candidate dominated..
39                 */
40                for (Individual candidate : candidates) {
41                        if (isUseful(state, candidate, cArchive, tArchive, testsCopy)) {
42                                usefulTests = findUsefulTests(state, candidate, cArchive, tArchive, testsCopy);
43                                eliminateDominatedCandidates(state, candidate, cArchive, tArchive);
44
45                                cArchive.add(candidate);
46                                tArchive.addAll(usefulTests);
47                                testsCopy.removeAll(usefulTests);
48                        }
49                }
50        }
51
52        private void eliminateDominatedCandidates(EvolutionState state, Individual candidate,
53                        List<Individual> candidateArchive, List<Individual> testArchive) {
54                for (int c = candidateArchive.size() - 1; c >= 0; c--) {
55                        if (dominates(state, candidate, candidateArchive.get(c), testArchive)) {
56                                candidateArchive.remove(c);
57                        }
58                }
59        }
60}
Note: See TracBrowser for help on using the repository browser.