1 | package de.uka.ipd.sdq.spa.basicsolver.visitor.perfhandler; |
2 | |
3 | import java.util.Hashtable; |
4 | |
5 | import de.uka.ipd.sdq.probfunction.math.IProbabilityDensityFunction; |
6 | import de.uka.ipd.sdq.probfunction.math.IProbabilityFunctionFactory; |
7 | import de.uka.ipd.sdq.probfunction.math.ISamplePDF; |
8 | import de.uka.ipd.sdq.probfunction.math.exception.ProbabilityFunctionException; |
9 | import de.uka.ipd.sdq.spa.basicsolver.visitor.SymbolHandler; |
10 | import de.uka.ipd.sdq.spa.expression.Expression; |
11 | import de.uka.ipd.sdq.spa.expression.Symbol; |
12 | import de.uka.ipd.sdq.spa.resourcemodel.ResourceUsage; |
13 | |
14 | /** |
15 | * @author Ihssane |
16 | * |
17 | */ |
18 | public class PerformanceSymbolHandler implements SymbolHandler { |
19 | |
20 | private Hashtable<Expression, IProbabilityDensityFunction> pdfTable; |
21 | |
22 | private IProbabilityFunctionFactory pfFactory = IProbabilityFunctionFactory.eINSTANCE; |
23 | |
24 | private int domainSize; |
25 | |
26 | protected PerformanceSymbolHandler( |
27 | Hashtable<Expression, IProbabilityDensityFunction> pdfTable, int domainSize) { |
28 | this(domainSize); |
29 | this.pdfTable = pdfTable; |
30 | } |
31 | |
32 | protected PerformanceSymbolHandler(int domainSize) { |
33 | super(); |
34 | this.domainSize = domainSize; |
35 | } |
36 | |
37 | public void handle(Symbol symbol) { |
38 | |
39 | try { |
40 | ResourceUsage resourceUsage = (ResourceUsage) symbol.getResourceUsages().get(0); |
41 | IProbabilityDensityFunction pdf = pfFactory.transformToPDF(resourceUsage.getUsageTime()); |
42 | ISamplePDF spdf = pfFactory.transformToSamplePDF(pdf); |
43 | spdf.expand(domainSize); |
44 | IProbabilityDensityFunction fftPDF = spdf.getFourierTransform(); |
45 | pdfTable.put(symbol, fftPDF); |
46 | } catch (ProbabilityFunctionException e) { |
47 | e.printStackTrace(); |
48 | System.exit(1); |
49 | } |
50 | } |
51 | |
52 | public Hashtable<Expression, IProbabilityDensityFunction> getPdfTable() { |
53 | return pdfTable; |
54 | } |
55 | |
56 | public void setPdfTable( |
57 | Hashtable<Expression, IProbabilityDensityFunction> pdfTable) { |
58 | this.pdfTable = pdfTable; |
59 | } |
60 | |
61 | } |