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

COVERAGE SUMMARY FOR SOURCE FILE [ExperimentRunner.java]

nameclass, %method, %block, %line, %
ExperimentRunner.java0%   (0/1)0%   (0/4)0%   (0/124)0%   (0/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ExperimentRunner0%   (0/1)0%   (0/4)0%   (0/124)0%   (0/28)
<static initializer> 0%   (0/1)0%   (0/5)0%   (0/3)
ExperimentRunner (): void 0%   (0/1)0%   (0/3)0%   (0/1)
run (SimuComModel, long): double 0%   (0/1)0%   (0/17)0%   (0/5)
setupStopConditions (SimuComModel, long): void 0%   (0/1)0%   (0/99)0%   (0/20)

1package de.uka.ipd.sdq.simucomframework;
2 
3import org.apache.log4j.Logger;
4 
5import de.uka.ipd.sdq.simucomframework.model.SimuComModel;
6import de.uka.ipd.sdq.statistics.IBatchAlgorithm;
7import de.uka.ipd.sdq.statistics.PhiMixingBatchAlgorithm;
8import de.uka.ipd.sdq.statistics.StaticBatchAlgorithm;
9import de.uka.ipd.sdq.statistics.estimation.SampleMeanEstimator;
10 
11/**
12 * Helper class to actually perform a simulation run using desmo-j
13 * @author Steffen Becker
14 *
15 */
16public class ExperimentRunner {
17        private static Logger logger = 
18                Logger.getLogger(ExperimentRunner.class.getName());
19        
20        /**
21         * Run the given simulation model until the given simulation time
22         * is reached
23         * @param model Simulation model to execute
24         * @param simTime Maximum simulation time to run the simulation for
25         */
26        public static double run(SimuComModel model, long simTime) {
27                logger.debug("Setting up experiment runner");
28                setupStopConditions(model, simTime);
29                
30                // measure elapsed time for the simulation
31                double startTime = System.nanoTime();
32                
33                model.getSimulationControl().start();
34                
35                return System.nanoTime() - startTime;
36        }
37 
38        /**
39         * @param model
40         * @param simTime
41         */
42        private static void setupStopConditions(SimuComModel model, long simTime) {
43                if (model.getConfig().getMaxMeasurementsCount() <= 0 && simTime <= 0) {
44                        logger.debug("Deactivating maximum simulation time stop condition per user request");
45                        model.getSimulationControl().setMaxSimTime(0); 
46                } else {
47                        logger.debug("Enabling simulation stop condition at maximum simulation time of "+simTime);
48                        if (simTime > 0)
49                                model.getSimulationControl().setMaxSimTime(simTime); // set end of simulation at 1500 time
50                                                                                                                                        // units
51                }
52                
53                model.getSimulationControl().addStopCondition(new MaxMeasurementsStopCondition(model));
54                
55                // Add confidence stop condition if configured
56                if (model.getConfiguration().isUseConfidence()) {
57                        double level = model.getConfiguration().getConfidenceLevel() / 100.0;
58                        double halfWidth = model.getConfiguration().getConfidenceHalfWidth() / 100.0;
59                        
60                        IBatchAlgorithm batchAlgorithm = null;
61                        if (model.getConfiguration().isAutomaticBatches() ){
62                                batchAlgorithm = new PhiMixingBatchAlgorithm();
63                        } else {
64                                int batchSize = model.getConfiguration().getBatchSize();
65                                int minNumberOfBatches = model.getConfiguration().getMinNumberOfBatches();
66                                batchAlgorithm = new StaticBatchAlgorithm(batchSize, minNumberOfBatches);
67                        }
68                        
69                        model.getSimulationControl().addStopCondition(
70                                        new ConfidenceStopCondition(model, batchAlgorithm,
71                                                        new SampleMeanEstimator(), level, halfWidth));
72        }
73}
74}

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