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

COVERAGE SUMMARY FOR SOURCE FILE [DesignDecisionGenotype.java]

nameclass, %method, %block, %line, %
DesignDecisionGenotype.java0%   (0/3)0%   (0/44)0%   (0/337)0%   (0/74)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DesignDecisionGenotype0%   (0/1)0%   (0/31)0%   (0/277)0%   (0/56)
DesignDecisionGenotype (): void 0%   (0/1)0%   (0/10)0%   (0/4)
DesignDecisionGenotype (Candidate): void 0%   (0/1)0%   (0/9)0%   (0/4)
DesignDecisionGenotype (Candidate, DecisionSpace, DesignDecisionGenotype): void 0%   (0/1)0%   (0/80)0%   (0/17)
DesignDecisionGenotype (List): void 0%   (0/1)0%   (0/16)0%   (0/5)
add (Choice): boolean 0%   (0/1)0%   (0/6)0%   (0/1)
add (int, Choice): void 0%   (0/1)0%   (0/7)0%   (0/2)
addAll (Collection): boolean 0%   (0/1)0%   (0/6)0%   (0/1)
addAll (int, Collection): boolean 0%   (0/1)0%   (0/7)0%   (0/1)
clear (): void 0%   (0/1)0%   (0/3)0%   (0/2)
contains (Object): boolean 0%   (0/1)0%   (0/6)0%   (0/1)
containsAll (Collection): boolean 0%   (0/1)0%   (0/6)0%   (0/1)
get (int): Choice 0%   (0/1)0%   (0/7)0%   (0/1)
getEMFCandidate (): Candidate 0%   (0/1)0%   (0/3)0%   (0/1)
getInternalList (): List 0%   (0/1)0%   (0/4)0%   (0/1)
getNumericID (): long 0%   (0/1)0%   (0/3)0%   (0/1)
indexOf (Object): int 0%   (0/1)0%   (0/6)0%   (0/1)
isEmpty (): boolean 0%   (0/1)0%   (0/5)0%   (0/1)
iterator (): Iterator 0%   (0/1)0%   (0/8)0%   (0/1)
lastIndexOf (Object): int 0%   (0/1)0%   (0/6)0%   (0/1)
listIterator (): ListIterator 0%   (0/1)0%   (0/8)0%   (0/1)
listIterator (int): ListIterator 0%   (0/1)0%   (0/8)0%   (0/1)
newInstance (): Genotype 0%   (0/1)0%   (0/4)0%   (0/1)
remove (Object): boolean 0%   (0/1)0%   (0/6)0%   (0/1)
remove (int): Choice 0%   (0/1)0%   (0/7)0%   (0/1)
removeAll (Collection): boolean 0%   (0/1)0%   (0/6)0%   (0/1)
retainAll (Collection): boolean 0%   (0/1)0%   (0/6)0%   (0/1)
set (int, Choice): Choice 0%   (0/1)0%   (0/8)0%   (0/1)
size (): int 0%   (0/1)0%   (0/5)0%   (0/1)
subList (int, int): List 0%   (0/1)0%   (0/10)0%   (0/1)
toArray (): Object [] 0%   (0/1)0%   (0/5)0%   (0/1)
toArray (Object []): Object [] 0%   (0/1)0%   (0/6)0%   (0/1)
     
class DesignDecisionGenotype$IndividualID0%   (0/1)0%   (0/3)0%   (0/12)0%   (0/3)
<static initializer> 0%   (0/1)0%   (0/3)0%   (0/2)
DesignDecisionGenotype$IndividualID (): void 0%   (0/1)0%   (0/3)0%   (0/1)
incID (): long 0%   (0/1)0%   (0/6)0%   (0/1)
     
class InternalIterator0%   (0/1)0%   (0/10)0%   (0/48)0%   (0/15)
InternalIterator (List, int): void 0%   (0/1)0%   (0/8)0%   (0/3)
add (Choice): void 0%   (0/1)0%   (0/5)0%   (0/2)
hasNext (): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
hasPrevious (): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
next (): Choice 0%   (0/1)0%   (0/5)0%   (0/1)
nextIndex (): int 0%   (0/1)0%   (0/4)0%   (0/1)
previous (): Choice 0%   (0/1)0%   (0/5)0%   (0/1)
previousIndex (): int 0%   (0/1)0%   (0/4)0%   (0/1)
remove (): void 0%   (0/1)0%   (0/4)0%   (0/2)
set (Choice): void 0%   (0/1)0%   (0/5)0%   (0/2)

1package de.uka.ipd.sdq.dsexplore.opt4j.genotype;
2 
3import java.util.Collection;
4import java.util.Iterator;
5import java.util.List;
6import java.util.ListIterator;
7 
8import org.eclipse.emf.ecore.util.EcoreUtil;
9import org.opt4j.core.problem.Genotype;
10import org.opt4j.genotype.ListGenotype;
11 
12import de.uka.ipd.sdq.pcm.designdecision.Candidate;
13import de.uka.ipd.sdq.pcm.designdecision.Choice;
14import de.uka.ipd.sdq.pcm.designdecision.DecisionSpace;
15import de.uka.ipd.sdq.pcm.designdecision.DegreeOfFreedomInstance;
16import de.uka.ipd.sdq.pcm.designdecision.designdecisionFactory;
17 
18public class DesignDecisionGenotype implements ListGenotype<Choice> {
19        
20        private Candidate choices;
21        
22        /*
23         * Internal static class to disallow any changes of the individual counter except increasing it.  
24         */
25        static class IndividualID { 
26                private static long individualIDCounter = 0;
27                protected static long incID(){
28                        return individualIDCounter++;
29                }
30        }
31        private long numericId = IndividualID.incID();
32        
33        public DesignDecisionGenotype() {
34                this.choices = designdecisionFactory.eINSTANCE.createCandidate();
35        }
36        
37        public DesignDecisionGenotype(Candidate emfCandidate){
38                this.choices = emfCandidate;
39        }
40        
41        /**
42         * create new genotype. Sort choice in the order of the passed Problem.  
43         * @param emfCandidate
44         */
45        public DesignDecisionGenotype(Candidate emfCandidate, DecisionSpace problem, DesignDecisionGenotype initialCandidateGenotype){
46                // sort by designdecision order (time doesnot matter so much as this is only done at optimisation startup)
47                this.choices = designdecisionFactory.eINSTANCE.createCandidate();
48                for (DegreeOfFreedomInstance dof : problem.getDegreesOfFreedom()) {
49                        boolean foundChoice = false;
50                        for (Choice choice : emfCandidate.getChoices()) {
51                                if (choice.getDegreeOfFreedomInstance() == dof){
52                                        this.choices.getChoices().add(choice);
53                                        foundChoice = true;
54                                        break;
55                                }
56                        }
57                        if (!foundChoice){
58                                // if not found take from initial genotype
59                                for (Choice choice : initialCandidateGenotype.getEMFCandidate().getChoices()) {
60                                        if (EcoreUtil.equals(choice.getDegreeOfFreedomInstance(),dof)){
61                                                this.choices.getChoices().add((Choice)EcoreUtil.copy(choice));
62                                                foundChoice = true;
63                                                break;
64                                        }
65                                }
66                        }
67                }
68        }
69 
70        private DesignDecisionGenotype(List<Choice> internalList) {
71                this.choices = designdecisionFactory.eINSTANCE.createCandidate();
72                this.choices.getChoices().addAll(internalList);
73        }
74 
75        @SuppressWarnings("unchecked")
76        @Override
77        public <G extends Genotype> G newInstance() {
78                return (G) new DesignDecisionGenotype();
79        }
80 
81        @Override
82        public int size() {
83                return this.choices.getChoices().size();
84        }
85 
86        @Override
87        public boolean add(Choice e) {
88                return this.choices.getChoices().add(e);
89        }
90 
91        @Override
92        public void add(int index, Choice element) {
93                this.choices.getChoices().add(index, element);
94        }
95 
96        @Override
97        public boolean addAll(Collection<? extends Choice> c) {
98                return this.choices.getChoices().addAll(c);
99        }
100 
101        @Override
102        public boolean addAll(int index, Collection<? extends Choice> c) {
103                return this.choices.getChoices().addAll(index, c);
104        }
105 
106        @Override
107        public void clear() {
108                this.clear();
109        }
110 
111        @Override
112        public boolean contains(Object o) {
113                return this.choices.getChoices().contains(o);
114        }
115 
116        @Override
117        public boolean containsAll(Collection<?> c) {
118                return this.choices.getChoices().containsAll(c);
119        }
120 
121        @Override
122        public Choice get(int index) {
123                return this.choices.getChoices().get(index);
124        }
125 
126        @Override
127        public int indexOf(Object o) {
128                return this.choices.getChoices().indexOf(o);
129        }
130 
131        @Override
132        public boolean isEmpty() {
133                return this.choices.getChoices().isEmpty();
134        }
135 
136        @Override
137        public Iterator<Choice> iterator() {
138                return new InternalIterator(this.choices.getChoices(),0);
139        }
140 
141        @Override
142        public int lastIndexOf(Object o) {
143                return this.choices.getChoices().lastIndexOf(o);
144        }
145 
146        @Override
147        public ListIterator<Choice> listIterator() {
148                return new InternalIterator(this.choices.getChoices(),0);
149        }
150 
151        @Override
152        public ListIterator<Choice> listIterator(int index) {
153                return new InternalIterator(this.choices.getChoices(), index);
154        }
155 
156        @Override
157        public boolean remove(Object o) {
158                return this.choices.getChoices().remove(o);
159        }
160 
161        @Override
162        public Choice remove(int index) {
163                return this.choices.getChoices().remove(index);
164        }
165 
166        @Override
167        public boolean removeAll(Collection<?> c) {
168                return this.choices.getChoices().removeAll(c);
169        }
170 
171        @Override
172        public boolean retainAll(Collection<?> c) {
173                return this.choices.getChoices().retainAll(c);
174        }
175 
176        @Override
177        public Choice set(int index, Choice element) {
178                return this.choices.getChoices().set(index, element);
179        }
180 
181        @Override
182        public List<Choice> subList(int fromIndex, int toIndex) {
183                return new DesignDecisionGenotype(choices.getChoices().subList(fromIndex, toIndex));
184        }
185 
186        @Override
187        public Object[] toArray() {
188                return this.choices.getChoices().toArray();
189        }
190 
191        @Override
192        public <T> T[] toArray(T[] a) {
193                return this.choices.getChoices().toArray(a);
194        }
195        
196        protected List<Choice> getInternalList(){
197                return this.choices.getChoices();
198        }
199        
200        public Candidate getEMFCandidate(){
201                return this.choices;
202        }
203        
204        public long getNumericID() {
205                return this.numericId;
206        }
207 
208 
209 
210}
211 
212/**
213 * This allows us to intercept uses of the iterator when needed. 
214 * @author martens
215 *
216 */
217class InternalIterator implements ListIterator<Choice>{
218        
219        ListIterator<Choice> decoratedIterator;
220        
221        public InternalIterator(List<Choice> internalList, int index){
222                this.decoratedIterator = internalList.listIterator(index);
223        }
224 
225        @Override
226        public boolean hasNext() {
227                return decoratedIterator.hasNext();
228        }
229 
230        @Override
231        public Choice next() {
232                return decoratedIterator.next();
233        }
234 
235        @Override
236        public void remove() {
237                decoratedIterator.remove();
238        }
239 
240        @Override
241        public void add(Choice e) {
242                this.decoratedIterator.add(e);
243        }
244 
245        @Override
246        public boolean hasPrevious() {
247                return this.decoratedIterator.hasPrevious();
248        }
249 
250        @Override
251        public int nextIndex() {
252                return this.decoratedIterator.nextIndex();
253        }
254 
255        @Override
256        public Choice previous() {
257                return this.decoratedIterator.previous();
258        }
259 
260        @Override
261        public int previousIndex() {
262                return this.decoratedIterator.previousIndex();
263        }
264 
265        @Override
266        public void set(Choice e) {
267                this.decoratedIterator.set(e);
268        }
269        
270}

[all classes][de.uka.ipd.sdq.dsexplore.opt4j.genotype]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov