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

COVERAGE SUMMARY FOR SOURCE FILE [PerformanceLoopHandler.java]

nameclass, %method, %block, %line, %
PerformanceLoopHandler.java0%   (0/1)0%   (0/7)0%   (0/115)0%   (0/38)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PerformanceLoopHandler0%   (0/1)0%   (0/7)0%   (0/115)0%   (0/38)
<static initializer> 0%   (0/1)0%   (0/3)0%   (0/2)
PerformanceLoopHandler (): void 0%   (0/1)0%   (0/3)0%   (0/2)
PerformanceLoopHandler (Hashtable): void 0%   (0/1)0%   (0/6)0%   (0/3)
getPdfTable (): Hashtable 0%   (0/1)0%   (0/3)0%   (0/1)
handle (Loop): void 0%   (0/1)0%   (0/31)0%   (0/9)
setPdfTable (Hashtable): void 0%   (0/1)0%   (0/4)0%   (0/2)
solveIterative (IProbabilityMassFunction, ISamplePDF): ISamplePDF 0%   (0/1)0%   (0/65)0%   (0/19)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.spa.basicsolver.visitor.perfhandler;
5 
6import java.util.Hashtable;
7import java.util.Iterator;
8 
9import de.uka.ipd.sdq.probfunction.math.IProbabilityDensityFunction;
10import de.uka.ipd.sdq.probfunction.math.IProbabilityFunctionFactory;
11import de.uka.ipd.sdq.probfunction.math.IProbabilityMassFunction;
12import de.uka.ipd.sdq.probfunction.math.ISample;
13import de.uka.ipd.sdq.probfunction.math.ISamplePDF;
14import de.uka.ipd.sdq.probfunction.math.IUnit;
15import de.uka.ipd.sdq.probfunction.math.exception.FunctionNotInTimeDomainException;
16import de.uka.ipd.sdq.probfunction.math.exception.FunctionsInDifferenDomainsException;
17import de.uka.ipd.sdq.probfunction.math.exception.ProbabilityFunctionException;
18import de.uka.ipd.sdq.probfunction.math.exception.UnknownPDFTypeException;
19import de.uka.ipd.sdq.spa.basicsolver.visitor.LoopHandler;
20import de.uka.ipd.sdq.spa.expression.Expression;
21import de.uka.ipd.sdq.spa.expression.Loop;
22 
23/**
24 * @author Ihssane
25 * 
26 */
27public class PerformanceLoopHandler implements LoopHandler {
28 
29        private Hashtable<Expression, IProbabilityDensityFunction> pdfTable;
30 
31        private static IProbabilityFunctionFactory pfFactory = IProbabilityFunctionFactory.eINSTANCE;
32 
33        protected PerformanceLoopHandler(
34                        Hashtable<Expression, IProbabilityDensityFunction> pdfTable) {
35                super();
36                this.pdfTable = pdfTable;
37        }
38 
39        /**
40         * the iterations of a loop have to be specified as a probability mass
41         * functions whose samples are integer values (type Integer)
42         * 
43         * @throws UnknownPDFTypeException
44         * @throws FunctionNotInTimeDomainException
45         * @throws FunctionsInDifferenDomainsException
46         */
47        public void handle(Loop loop) {
48                try {
49                        
50                        ISamplePDF innerPDF = pfFactory.transformToSamplePDF(pdfTable
51                                        .get(loop.getRegExp()));
52                        IProbabilityMassFunction iterations = pfFactory.transformToPMF(loop.getIterationsPMF());
53                        ISamplePDF result = solveIterative(iterations, innerPDF);
54                        pdfTable.put(loop, result);
55                        
56                } catch (ProbabilityFunctionException e) {
57                        e.printStackTrace();
58                        System.exit(1);
59                }
60 
61        }
62 
63        public static ISamplePDF solveIterative(IProbabilityMassFunction iterations, ISamplePDF innerFourier) throws ProbabilityFunctionException {
64                int numSamplingPoints = innerFourier.getValuesAsDouble().size();
65                double distance = innerFourier.getDistance();
66                IUnit unit = innerFourier.getUnit();
67 
68                ISamplePDF result = (ISamplePDF)pfFactory.createZeroFunction(numSamplingPoints,
69                                distance, unit).getFourierTransform();
70 
71                ISamplePDF dirac = pfFactory.createDiracImpulse(numSamplingPoints,
72                                distance, unit);
73 
74                IProbabilityDensityFunction tmp = dirac.getFourierTransform();
75 
76 
77                int pos = 0;
78                for (Iterator<ISample> iter = iterations.getSamples().iterator(); iter
79                                .hasNext();) {
80                        ISample sample = iter.next();
81                        Integer nextPos = (Integer) sample.getValue();
82                        while (pos < nextPos) {
83                                tmp = tmp.mult(innerFourier);
84                                pos++;
85                        }
86                        result = (ISamplePDF) result.add(tmp.scale(sample
87                                        .getProbability()));
88                }
89                return result;
90        }
91 
92        public Hashtable<Expression, IProbabilityDensityFunction> getPdfTable() {
93                return pdfTable;
94        }
95 
96        public void setPdfTable(
97                        Hashtable<Expression, IProbabilityDensityFunction> pdfTable) {
98                this.pdfTable = pdfTable;
99        }
100 
101        protected PerformanceLoopHandler() {
102                super();
103        }
104 
105}

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