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

COVERAGE SUMMARY FOR SOURCE FILE [InsignificantParetoFrontChangeCriterionTest.java]

nameclass, %method, %block, %line, %
InsignificantParetoFrontChangeCriterionTest.java0%   (0/2)0%   (0/6)0%   (0/442)0%   (0/82)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class InsignificantParetoFrontChangeCriterionTest0%   (0/1)0%   (0/5)0%   (0/431)0%   (0/79)
InsignificantParetoFrontChangeCriterionTest (): void 0%   (0/1)0%   (0/106)0%   (0/16)
setUp (): void 0%   (0/1)0%   (0/124)0%   (0/24)
testInsignificantChange (): void 0%   (0/1)0%   (0/101)0%   (0/19)
testSignificantChange (): void 0%   (0/1)0%   (0/62)0%   (0/12)
testWithAnEmptyArchive (): void 0%   (0/1)0%   (0/38)0%   (0/8)
     
class InsignificantParetoFrontChangeCriterionTest$MyIndividual0%   (0/1)0%   (0/1)0%   (0/11)0%   (0/3)
InsignificantParetoFrontChangeCriterionTest$MyIndividual (InsignificantPareto... 0%   (0/1)0%   (0/11)0%   (0/3)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.tcfmoop.tests;
5 
6import static org.junit.Assert.*;
7 
8import java.util.HashSet;
9 
10import org.junit.Before;
11import org.junit.Test;
12import org.opt4j.common.archive.DefaultArchive;
13import org.opt4j.core.Archive;
14import org.opt4j.core.Individual;
15import org.opt4j.core.IndividualStateListener;
16import org.opt4j.core.Objective;
17import org.opt4j.core.Objectives;
18import org.opt4j.core.Objective.Sign;
19import org.opt4j.core.domination.ParetoDomination;
20 
21import de.uka.ipd.sdq.tcfmoop.config.InsignificantParetoFrontChangeConfig;
22import de.uka.ipd.sdq.tcfmoop.terminationcriteria.InsignificantParetoFrontChangeCriterion;
23 
24/**
25 * @author Atanas Dimitrov
26 *
27 */
28public class InsignificantParetoFrontChangeCriterionTest {
29        InsignificantParetoFrontChangeConfig ipfcconf;
30        InsignificantParetoFrontChangeCriterion ipfccrit;
31        
32        Archive archive = new DefaultArchive(); //empty
33 
34        Objectives o1 = new Objectives(new ParetoDomination());
35        Objectives o2 = new Objectives(new ParetoDomination());
36        Objectives o3 = new Objectives(new ParetoDomination());
37        Objectives o4 = new Objectives(new ParetoDomination());
38        Objectives o5 = new Objectives(new ParetoDomination());
39        Objectives o6 = new Objectives(new ParetoDomination());
40        
41        MyIndividual i1 = new MyIndividual();
42        MyIndividual i2 = new MyIndividual();
43        MyIndividual i3 = new MyIndividual();
44        MyIndividual i4 = new MyIndividual();
45        MyIndividual i5 = new MyIndividual();
46        MyIndividual i6 = new MyIndividual();
47        
48        Objective X = new Objective("X", Sign.MIN);
49        Objective Y = new Objective("Y", Sign.MIN);
50        
51        /**
52         * @throws java.lang.Exception
53         */
54        @Before
55        public void setUp() throws Exception {
56                
57                ipfcconf = new InsignificantParetoFrontChangeConfig();
58                
59                o1.add(X, 2);
60                o1.add(Y, 6);
61                
62                o2.add(X, 4);
63                o2.add(Y, 3);
64                                
65                o3.add(X, 6);
66                o3.add(Y, 1);
67                
68                o4.add(X, 8);
69                o4.add(Y, 0.5);
70                
71                //frontInsig
72                o5.add(X, 3);
73                o5.add(Y, 2);
74                
75                //frontSig
76                o6.add(X, 1);
77                o6.add(Y, 5);
78                
79                i1.setObjectives(o1);
80                i2.setObjectives(o2);
81                i3.setObjectives(o3);
82                i4.setObjectives(o4);
83                i5.setObjectives(o5);
84                i6.setObjectives(o6);
85                
86                
87                ipfcconf.setMinimumAllowedDifference(0.35);
88                ipfcconf.setPastIterationNumber(2);
89                if(!ipfcconf.validateConfiguration()){
90                        throw new Exception();
91                }
92                
93        }
94 
95        /**
96         * Test method for {@link de.uka.ipd.sdq.tcfmoop.terminationcriteria.AbstractTerminationCriterion#getEvaluationResult()}.
97         */
98        @Test
99        public void testWithAnEmptyArchive() {
100                
101                //Test with an empty archive
102                ipfccrit = new InsignificantParetoFrontChangeCriterion(ipfcconf, null, archive);
103                ipfccrit.evaluate(0, 0);
104                assertFalse(ipfccrit.getEvaluationResult());
105                ipfccrit.evaluate(0, 0);
106                assertFalse(ipfccrit.getEvaluationResult());
107                ipfccrit.evaluate(0, 0);
108                assertTrue(ipfccrit.getEvaluationResult());
109                
110        }
111        
112        @Test
113        public void testInsignificantChange() {
114                //Test insignificant front
115                //Init archive
116                
117                this.archive.add(i1);
118                this.archive.add(i2);
119                this.archive.add(i3);
120                this.archive.add(i4);
121                
122                ipfccrit = new InsignificantParetoFrontChangeCriterion(ipfcconf, null, archive);
123                ipfccrit.evaluate(0, 0);
124                assertFalse(ipfccrit.getEvaluationResult());
125                ipfccrit.evaluate(0, 0);
126                assertFalse(ipfccrit.getEvaluationResult());
127                
128                //Make an insignificant change in the archive
129                
130                archive.remove(i2);
131                archive.add(i5);
132                
133                ipfccrit.evaluate(0, 0);
134                assertTrue(ipfccrit.getEvaluationResult());
135                
136                //Roll back the archive
137                
138                archive.clear();
139                this.archive.add(i1);
140                this.archive.add(i2);
141                this.archive.add(i3);
142                this.archive.add(i4);
143                
144        }
145        
146        @Test
147        public void testSignificantChange() {
148                
149                //Test significant front
150                ipfccrit = new InsignificantParetoFrontChangeCriterion(ipfcconf, null, archive);
151                ipfccrit.evaluate(0, 0);
152                assertFalse(ipfccrit.getEvaluationResult());
153                ipfccrit.evaluate(0, 0);
154                assertFalse(ipfccrit.getEvaluationResult());
155                
156                //Make a significant change to the archive
157                archive.remove(i1);
158                archive.remove(i2);
159                archive.add(i5);
160                archive.add(i6);
161                
162                ipfccrit.evaluate(0, 0);
163                assertFalse(ipfccrit.getEvaluationResult());
164                
165        }
166        
167        public class MyIndividual extends Individual{
168                public MyIndividual(){
169                        this.setIndividualStatusListeners(new HashSet<IndividualStateListener>());
170                }
171        }
172 
173}

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