EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.tcfmoop.terminationcriteria]

COVERAGE SUMMARY FOR SOURCE FILE [NoNewParetoOptimalCandidatesFoundCriterion.java]

nameclass, %method, %block, %line, %
NoNewParetoOptimalCandidatesFoundCriterion.java0%   (0/1)0%   (0/4)0%   (0/176)0%   (0/35)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NoNewParetoOptimalCandidatesFoundCriterion0%   (0/1)0%   (0/4)0%   (0/176)0%   (0/35)
NoNewParetoOptimalCandidatesFoundCriterion (IConfiguration, Population, Archi... 0%   (0/1)0%   (0/36)0%   (0/9)
evaluateImpl (int, long): void 0%   (0/1)0%   (0/84)0%   (0/17)
initializeOutputTree (): void 0%   (0/1)0%   (0/37)0%   (0/6)
updateOutputInformation (): void 0%   (0/1)0%   (0/19)0%   (0/3)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.tcfmoop.terminationcriteria;
5 
6import java.util.LinkedList;
7import java.util.List;
8 
9import org.opt4j.core.Archive;
10import org.opt4j.core.Individual;
11import org.opt4j.core.Population;
12 
13import de.uka.ipd.sdq.tcfmoop.config.IConfiguration;
14import de.uka.ipd.sdq.tcfmoop.config.NoNewParetoOptimalCandidatesFoundConfig;
15import de.uka.ipd.sdq.tcfmoop.outputtree.Node;
16import de.uka.ipd.sdq.tcfmoop.outputtree.Node.NodeType;
17 
18/**
19 * @author Atanas Dimitrov
20 *
21 */
22public class NoNewParetoOptimalCandidatesFoundCriterion extends
23                AbstractTerminationCriterion {
24        
25        //Denotes whether new pareto optimal candidates were found in the last iteration.
26        private boolean newParetoCandidatesFound = false;
27        //Required and current number of iterations without a newly found pareto optimal candidate.
28        private int requiredIterationsWithoutNewParetoOptimalCandidate;
29        private int currentIterationsWithoutNewParetoOptimalCandidate = 0;
30        //Local Archive of the already found pareto optimal candidates.
31        private List<Individual> localArchive = new LinkedList<Individual>();
32        
33        //OutputNodes
34        //dynamic
35        private Node generationsWithoutNewCandidate;
36 
37        public NoNewParetoOptimalCandidatesFoundCriterion(IConfiguration conf, Population population,
38                        Archive archive) {
39                super(conf, population, archive);
40                if((conf instanceof NoNewParetoOptimalCandidatesFoundConfig) && conf.validateConfiguration()){
41                        this.requiredIterationsWithoutNewParetoOptimalCandidate = ((NoNewParetoOptimalCandidatesFoundConfig)(conf)).getIterationsWithoutNewCandidates();
42                }else{
43                        throw new RuntimeException("NoNewParetoOptimalCandidatesFoundCriterion.initialize: " +
44                                        "wrong or invalid configuration object");
45                }
46                initializeOutputTree();
47        }
48        
49        private void initializeOutputTree(){
50                this.outputInformation.updateValue("No New Pareto Optimal Candidates Found");
51                this.outputInformation.getChildren().clear();
52                
53                this.generationsWithoutNewCandidate = this.outputInformation.addChild("No new pareto optimal candidate for: " + this.currentIterationsWithoutNewParetoOptimalCandidate + 
54                                "/" + this.requiredIterationsWithoutNewParetoOptimalCandidate + " generations", NodeType.PARAMETER);
55                this.outputInformation.getChildren().add(this.suggestedStop);
56        }
57        
58        /**
59         * {@inheritDoc}
60         * Implements the No New Pareto Optimal Candidates Found Criterion: This criterion tests the pareto optimal set
61         * for new found pareto optimal candidates. If no new pareto optimal candidates are found within n iterations
62         * it suggests a termination of the optimization.
63         */
64        @Override
65        public void evaluateImpl(int iteration, long currentTime) {
66                this.newParetoCandidatesFound = false;
67                
68                for(Individual indi : archive){
69                        if(!localArchive.contains(indi)){
70                                this.newParetoCandidatesFound = true;
71                                localArchive.add(indi);
72                        }
73                }
74                
75                //Clean the local archive
76                
77                List<Individual> individualsToRemove = new LinkedList<Individual>();
78                
79                for(Individual indi: this.localArchive){
80                        if(!archive.contains(indi)){
81                                individualsToRemove.add(indi);
82                        }
83                }
84                
85                this.localArchive.removeAll(individualsToRemove);
86                
87                if(!this.newParetoCandidatesFound){
88                        this.currentIterationsWithoutNewParetoOptimalCandidate++;
89                }else{
90                        this.currentIterationsWithoutNewParetoOptimalCandidate = 0;
91                }
92                
93                if(this.currentIterationsWithoutNewParetoOptimalCandidate == this.requiredIterationsWithoutNewParetoOptimalCandidate){
94                        this.evaluationResult = true;
95                }else{
96                        this.evaluationResult = false;
97                }
98                
99        }
100        
101        /**
102         * {@inheritDoc}
103         */
104        @Override
105        public void updateOutputInformation() {
106                this.generationsWithoutNewCandidate.updateValue("No new pareto optimal candidate for: " + this.currentIterationsWithoutNewParetoOptimalCandidate + 
107                                "/" + this.requiredIterationsWithoutNewParetoOptimalCandidate + " generations");
108        }
109 
110}

[all classes][de.uka.ipd.sdq.tcfmoop.terminationcriteria]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov