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

COVERAGE SUMMARY FOR SOURCE FILE [RUPerformanceOps.java]

nameclass, %method, %block, %line, %
RUPerformanceOps.java0%   (0/1)0%   (0/11)0%   (0/218)0%   (0/55)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RUPerformanceOps0%   (0/1)0%   (0/11)0%   (0/218)0%   (0/55)
RUPerformanceOps (): void 0%   (0/1)0%   (0/8)0%   (0/3)
RUPerformanceOps (PDFPerformanceOps): void 0%   (0/1)0%   (0/6)0%   (0/3)
computeAlternative (Hashtable, double, Hashtable, double): Hashtable 0%   (0/1)0%   (0/8)0%   (0/2)
computeIteration (Hashtable, IProbabilityMassFunction): Hashtable 0%   (0/1)0%   (0/38)0%   (0/9)
computeParallel (Hashtable, Hashtable): Hashtable 0%   (0/1)0%   (0/8)0%   (0/2)
computeSequence (Hashtable, Hashtable): Hashtable 0%   (0/1)0%   (0/8)0%   (0/2)
ensureNotNull (ManagedPDF, ManagedPDF): ManagedPDF 0%   (0/1)0%   (0/12)0%   (0/5)
getDisjointUnion (Set, Set): List 0%   (0/1)0%   (0/26)0%   (0/5)
getResourceUsageTimes (List): Hashtable 0%   (0/1)0%   (0/32)0%   (0/7)
performOperation (BinaryOperation, Hashtable, double, Hashtable, double): Has... 0%   (0/1)0%   (0/53)0%   (0/13)
performOperation (BinaryOperation, ManagedPDF, double, ManagedPDF, double): M... 0%   (0/1)0%   (0/19)0%   (0/4)

1package de.uka.ipd.sdq.spa.basicsolver.operations;
2 
3import java.util.ArrayList;
4import java.util.Hashtable;
5import java.util.List;
6import java.util.Set;
7 
8import de.uka.ipd.sdq.probfunction.math.IProbabilityMassFunction;
9import de.uka.ipd.sdq.probfunction.math.ManagedPDF;
10import de.uka.ipd.sdq.probfunction.math.exception.ConfigurationNotSetException;
11import de.uka.ipd.sdq.probfunction.math.exception.ProbabilityFunctionException;
12import de.uka.ipd.sdq.spa.basicsolver.exceptions.BothNullExpeception;
13import de.uka.ipd.sdq.spa.resourcemodel.ActiveResource;
14import de.uka.ipd.sdq.spa.resourcemodel.Resource;
15import de.uka.ipd.sdq.spa.resourcemodel.ResourceUsage;
16 
17public class RUPerformanceOps {
18 
19        private PDFPerformanceOps pdfPerformanceOps;
20 
21        public RUPerformanceOps(PDFPerformanceOps pdfPerformanceOps) {
22                super();
23                this.pdfPerformanceOps = pdfPerformanceOps;
24        }
25 
26        public RUPerformanceOps() {
27                pdfPerformanceOps = new PDFPerformanceOps();
28        }
29 
30        public Hashtable<ActiveResource, ManagedPDF> computeIteration(
31                        Hashtable<ActiveResource, ManagedPDF> innerRUs,
32                        IProbabilityMassFunction iterations) throws ConfigurationNotSetException {
33                Hashtable<ActiveResource, ManagedPDF> resultTable = new Hashtable<ActiveResource, ManagedPDF>();
34 
35                try {
36                        for (ActiveResource resource : innerRUs.keySet()) {
37                                ManagedPDF ru = pdfPerformanceOps.computeIteration(innerRUs.get(resource),
38                                                iterations);
39                                resultTable.put(resource, ru);
40                        }
41                } catch (ProbabilityFunctionException e) {
42                        e.printStackTrace();
43                        System.exit(1);
44                }
45 
46                return resultTable;
47 
48        }
49 
50        public Hashtable<Resource, ManagedPDF> getResourceUsageTimes(
51                        List<ResourceUsage> resourceUsageList) {
52 
53                Hashtable<Resource, ManagedPDF> resultTable = new Hashtable<Resource, ManagedPDF>();
54                for (ResourceUsage resourceUsage : resourceUsageList) {
55                        Resource resource = resourceUsage.getResource();
56                        ManagedPDF managedPDF = new ManagedPDF(
57                                        resourceUsage.getUsageTime(), true);
58                        resultTable.put(resource, managedPDF);
59                }
60                return resultTable;
61        }
62 
63        public Hashtable<ActiveResource, ManagedPDF> computeAlternative(
64                        Hashtable<ActiveResource, ManagedPDF> leftRUs, double leftProb,
65                        Hashtable<ActiveResource, ManagedPDF> rightRUs, double rightProb) {
66 
67                return performOperation(BinaryOperation.ALTERNATIVE, leftRUs, leftProb,
68                                rightRUs, rightProb);
69        }
70 
71        public Hashtable<ActiveResource, ManagedPDF> computeParallel(
72                        Hashtable<ActiveResource, ManagedPDF> leftRUs,
73                        Hashtable<ActiveResource, ManagedPDF> rightRUs) {
74 
75                return performOperation(BinaryOperation.PARALLEL, leftRUs, 0, rightRUs,
76                                0);
77        }
78 
79        public Hashtable<ActiveResource, ManagedPDF> computeSequence(
80                        Hashtable<ActiveResource, ManagedPDF> leftRUs,
81                        Hashtable<ActiveResource, ManagedPDF> rightRUs) {
82 
83                return performOperation(BinaryOperation.SEQUENCE, leftRUs, 0, rightRUs,
84                                0);
85        }
86 
87        private Hashtable<ActiveResource, ManagedPDF> performOperation(
88                        BinaryOperation op, Hashtable<ActiveResource, ManagedPDF> leftRUs,
89                        double leftProbability,
90                        Hashtable<ActiveResource, ManagedPDF> rightRUs,
91                        double rightProbability) {
92 
93                Hashtable<ActiveResource, ManagedPDF> resultTable = new Hashtable<ActiveResource, ManagedPDF>();
94 
95                try {
96                        List<ActiveResource> keyList = getDisjointUnion(leftRUs.keySet(),
97                                        rightRUs.keySet());
98                        for (ActiveResource resource : keyList) {
99                                ManagedPDF leftRU = leftRUs.get(resource);
100                                ManagedPDF rightRU = rightRUs.get(resource);
101                                ManagedPDF resultRU = performOperation(op, leftRU,
102                                                leftProbability, rightRU, rightProbability);
103                                resultTable.put(resource, resultRU);
104                        }
105                } catch (Exception e) {
106                        e.printStackTrace();
107                        System.exit(1);
108                }
109                return resultTable;
110        }
111 
112        private ManagedPDF performOperation(BinaryOperation op, ManagedPDF leftRU,
113                        double leftProbability, ManagedPDF rightRU, double rightProbability)
114                        throws ProbabilityFunctionException, BothNullExpeception, ConfigurationNotSetException {
115                leftRU = ensureNotNull(leftRU, rightRU);
116                rightRU = ensureNotNull(rightRU, leftRU);
117                return pdfPerformanceOps.performOperation(op, leftRU, leftProbability, rightRU,
118                                rightProbability);
119        }
120 
121        private ManagedPDF ensureNotNull(ManagedPDF rightRU, ManagedPDF leftRU)
122                        throws BothNullExpeception, ConfigurationNotSetException {
123                if (rightRU == null) {
124                        if (leftRU == null) {
125                                throw new BothNullExpeception();
126                        } else {
127                                rightRU = ManagedPDF.createDiracImpulse(); 
128                        }
129                }
130                return rightRU;
131        }
132 
133        private List<ActiveResource> getDisjointUnion(Set<ActiveResource> setOne,
134                        Set<ActiveResource> name) {
135                List<ActiveResource> resultList = new ArrayList<ActiveResource>(setOne);
136                for (ActiveResource resource : name) {
137                        if (!resultList.contains(resource)) {
138                                resultList.add(resource);
139                        }
140                }
141                return resultList;
142        }
143}

[all classes][de.uka.ipd.sdq.spa.basicsolver.operations]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov