- Timestamp:
- 09/28/11 03:03:13 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDcalcEntropy.java
r171 r209 1 1 package de.ugoe.cs.eventbench.commands; 2 2 3 import java.security.InvalidParameterException; 3 4 import java.util.List; … … 18 19 public class CMDcalcEntropy implements Command { 19 20 20 /* (non-Javadoc) 21 /* 22 * (non-Javadoc) 23 * 21 24 * @see de.ugoe.cs.util.console.Command#help() 22 25 */ … … 26 29 } 27 30 28 /* (non-Javadoc) 31 /* 32 * (non-Javadoc) 33 * 29 34 * @see de.ugoe.cs.util.console.Command#run(java.util.List) 30 35 */ … … 37 42 throw new InvalidParameterException(); 38 43 } 39 40 FirstOrderMarkovModel model = null; 41 Object dataObject = GlobalDataContainer.getInstance().getData(modelname); 42 if( dataObject==null ) { 44 45 FirstOrderMarkovModel model = null; 46 Object dataObject = GlobalDataContainer.getInstance() 47 .getData(modelname); 48 if (dataObject == null) { 43 49 Console.println("Model " + modelname + "not found in storage."); 50 return; 44 51 } 45 else if( !(dataObject instanceof FirstOrderMarkovModel) ) { 46 Console.println("Object " + modelname + " is not a first-order Markov model!"); 47 } else { 48 model = (FirstOrderMarkovModel) dataObject; 49 double entropy = model.calcEntropy(); 50 if( !Double.isNaN(entropy) ) { 51 Console.println("entropy: " + entropy); 52 } 52 if (!(dataObject instanceof FirstOrderMarkovModel)) { 53 Console.println("Object " + modelname 54 + " is not a first-order Markov model!"); 55 return; 56 } 57 model = (FirstOrderMarkovModel) dataObject; 58 double entropy = model.calcEntropy(); 59 if (!Double.isNaN(entropy)) { 60 Console.println("entropy: " + entropy); 53 61 } 54 62 }
Note: See TracChangeset
for help on using the changeset viewer.