1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.spa.basicsolver.visitor.perfhandler; |
5 | |
6 | import java.util.Hashtable; |
7 | |
8 | import de.uka.ipd.sdq.probfunction.math.IProbabilityDensityFunction; |
9 | import de.uka.ipd.sdq.probfunction.math.exception.FunctionsInDifferenDomainsException; |
10 | import de.uka.ipd.sdq.probfunction.math.exception.IncompatibleUnitsException; |
11 | import de.uka.ipd.sdq.probfunction.math.exception.UnknownPDFTypeException; |
12 | import de.uka.ipd.sdq.spa.basicsolver.visitor.SequenceHandler; |
13 | import de.uka.ipd.sdq.spa.expression.Expression; |
14 | import de.uka.ipd.sdq.spa.expression.Sequence; |
15 | |
16 | /** |
17 | * @author Ihssane |
18 | * |
19 | */ |
20 | public class PerformanceSequenceHandler implements SequenceHandler { |
21 | |
22 | private Hashtable<Expression, IProbabilityDensityFunction> pdfTable; |
23 | |
24 | protected PerformanceSequenceHandler( |
25 | Hashtable<Expression, IProbabilityDensityFunction> pdfTable) { |
26 | super(); |
27 | this.pdfTable = pdfTable; |
28 | } |
29 | |
30 | public void handle(Sequence seq) { |
31 | try { |
32 | IProbabilityDensityFunction leftDF = pdfTable.get(seq |
33 | .getLeftRegExp()); |
34 | IProbabilityDensityFunction rightDF = pdfTable.get(seq |
35 | .getRightRegExp()); |
36 | IProbabilityDensityFunction seqPDF = leftDF.mult(rightDF); |
37 | pdfTable.put(seq, seqPDF); |
38 | } catch (FunctionsInDifferenDomainsException e) { |
39 | e.printStackTrace(); |
40 | System.exit(1); |
41 | } catch (UnknownPDFTypeException e) { |
42 | e.printStackTrace(); |
43 | System.exit(1); |
44 | } catch (IncompatibleUnitsException e) { |
45 | e.printStackTrace(); |
46 | System.exit(1); |
47 | } |
48 | } |
49 | |
50 | public Hashtable<Expression, IProbabilityDensityFunction> getPdfTable() { |
51 | return pdfTable; |
52 | } |
53 | |
54 | public void setPdfTable( |
55 | Hashtable<Expression, IProbabilityDensityFunction> pdfTable) { |
56 | this.pdfTable = pdfTable; |
57 | } |
58 | |
59 | protected PerformanceSequenceHandler() { |
60 | super(); |
61 | } |
62 | |
63 | } |