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

COVERAGE SUMMARY FOR SOURCE FILE [DSEListener.java]

nameclass, %method, %block, %line, %
DSEListener.java0%   (0/1)0%   (0/4)0%   (0/112)0%   (0/23)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DSEListener0%   (0/1)0%   (0/4)0%   (0/112)0%   (0/23)
DSEListener (IProgressMonitor, DSEWorkflowConfiguration): void 0%   (0/1)0%   (0/26)0%   (0/8)
getIteration (): int 0%   (0/1)0%   (0/3)0%   (0/1)
iterationComplete (Optimizer, int): void 0%   (0/1)0%   (0/24)0%   (0/8)
storeIntermediateResults (int): void 0%   (0/1)0%   (0/59)0%   (0/6)

1package de.uka.ipd.sdq.dsexplore.opt4j.start;
2 
3import java.util.ArrayList;
4import java.util.List;
5 
6import org.eclipse.core.runtime.IProgressMonitor;
7import org.opt4j.core.optimizer.Optimizer;
8import org.opt4j.core.optimizer.OptimizerIterationListener;
9 
10import de.uka.ipd.sdq.dsexplore.helper.ResultsWriter;
11import de.uka.ipd.sdq.dsexplore.launch.DSEWorkflowConfiguration;
12import de.uka.ipd.sdq.dsexplore.opt4j.archive.PopulationTracker;
13 
14 
15/**
16 * Adds the possibility to terminate a run in the eclipse Progress view. 
17 * If cancel operation is clicked there, IProgressMonitor.isCanceled evaluates to true and 
18 * the optimisation is asked to terminate after completing the current iteration.
19 * @author Anne
20 *
21 */
22public class DSEListener implements OptimizerIterationListener {
23        
24        int iteration = 0;
25 
26        private IProgressMonitor monitor;
27 
28        private String resultFolder;
29 
30        private boolean asEMF;
31 
32        private boolean asCSV;
33        
34        public DSEListener(IProgressMonitor monitor, DSEWorkflowConfiguration dseConfig) {
35                this.resultFolder = dseConfig.getResultFolder();
36                this.asEMF = dseConfig.isResultsAsEMF();
37                this.asCSV = dseConfig.isResultsAsCSV();
38                this.monitor = monitor;
39                monitor.beginTask("DSE run", dseConfig.getMaxIterations());
40        }
41 
42        @Override
43        public void iterationComplete(Optimizer optimizer, int iteration) {
44                if (this.monitor.isCanceled()){
45                        Opt4JStarter.terminate();
46                        this.monitor.setTaskName("DSE Run cancelling");
47                        this.monitor.done();
48                } else {
49                        monitor.worked(1);
50                        
51                        //printStatistics(iteration);
52                        storeIntermediateResults(iteration);
53                        
54                }
55                this.iteration = iteration;
56 
57        }
58 
59        private void storeIntermediateResults(int iteration) {
60                
61                PopulationTracker individuals = Opt4JStarter.getAllIndividuals();
62                
63                List<Exception> exceptionList = new ArrayList<Exception>();
64                
65                ResultsWriter.writeDSEIndividualsToFile(individuals.getIndividuals(), this.resultFolder+"allCandidates", iteration, this.asEMF, this.asCSV, exceptionList);
66                
67                ResultsWriter.writeDSEIndividualsToFile(Opt4JStarter.getPopulationIndividuals(), this.resultFolder+"population", iteration, this.asEMF, this.asCSV, exceptionList);
68 
69                //ResultsWriter.writeIndividualsToFile(individuals.getParetoOptimalIndividuals(), this.resultFolder+"ownOptimalCandidates", iteration, exceptionList);
70                ResultsWriter.writeIndividualsToFile(Opt4JStarter.getArchiveIndividuals(), this.resultFolder+"archiveCandidates", iteration, exceptionList, this.asEMF, this.asCSV);        
71        }
72 
73 
74        public int getIteration(){
75                return this.iteration;
76        }
77 
78}

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