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

COVERAGE SUMMARY FOR SOURCE FILE [MarkovResultApproximation.java]

nameclass, %method, %block, %line, %
MarkovResultApproximation.java0%   (0/1)0%   (0/9)0%   (0/130)0%   (0/31)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MarkovResultApproximation0%   (0/1)0%   (0/9)0%   (0/130)0%   (0/31)
MarkovResultApproximation (double, double): void 0%   (0/1)0%   (0/28)0%   (0/11)
adjustBounds (): void 0%   (0/1)0%   (0/43)0%   (0/6)
calculateAccuracy (): void 0%   (0/1)0%   (0/36)0%   (0/8)
getAccuracy (): int 0%   (0/1)0%   (0/3)0%   (0/1)
getAdjustedLowerBound (): double 0%   (0/1)0%   (0/3)0%   (0/1)
getAdjustedUpperBound (): double 0%   (0/1)0%   (0/3)0%   (0/1)
getLowerBound (): double 0%   (0/1)0%   (0/3)0%   (0/1)
getUpperBound (): double 0%   (0/1)0%   (0/3)0%   (0/1)
hasRequiredAccuracy (int): boolean 0%   (0/1)0%   (0/8)0%   (0/1)

1package de.uka.ipd.sdq.reliability.solver.pcm2markov;
2 
3/**
4 * This class represents an approximated Markov transformation result value.
5 * 
6 * @author brosch
7 * 
8 */
9public class MarkovResultApproximation {
10 
11        /**
12         * The maximal accuracy yielded by an approximation.
13         */
14        private static final int MAXACCURACY = 10;
15 
16        /**
17         * The accuracy (i.e., number of exact decimal places) of this
18         * approximation.
19         */
20        private int accuracy = 0;
21 
22        /**
23         * The lower approximation bound after adjustment.
24         */
25        private double adjustedLowerBound = 0.0;
26 
27        /**
28         * The upper approximation bound after adjustment.
29         */
30        private double adjustedUpperBound = 0.0;
31 
32        /**
33         * A lower approximation bound.
34         */
35        private double lowerBound = 0.0;
36 
37        /**
38         * An upper approximation bound.
39         */
40        private double upperBound = 0.0;
41 
42        /**
43         * Initializes a new Markov result value approximation.
44         * 
45         * @param lowerBound
46         *            the lower bound of the approximation
47         * @param upperBound
48         *            the upper bound of the approximation
49         */
50        public MarkovResultApproximation(final double lowerBound,
51                        final double upperBound) {
52                this.lowerBound = lowerBound;
53                this.upperBound = upperBound;
54                calculateAccuracy();
55                adjustBounds();
56        }
57 
58        /**
59         * Replaces the approximation through a more coarse-grained one, in order to
60         * reduce the number of decimal places of the bounds to the value of
61         * accuracy.
62         */
63        private void adjustBounds() {
64                adjustedLowerBound = Math
65                                .floor(lowerBound * Math.pow(10, accuracy + 1))
66                                / Math.pow(10, accuracy + 1);
67                adjustedUpperBound = Math.ceil(upperBound * Math.pow(10, accuracy + 1))
68                                / Math.pow(10, accuracy + 1);
69        }
70 
71        /**
72         * Determines the accuracy of the approximation.
73         */
74        private void calculateAccuracy() {
75                double delta = upperBound - lowerBound;
76                accuracy = 1;
77                while (delta < Math.pow(0.1, accuracy)) {
78                        accuracy++;
79                        if (accuracy > MAXACCURACY) {
80                                break;
81                        }
82                }
83                accuracy -= 1;
84        }
85 
86        /**
87         * Retrieves the accuracy (i.e., number of exact decimal values) of the
88         * approximation.
89         * 
90         * @return the accuracy of the approximation
91         */
92        public int getAccuracy() {
93                return accuracy;
94        }
95 
96        /**
97         * Retrieves the lower approximation bound after adjustment.
98         * 
99         * @return the lower approximation bound
100         */
101        public double getAdjustedLowerBound() {
102                return adjustedLowerBound;
103        }
104 
105        /**
106         * Retrieves the upper approximation bound after adjustment.
107         * 
108         * @return the upper approximation bound
109         */
110        public double getAdjustedUpperBound() {
111                return adjustedUpperBound;
112        }
113 
114        /**
115         * Retrieves the lower approximation bound.
116         * 
117         * @return the lower approximation bound
118         */
119        public double getLowerBound() {
120                return lowerBound;
121        }
122 
123        /**
124         * Retrieves the upper approximation bound.
125         * 
126         * @return the upper approximation bound
127         */
128        public double getUpperBound() {
129                return upperBound;
130        }
131 
132        /**
133         * Checks if the approximation fulfills a required accuracy (i.e., number of
134         * exact decimal places).
135         * 
136         * @param requiredAccuracy
137         *            the required accuracy
138         * @return true if the required accuracy is fulfilled
139         */
140        public boolean hasRequiredAccuracy(final int requiredAccuracy) {
141                return (accuracy >= requiredAccuracy);
142        }
143}

[all classes][de.uka.ipd.sdq.reliability.solver.pcm2markov]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov