- Timestamp:
- 07/14/11 14:19:22 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDcalcCoverage.java
r124 r127 5 5 import java.util.List; 6 6 7 import de.ugoe.cs.eventbench.coverage.CoverageCalculatorObserved; 7 8 import de.ugoe.cs.eventbench.coverage.CoverageCalculatorProcess; 8 9 import de.ugoe.cs.eventbench.data.Event; … … 17 18 @Override 18 19 public void run(List<Object> parameters) { 19 String modelname; 20 String modelname; 20 21 String[] sequenceNames; 21 22 int minLength; 22 23 int maxLength; 24 String observedName = "sequences"; 23 25 try { 24 26 modelname = (String) parameters.get(0); … … 26 28 minLength = Integer.parseInt((String) parameters.get(2)); 27 29 maxLength = Integer.parseInt((String) parameters.get(3)); 30 if( parameters.size()==5 ) { 31 observedName = (String) parameters.get(1); 32 } 28 33 } 29 34 catch (Exception e) { … … 32 37 33 38 IStochasticProcess process = null; 39 Collection<List<? extends Event<?>>> observedSequences = null; 34 40 Collection<List<? extends Event<?>>> sequences = null; 35 41 Object dataObjectProcess = GlobalDataContainer.getInstance().getData(modelname); 42 Object dataObjectObserved = GlobalDataContainer.getInstance().getData(observedName); 36 43 if( dataObjectProcess==null ) { 37 Console.println("Model " + modelname + " not found in storage."); 44 Console.printerrln("Model " + modelname + " not found in storage."); 45 return; 38 46 } 39 else if( !(dataObjectProcess instanceof IStochasticProcess) ) { 40 Console.println("Object " + modelname + " not of type MarkovModel!"); 41 } else { 42 Console.print("seqName"); 47 if( !(dataObjectProcess instanceof IStochasticProcess) ) { 48 Console.printerrln("Object " + modelname + " not of type MarkovModel!"); 49 return; 50 } 51 if( dataObjectObserved==null ) { 52 Console.printerrln("Observed sequences not found in storage."); 53 return; 54 } 55 if( !(dataObjectObserved instanceof Collection<?>) ) { 56 // weak instance check! 57 Console.printerrln("Object " + observedName + " not a Collection!"); 58 return; 59 } 60 process = (IStochasticProcess) dataObjectProcess; 61 observedSequences = (Collection<List<? extends Event<?>>>) dataObjectObserved; 62 63 64 Console.print("seqName"); 65 for( int length=minLength ; length<=maxLength ; length++) { 66 Console.print(";numObs_" + length); 67 Console.print(";numCov_" + length); 68 Console.print(";numNew_" + length); 69 Console.print(";numPos_" + length); 70 Console.print(";all_" + length); 71 Console.print(";pos_" + length); 72 Console.print(";poswei_" + length); 73 Console.print(";obs_" + length); 74 Console.print(";obswei_" + length); 75 Console.print(";new_" + length); 76 Console.print(";newpos_" + length); 77 Console.print(";newposwei_" + length); 78 } 79 Console.println(""); 80 for( String sequenceName : sequenceNames ) { 81 Object dataObjectSequences = GlobalDataContainer.getInstance().getData(sequenceName); 82 if( dataObjectSequences==null ) { 83 Console.println("Sequences " + sequenceName + " not found in storage."); 84 } 85 else if( !(dataObjectSequences instanceof Collection<?>) ) { 86 // cannot really perform type check at runtime! this is an approximative substitute 87 Console.printerrln("Object " + sequenceName + "not of type Collection<?>!"); 88 return; 89 } 90 sequences = (Collection<List<? extends Event<?>>>) dataObjectSequences; 91 Console.print(sequenceName); 43 92 for( int length=minLength ; length<=maxLength ; length++) { 44 Console.print(";all_" + length); 45 Console.print(";pos_" + length); 46 Console.print(";wei_" + length); 93 CoverageCalculatorProcess covCalcProc = new CoverageCalculatorProcess(process, sequences, length); 94 CoverageCalculatorObserved covCalcObs = new CoverageCalculatorObserved(observedSequences, sequences, length); 95 Console.print(";" + covCalcObs.getNumObserved()); 96 Console.print(";" + covCalcObs.getNumCovered()); 97 Console.print(";" + covCalcObs.getNumNew()); 98 Console.print(";" + covCalcProc.getNumPossible()); 99 Console.print(";" + covCalcProc.getCoverageAllNoWeight()); 100 Console.print(";" + covCalcProc.getCoveragePossibleNoWeight()); 101 Console.print(";" + covCalcProc.getCoveragePossibleWeight()); 102 Console.print(";" + covCalcObs.getCoverageObserved()); 103 Console.print(";" + covCalcObs.getCoverageObservedWeigth(process)); 104 Console.print(";" + covCalcObs.getNewPercentage()); 105 Console.print(";" + covCalcObs.getCoveragePossibleNew(process)); 106 Console.print(";" + covCalcObs.getCoveragePossibleNewWeight(process)); 47 107 } 48 108 Console.println(""); 49 for( String sequenceName : sequenceNames ) {50 Object dataObjectSequences = GlobalDataContainer.getInstance().getData(sequenceName);51 if( dataObjectSequences==null ) {52 Console.println("Sequences " + sequenceName + " not found in storage.");53 }54 else if( !(dataObjectSequences instanceof Collection<?>) ) {55 // cannot really perform type check at runtime! this is an approximative substitute56 Console.println("Object " + sequenceName + "not of type Collection<?>!");57 }58 59 process = (IStochasticProcess) dataObjectProcess;60 sequences = (Collection<List<? extends Event<?>>>) dataObjectSequences;61 Console.print(sequenceName);62 for( int length=minLength ; length<=maxLength ; length++) {63 CoverageCalculatorProcess covCalc = new CoverageCalculatorProcess(process, sequences, length);64 Console.print(";" + covCalc.getCoverageAllNoWeight());65 Console.print(";" + covCalc.getCoveragePossibleNoWeight());66 Console.print(";" + covCalc.getCoveragePossibleWeight());67 }68 Console.println("");69 }70 109 } 71 110 }
Note: See TracChangeset
for help on using the changeset viewer.