Changeset 129


Ignore:
Timestamp:
07/20/11 11:13:50 (13 years ago)
Author:
sherbold
Message:
  • renamed de.ugoe.cs.eventbench.models.IStochasticProcess.getNumStates() to getNumSymbols()
  • renamed de.ugoe.cs.eventbench.models.IStochasticProcess.getStateStrings() to getSymbolStrings()

+ added de.ugoe.cs.eventbench.models.IStochasticProcess.getNumFOMStates(); this function returns the number states an equivalent first-order Markov model would have
+ added methods that count the ancestors of trie leaves, which is in turn used to determine the FOM-equivalent

Location:
trunk/EventBenchCore/src/de/ugoe/cs/eventbench
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchCore/src/de/ugoe/cs/eventbench/coverage/SequenceTools.java

    r123 r129  
    6969         */ 
    7070        public static long numSequences(IStochasticProcess process, int length) { 
    71                 return (long) Math.pow(process.getNumStates(), length); 
     71                return (long) Math.pow(process.getNumSymbols(), length); 
    7272        } 
    7373 
  • trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/IStochasticProcess.java

    r118 r129  
    107107         * @return number of states 
    108108         */ 
    109         public int getNumStates(); 
     109        public int getNumSymbols(); 
    110110 
    111111        /** 
     
    116116         * @return string representation for all known states 
    117117         */ 
    118         public String[] getStateStrings(); 
     118        public String[] getSymbolStrings(); 
     119         
     120        /** 
     121         * <p> 
     122         * Returns the number of states the process would have if it would be flattened through state-splitting to a first-order Markov model. 
     123         * </p> 
     124         * <p> 
     125         * If it is not possible to flatten the model, -1 is returned. 
     126         * </p> 
     127         *  
     128         * @return number of states an equivalent FOM would have; -1 is not available 
     129         */ 
     130        public int getNumFOMStates(); 
    119131 
    120132        /** 
  • trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/Trie.java

    r106 r129  
    33import java.io.Serializable; 
    44import java.util.Collection; 
     5import java.util.HashSet; 
    56import java.util.LinkedHashSet; 
    67import java.util.LinkedList; 
    78import java.util.List; 
     9import java.util.Set; 
    810 
    911import de.ugoe.cs.util.StringTools; 
     
    364366         * </p> 
    365367         *  
    366          * @return 
     368         * @return number of symbols contained in the trie 
    367369         */ 
    368370        public int getNumSymbols() { 
    369371                return knownSymbols.size(); 
    370372        } 
     373 
     374        /** 
     375         * <p> 
     376         * Returns the number of trie nodes that are ancestors of a leaf. This is 
     377         * the equivalent to the number of states a first-order markov model would 
     378         * have. 
     379         * <p> 
     380         *  
     381         * @return number of trie nodes that are ancestors of leafs. 
     382         */ 
     383        public int getNumLeafAncestors() { 
     384                Set<TrieNode<T>> ancestors = new HashSet<TrieNode<T>>(); 
     385                rootNode.getLeafAncestors(ancestors); 
     386                return ancestors.size(); 
     387        } 
    371388} 
  • trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/TrieBasedModel.java

    r118 r129  
    179179         */ 
    180180        @Override 
    181         public int getNumStates() { 
     181        public int getNumSymbols() { 
    182182                return trie.getNumSymbols(); 
    183183        } 
     
    189189         */ 
    190190        @Override 
    191         public String[] getStateStrings() { 
    192                 String[] stateStrings = new String[getNumStates()]; 
     191        public String[] getSymbolStrings() { 
     192                String[] stateStrings = new String[getNumSymbols()]; 
    193193                int i = 0; 
    194194                for (Event<?> symbol : trie.getKnownSymbols()) { 
     
    309309        } 
    310310 
     311        /* (non-Javadoc) 
     312         * @see de.ugoe.cs.eventbench.models.IStochasticProcess#getNumFOMStates() 
     313         */ 
     314        @Override 
     315        public int getNumFOMStates() { 
     316                return trie.getNumLeafAncestors(); 
     317        } 
    311318} 
  • trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/TrieNode.java

    r106 r129  
    66import java.util.LinkedList; 
    77import java.util.List; 
     8import java.util.Set; 
    89 
    910import de.ugoe.cs.eventbench.models.Trie.Edge; 
     
    286287                } 
    287288        } 
     289 
     290        /** 
     291         * <p> 
     292         * Checks if the node is a leaf. 
     293         * </p> 
     294         *  
     295         * @return true if the node is a leaf, false otherwise. 
     296         */ 
     297        protected boolean isLeaf() { 
     298                return children.isEmpty(); 
     299        } 
     300 
     301        /** 
     302         * <p> 
     303         * Recursive methods that collects all nodes that are ancestors of leafs and 
     304         * stores them in the set. 
     305         * </p> 
     306         *  
     307         * @param ancestors 
     308         *            set of all ancestors of leafs 
     309         */ 
     310        protected void getLeafAncestors(Set<TrieNode<T>> ancestors) { 
     311                boolean isAncestor = false; 
     312                for (TrieNode<T> child : children) { 
     313                        child.getLeafAncestors(ancestors); 
     314                        isAncestor |= child.isLeaf(); 
     315                } 
     316                if (isAncestor) { 
     317                        ancestors.add(this); 
     318                } 
     319        } 
    288320} 
Note: See TracChangeset for help on using the changeset viewer.