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

Last change on this file since 28 was 28, checked in by mszubert, 15 years ago

cecj - coEvolutionary Computation in Java with additional games package

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 1.3 KB
Line 
1package cecj.archive;
2
3import java.util.ArrayList;
4import java.util.List;
5
6import ec.EvolutionState;
7import ec.Individual;
8
9public class IPCArchive extends ParetoCoevolutionArchive {
10
11        @Override
12        protected void submit(EvolutionState state, List<Individual> candidates,
13                        List<Individual> cArchive, List<Individual> tests, List<Individual> tArchive) {
14                List<Individual> testsCopy = new ArrayList<Individual>(tests);
15                List<Individual> usefulTests;
16
17                /*
18                 * Is is a right sequence of operations? Dominated candidates are eliminated before new
19                 * tests are added to the test archive. New tests can make yet another candidate dominated..
20                 */
21                for (Individual candidate : candidates) {
22                        if (isUseful(state, candidate, cArchive, tArchive, testsCopy)) {
23                                usefulTests = findUsefulTests(state, candidate, cArchive, tArchive, testsCopy);
24                                eliminateDominatedCandidates(state, candidate, cArchive, tArchive);
25
26                                cArchive.add(candidate);
27                                tArchive.addAll(usefulTests);
28                                testsCopy.removeAll(usefulTests);
29                        }
30                }
31        }
32
33        private void eliminateDominatedCandidates(EvolutionState state, Individual candidate,
34                        List<Individual> candidateArchive, List<Individual> testArchive) {
35                for (int c = candidateArchive.size() - 1; c >= 0; c--) {
36                        if (dominates(state, candidate, candidateArchive.get(c), testArchive)) {
37                                candidateArchive.remove(c);
38                        }
39                }
40        }
41}
Note: See TracBrowser for help on using the repository browser.