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

nameclass, %method, %block, %line, %
PDFPerformanceOps.java0%   (0/1)0%   (0/7)0%   (0/151)0%   (0/31)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PDFPerformanceOps0%   (0/1)0%   (0/7)0%   (0/151)0%   (0/31)
$SWITCH_TABLE$de$uka$ipd$sdq$spa$basicsolver$operations$BinaryOperation (): i... 0%   (0/1)0%   (0/34)0%   (0/1)
PDFPerformanceOps (): void 0%   (0/1)0%   (0/3)0%   (0/2)
computeAlternative (ManagedPDF, double, ManagedPDF, double): ManagedPDF 0%   (0/1)0%   (0/8)0%   (0/2)
computeIteration (ManagedPDF, IProbabilityMassFunction): ManagedPDF 0%   (0/1)0%   (0/52)0%   (0/13)
computeParallel (ManagedPDF, ManagedPDF): ManagedPDF 0%   (0/1)0%   (0/8)0%   (0/1)
computeSequence (ManagedPDF, ManagedPDF): ManagedPDF 0%   (0/1)0%   (0/8)0%   (0/1)
performOperation (BinaryOperation, ManagedPDF, double, ManagedPDF, double): M... 0%   (0/1)0%   (0/38)0%   (0/11)

1package de.uka.ipd.sdq.spa.basicsolver.operations;
2 
3import java.util.Iterator;
4 
5import de.uka.ipd.sdq.probfunction.math.IProbabilityDensityFunction;
6import de.uka.ipd.sdq.probfunction.math.IProbabilityMassFunction;
7import de.uka.ipd.sdq.probfunction.math.ISample;
8import de.uka.ipd.sdq.probfunction.math.ISamplePDF;
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;
12 
13public class PDFPerformanceOps {
14 
15        public PDFPerformanceOps() {
16                super();
17        }
18        
19        public ManagedPDF computeIteration(ManagedPDF usage,
20                        IProbabilityMassFunction iterations)
21                        throws ProbabilityFunctionException, ConfigurationNotSetException {
22                ISamplePDF innerPDF = usage.getSamplePdfFrequencyDomain();
23                
24                ISamplePDF resultPDF = ManagedPDF.createZeroFunction().getSamplePdfFrequencyDomain();
25                ISamplePDF tempPDF = ManagedPDF.createDiracImpulse().getSamplePdfFrequencyDomain();
26 
27                int pos = 0;
28                for (Iterator<ISample> iter = iterations.getSamples().iterator(); iter
29                                .hasNext();) {
30                        ISample sample = iter.next();
31                        Integer nextPos = (Integer) sample.getValue();
32                        while (pos < nextPos) {
33                                tempPDF = (ISamplePDF)tempPDF.mult(innerPDF);
34                                pos++;
35                        }
36                        resultPDF = (ISamplePDF) resultPDF.add(tempPDF.scale(sample.getProbability()));
37                }
38                return new ManagedPDF(resultPDF, true);
39        }
40 
41        public ManagedPDF computeAlternative(ManagedPDF leftRU, double leftProbability,
42                        ManagedPDF rightRU, double rightProbability)
43                        throws ProbabilityFunctionException {
44                return performOperation(BinaryOperation.ALTERNATIVE, leftRU,
45                                leftProbability, rightRU, rightProbability);
46        }
47 
48        public ManagedPDF computeSequence(ManagedPDF leftRU, ManagedPDF rightRU)
49                        throws ProbabilityFunctionException {
50                return performOperation(BinaryOperation.SEQUENCE, leftRU, 0, rightRU, 0);
51        }
52 
53        public ManagedPDF computeParallel(ManagedPDF leftRU, ManagedPDF rightRU)
54                        throws ProbabilityFunctionException {
55                return performOperation(BinaryOperation.PARALLEL, leftRU, 0, rightRU, 0);
56        }
57 
58 
59        protected ManagedPDF performOperation(BinaryOperation op,
60                        ManagedPDF leftRU, double leftProbability,
61                        ManagedPDF rightRU, double rightProbability)
62                        throws ProbabilityFunctionException {
63 
64                IProbabilityDensityFunction resultPDF = null;
65                IProbabilityDensityFunction leftPDF = leftRU.getPdfFrequencyDomain();
66                IProbabilityDensityFunction rightPDF = rightRU.getPdfFrequencyDomain();
67 
68                switch (op) {
69                case SEQUENCE:
70                        resultPDF = leftPDF.mult(rightPDF); 
71                        break;
72                case ALTERNATIVE:
73                        resultPDF = leftPDF.scale(leftProbability).add(rightPDF.scale(rightProbability));
74                        break;
75                case PARALLEL:
76                        // TODO add correct computation for parallel
77                        resultPDF = leftPDF.mult(rightPDF); 
78                        break;
79                default:
80                        break;
81                }
82 
83                return new ManagedPDF(resultPDF, true);
84        }
85 
86}

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