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 [ParetoOptimalSetStabilityCriterionTest.java]

nameclass, %method, %block, %line, %
ParetoOptimalSetStabilityCriterionTest.java0%   (0/2)0%   (0/5)0%   (0/552)0%   (0/104)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ParetoOptimalSetStabilityCriterionTest0%   (0/1)0%   (0/4)0%   (0/541)0%   (0/101)
ParetoOptimalSetStabilityCriterionTest (): void 0%   (0/1)0%   (0/92)0%   (0/14)
setUp (): void 0%   (0/1)0%   (0/139)0%   (0/27)
testExactNumbersMode (): void 0%   (0/1)0%   (0/148)0%   (0/28)
testPercentageMode (): void 0%   (0/1)0%   (0/162)0%   (0/32)
     
class ParetoOptimalSetStabilityCriterionTest$MyIndividual0%   (0/1)0%   (0/1)0%   (0/11)0%   (0/3)
ParetoOptimalSetStabilityCriterionTest$MyIndividual (ParetoOptimalSetStabilit... 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.ParetoOptimalSetStabilityConfig;
22import de.uka.ipd.sdq.tcfmoop.config.ParetoOptimalSetStabilityConfig.EvaluationMode;
23import de.uka.ipd.sdq.tcfmoop.config.exceptions.InvalidConfigException;
24import de.uka.ipd.sdq.tcfmoop.terminationcriteria.ParetoOptimalSetStabilityCriterion;
25 
26/**
27 * @author Atanas Dimitrov
28 *
29 */
30public class ParetoOptimalSetStabilityCriterionTest {
31        ParetoOptimalSetStabilityConfig possconf;
32        ParetoOptimalSetStabilityCriterion posscrit;
33        
34        Archive archive = new DefaultArchive();
35 
36        Objectives o1 = new Objectives(new ParetoDomination());
37        Objectives o2 = new Objectives(new ParetoDomination());
38        Objectives o3 = new Objectives(new ParetoDomination());
39        Objectives o4 = new Objectives(new ParetoDomination());
40        Objectives o5 = new Objectives(new ParetoDomination());
41        
42        MyIndividual i1 = new MyIndividual();
43        MyIndividual i2 = new MyIndividual();
44        MyIndividual i3 = new MyIndividual();
45        MyIndividual i4 = new MyIndividual();
46        MyIndividual i5 = 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                possconf = new ParetoOptimalSetStabilityConfig();
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                o5.add(X, 9);
72                o5.add(Y, 1.5);
73                
74                i1.setObjectives(o1);
75                i2.setObjectives(o2);
76                i3.setObjectives(o3);
77                i4.setObjectives(o4);
78                i5.setObjectives(o5);
79                
80                archive.add(i1);
81                archive.add(i2);
82                archive.add(i3);
83                archive.add(i4);                
84                
85                possconf.setMinimumIterationsToSurvive(3);
86                possconf.setMinimumSurvivors(3);
87                possconf.setMinimumSurvivorsInPercentage(0.75);
88                possconf.setEvaluationMode(EvaluationMode.EXACT_NUMBER);
89                if(!possconf.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 testExactNumbersMode() {
100                
101                //Test exact number
102                posscrit = new ParetoOptimalSetStabilityCriterion(possconf, null, archive);
103                posscrit.evaluate(0, 0);
104                assertFalse(posscrit.getEvaluationResult());
105                posscrit.evaluate(0, 0);
106                assertFalse(posscrit.getEvaluationResult());
107                posscrit.evaluate(0, 0);
108                assertTrue(posscrit.getEvaluationResult());
109                
110                posscrit = new ParetoOptimalSetStabilityCriterion(possconf, null, archive);
111                posscrit.evaluate(0, 0);
112                assertFalse(posscrit.getEvaluationResult());
113                posscrit.evaluate(0, 0);
114                assertFalse(posscrit.getEvaluationResult());
115                archive.remove(i2);
116                archive.add(i5);
117                posscrit.evaluate(0, 0);
118                assertTrue(posscrit.getEvaluationResult());
119                
120                archive.remove(i5);
121                archive.add(i2);
122                posscrit = new ParetoOptimalSetStabilityCriterion(possconf, null, archive);
123                posscrit.evaluate(0, 0);
124                assertFalse(posscrit.getEvaluationResult());
125                posscrit.evaluate(0, 0);
126                assertFalse(posscrit.getEvaluationResult());
127                archive.remove(i2);
128                archive.remove(i3);
129                posscrit.evaluate(0, 0);
130                assertFalse(posscrit.getEvaluationResult());
131                
132        }
133        
134        /**
135         * Test method for {@link de.uka.ipd.sdq.tcfmoop.terminationcriteria.AbstractTerminationCriterion#getEvaluationResult()}.
136         */
137        @Test
138        public void testPercentageMode() {
139                
140                //Test percentage
141                try {
142                        possconf.setEvaluationMode(EvaluationMode.PERCENTAGE);
143                } catch (InvalidConfigException e) {
144                        // TODO Auto-generated catch block
145                        e.printStackTrace();
146                }
147                posscrit = new ParetoOptimalSetStabilityCriterion(possconf, null, archive);
148                posscrit.evaluate(0, 0);
149                assertFalse(posscrit.getEvaluationResult());
150                posscrit.evaluate(0, 0);
151                assertFalse(posscrit.getEvaluationResult());
152                posscrit.evaluate(0, 0);
153                assertTrue(posscrit.getEvaluationResult());
154                
155                posscrit = new ParetoOptimalSetStabilityCriterion(possconf, null, archive);
156                posscrit.evaluate(0, 0);
157                assertFalse(posscrit.getEvaluationResult());
158                posscrit.evaluate(0, 0);
159                assertFalse(posscrit.getEvaluationResult());
160                archive.remove(i2);
161                archive.add(i5);
162                posscrit.evaluate(0, 0);
163                assertTrue(posscrit.getEvaluationResult());
164                
165                archive.remove(i5);
166                archive.add(i2);
167                posscrit = new ParetoOptimalSetStabilityCriterion(possconf, null, archive);
168                posscrit.evaluate(0, 0);
169                assertFalse(posscrit.getEvaluationResult());
170                posscrit.evaluate(0, 0);
171                assertFalse(posscrit.getEvaluationResult());
172                archive.remove(i2);
173                archive.remove(i3);
174                archive.add(i5);
175                posscrit.evaluate(0, 0);
176                assertFalse(posscrit.getEvaluationResult());
177                
178        }
179        
180        public class MyIndividual extends Individual{
181                public MyIndividual(){
182                        this.setIndividualStatusListeners(new HashSet<IndividualStateListener>());
183                }
184        }
185 
186}

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