Changeset 127


Ignore:
Timestamp:
07/14/11 14:19:22 (13 years ago)
Author:
sherbold
Message:
  • command calcCoverage now includes coverage criteria based on the observed sequences
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDcalcCoverage.java

    r124 r127  
    55import java.util.List; 
    66 
     7import de.ugoe.cs.eventbench.coverage.CoverageCalculatorObserved; 
    78import de.ugoe.cs.eventbench.coverage.CoverageCalculatorProcess; 
    89import de.ugoe.cs.eventbench.data.Event; 
     
    1718        @Override 
    1819        public void run(List<Object> parameters) { 
    19                 String modelname; 
     20                String modelname;                
    2021                String[] sequenceNames; 
    2122                int minLength; 
    2223                int maxLength; 
     24                String observedName = "sequences"; 
    2325                try { 
    2426                        modelname = (String) parameters.get(0); 
     
    2628                        minLength = Integer.parseInt((String) parameters.get(2)); 
    2729                        maxLength = Integer.parseInt((String) parameters.get(3)); 
     30                        if( parameters.size()==5 ) { 
     31                                observedName = (String) parameters.get(1); 
     32                        } 
    2833                } 
    2934                catch (Exception e) { 
     
    3237                 
    3338                IStochasticProcess process = null;  
     39                Collection<List<? extends Event<?>>> observedSequences = null; 
    3440                Collection<List<? extends Event<?>>> sequences = null; 
    3541                Object dataObjectProcess = GlobalDataContainer.getInstance().getData(modelname); 
     42                Object dataObjectObserved = GlobalDataContainer.getInstance().getData(observedName); 
    3643                if( dataObjectProcess==null ) { 
    37                         Console.println("Model " + modelname + " not found in storage."); 
     44                        Console.printerrln("Model " + modelname + " not found in storage."); 
     45                        return; 
    3846                } 
    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); 
    4392                        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)); 
    47107                        } 
    48108                        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 substitute 
    56                                         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                         } 
    70109                } 
    71110        } 
Note: See TracChangeset for help on using the changeset viewer.