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

COVERAGE SUMMARY FOR SOURCE FILE [AbstractStartingPopulationHeuristic.java]

nameclass, %method, %block, %line, %
AbstractStartingPopulationHeuristic.java0%   (0/1)0%   (0/3)0%   (0/112)0%   (0/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractStartingPopulationHeuristic0%   (0/1)0%   (0/3)0%   (0/112)0%   (0/28)
AbstractStartingPopulationHeuristic (DSEWorkflowConfiguration): void 0%   (0/1)0%   (0/3)0%   (0/2)
getAllocationContexts (): ArrayList 0%   (0/1)0%   (0/50)0%   (0/13)
getResourceContainers (): ArrayList 0%   (0/1)0%   (0/59)0%   (0/13)

1package de.uka.ipd.sdq.dsexplore.opt4j.optimizer.heuristic.startingPopulation;
2 
3import java.util.ArrayList;
4import java.util.Collection;
5 
6import org.eclipse.emf.ecore.EObject;
7 
8import de.uka.ipd.sdq.dsexplore.launch.DSEWorkflowConfiguration;
9import de.uka.ipd.sdq.dsexplore.opt4j.start.Opt4JStarter;
10import de.uka.ipd.sdq.pcm.allocation.AllocationContext;
11import de.uka.ipd.sdq.pcm.core.entity.Entity;
12import de.uka.ipd.sdq.pcm.designdecision.AllocationDegree;
13import de.uka.ipd.sdq.pcm.designdecision.DegreeOfFreedomInstance;
14import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer;
15 
16/**
17 * Class defines methods to get all resource containers and allocation contexts
18 * @author Tom Beyer
19 *
20 */
21public abstract class AbstractStartingPopulationHeuristic implements IStartingPoulationHeuristic {
22        
23        /**
24         * Resource containers found by getResourceContainers(). Caching used to here to avoid
25         * Unnecessary calculations
26         */
27        ArrayList<ResourceContainer> resourceContainers;
28        
29        /**
30         * Allocation contexts found by getAllocationContexts(). Caching used to here to avoid
31         * Unnecessary calculations
32         */
33        ArrayList<AllocationContext> allocationContexts;
34 
35        public AbstractStartingPopulationHeuristic(DSEWorkflowConfiguration configuration) {
36                super();
37        }
38        
39        /**
40         * @return All resource containers based on the current Opt4J Problem (via Opt4JStarter.getProblem())
41         */
42        protected ArrayList<ResourceContainer> getResourceContainers() {
43                if (resourceContainers != null) {
44                        return resourceContainers;
45                } else {
46                        ArrayList<ResourceContainer> resourceContainers = new ArrayList<ResourceContainer>();
47                        
48                        Collection<DegreeOfFreedomInstance> degreesOfFreedom = Opt4JStarter.getProblem().getDesignDecisions();
49                        for (DegreeOfFreedomInstance DegreeOfFreedomInstance : degreesOfFreedom) {
50                                if (DegreeOfFreedomInstance instanceof AllocationDegree) {
51                                        AllocationDegree allocationDegree = (AllocationDegree) DegreeOfFreedomInstance;
52                                        for (EObject entity : allocationDegree.getClassDesignOptions()) {
53                                                if (entity instanceof ResourceContainer) {
54                                                        if (!resourceContainers.contains(entity)) {
55                                                                resourceContainers.add((ResourceContainer) entity);
56                                                        }
57                                                }
58                                        }
59                                }
60                        }
61                        this.resourceContainers = resourceContainers;
62                        return resourceContainers;
63                }
64        }
65        
66        /**
67         * @return All allocation contexts based on the current Opt4J Problem (via Opt4JStarter.getProblem())
68         */
69        protected ArrayList<AllocationContext> getAllocationContexts() {
70                if (allocationContexts != null) {
71                        return allocationContexts;
72                } else {
73                        ArrayList<AllocationContext> allocationContexts = new ArrayList<AllocationContext>();
74                        Collection<DegreeOfFreedomInstance> degreesOfFreedom = Opt4JStarter.getProblem().getDesignDecisions();
75                        for (DegreeOfFreedomInstance DegreeOfFreedomInstance : degreesOfFreedom) {
76                                if (DegreeOfFreedomInstance instanceof AllocationDegree) {
77                                        AllocationDegree allocationDegree = (AllocationDegree) DegreeOfFreedomInstance;
78                                        EObject entity = allocationDegree.getPrimaryChanged();
79                                        if (entity instanceof AllocationContext) {
80                                                if (!allocationContexts.contains(entity)) {
81                                                        allocationContexts.add((AllocationContext) entity);
82                                                }
83                                        }
84                                }
85                        }
86                        this.allocationContexts = allocationContexts;
87                        return allocationContexts;
88                }
89        }
90 
91}

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