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

COVERAGE SUMMARY FOR SOURCE FILE [DimensionBounds.java]

nameclass, %method, %block, %line, %
DimensionBounds.java0%   (0/1)0%   (0/13)0%   (0/299)0%   (0/43)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DimensionBounds0%   (0/1)0%   (0/13)0%   (0/299)0%   (0/43)
DimensionBounds (DecisionSpace): void 0%   (0/1)0%   (0/6)0%   (0/3)
getLowerBound (int): Double 0%   (0/1)0%   (0/54)0%   (0/7)
getLowerDoubleBound (int): Double 0%   (0/1)0%   (0/19)0%   (0/2)
getLowerEnumerationBound (int): Double 0%   (0/1)0%   (0/3)0%   (0/1)
getLowerIntBound (int): Double 0%   (0/1)0%   (0/20)0%   (0/2)
getUpperBound (int): Double 0%   (0/1)0%   (0/54)0%   (0/7)
getUpperDoubleBound (int): Double 0%   (0/1)0%   (0/19)0%   (0/2)
getUpperEnumerationBound (int): Double 0%   (0/1)0%   (0/45)0%   (0/6)
getUpperIntBound (int): Double 0%   (0/1)0%   (0/20)0%   (0/2)
isEnum (int): boolean 0%   (0/1)0%   (0/8)0%   (0/2)
isInteger (int): boolean 0%   (0/1)0%   (0/20)0%   (0/3)
isValidGene (Double, int): boolean 0%   (0/1)0%   (0/26)0%   (0/5)
numberOfDimensions (): int 0%   (0/1)0%   (0/5)0%   (0/1)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.dsexplore.opt4j.representation;
5 
6import org.opt4j.genotype.Bounds;
7 
8import de.uka.ipd.sdq.pcm.designdecision.ContinuousRangeDegree;
9import de.uka.ipd.sdq.pcm.designdecision.DecisionSpace;
10import de.uka.ipd.sdq.pcm.designdecision.DegreeOfFreedomInstance;
11import de.uka.ipd.sdq.pcm.designdecision.DiscreteRangeDegree;
12import de.uka.ipd.sdq.pcm.designdecision.ClassDegree;
13 
14@Deprecated
15class DimensionBounds implements Bounds<Double> {
16        
17 
18        protected DecisionSpace problem;
19 
20        public DimensionBounds(DecisionSpace problem){
21                this.problem = problem;
22                
23        }
24 
25        @Override
26        public Double getLowerBound(int index) {
27                if (DiscreteRangeDegree.class.isInstance(this.problem.getDegreesOfFreedom().get(index))){
28                        return this.getLowerIntBound(index);
29                } else if (ContinuousRangeDegree.class.isInstance(this.problem.getDegreesOfFreedom().get(index)) ){
30                        return this.getLowerDoubleBound(index);
31                } else if (ClassDegree.class.isInstance(this.problem.getDegreesOfFreedom().get(index))){
32                        return this.getLowerEnumerationBound(index);
33                } else 
34                        throw new RuntimeException("Design decision not supported: "+this.problem.getDegreesOfFreedom().get(index).getClass().getName());
35        }
36 
37        @Override
38        public Double getUpperBound(int index) {
39                if (DiscreteRangeDegree.class.isInstance(this.problem.getDegreesOfFreedom().get(index))){
40                        return this.getUpperIntBound(index);
41                } else if (ContinuousRangeDegree.class.isInstance(this.problem.getDegreesOfFreedom().get(index)) ){
42                        return this.getUpperDoubleBound(index);
43                } else if (ClassDegree.class.isInstance(this.problem.getDegreesOfFreedom().get(index))){
44                        return this.getUpperEnumerationBound(index);
45                } else 
46                        throw new RuntimeException("Design decision not supported: "+this.problem.getDegreesOfFreedom().get(index).getClass().getName());
47        }
48        
49 
50        private Double getLowerEnumerationBound(int index) {
51                //Lower bound for enumeration types is always 0.
52                return 0.0;
53        }
54        
55        private Double getUpperEnumerationBound(int index) {
56                int upperEnumerationBound = 0;
57                DegreeOfFreedomInstance degree = this.problem.getDegreesOfFreedom().get(index);
58                if (ClassDegree.class.isInstance(degree)){
59                        upperEnumerationBound = ((ClassDegree)degree).getClassDesignOptions().size()-1;
60                } else {
61                        throw new RuntimeException("Domain of design decision not supported: "+this.problem.getDegreesOfFreedom().get(index).getClass().getName());
62                }
63                
64                return new Double(upperEnumerationBound);
65        }
66        
67        private Double getLowerDoubleBound(int index) {
68                ContinuousRangeDegree range = (ContinuousRangeDegree)this.problem.getDegreesOfFreedom().get(index);
69                return range.isLowerBoundIncluded() ? range.getFrom() : range.getFrom() + Double.MIN_VALUE;
70        }
71 
72        private Double getUpperDoubleBound(int index) {
73                ContinuousRangeDegree range = (ContinuousRangeDegree)this.problem.getDegreesOfFreedom().get(index);
74                return range.isUpperBoundIncluded() ? range.getTo() : range.getTo() - Double.MIN_VALUE;
75        }
76        
77        private Double getLowerIntBound(int index) {
78                DiscreteRangeDegree range = (DiscreteRangeDegree)this.problem.getDegreesOfFreedom().get(index);
79                return Double.valueOf(range.isLowerBoundIncluded() ? range.getFrom() : range.getFrom() + 1);
80        }
81 
82        private Double getUpperIntBound(int index) {
83                DiscreteRangeDegree range = (DiscreteRangeDegree)this.problem.getDegreesOfFreedom().get(index);
84                return Double.valueOf(range.isUpperBoundIncluded() ? range.getTo() : range.getTo() - 1);
85        }
86 
87        public int numberOfDimensions() {
88                //here, the sizes of the arrays have to be the same!
89                return this.problem.getDegreesOfFreedom().size();
90        }
91        
92        public boolean isInteger(int index){
93                return (
94                                ClassDegree.class.isInstance(this.problem.getDegreesOfFreedom().get(index))
95                                || DiscreteRangeDegree.class.isInstance(this.problem.getDegreesOfFreedom().get(index)));
96        }
97        
98        public boolean isEnum(int index){
99                return (
100                                ClassDegree.class.isInstance(this.problem.getDegreesOfFreedom().get(index))
101                                );
102        }
103 
104        /**
105         * Checks whether a single gene is within the bounds specified for the given index
106         * @param doubleGene
107         * @param index
108         * @return
109         */
110        public boolean isValidGene(Double doubleGene, int index) {
111                if (doubleGene.isNaN() || doubleGene.isInfinite()
112                        || doubleGene < this.getLowerBound(index)
113                        || doubleGene > this.getUpperBound(index))
114                        return false;
115                return true;
116        }
117 
118}

[all classes][de.uka.ipd.sdq.dsexplore.opt4j.representation]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov