Changeset 182


Ignore:
Timestamp:
09/14/11 18:51:16 (13 years ago)
Author:
sherbold
Message:
  • already trained de.ugoe.cs.eventbench.model.TrieBasedModel? instances can now be updated with further sequences to allow model reinforcement
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/TrieBasedModel.java

    r176 r182  
    4848         * </p> 
    4949         */ 
    50         protected Trie<Event<?>> trie; 
     50        protected Trie<Event<?>> trie = null; 
    5151 
    5252        /** 
     
    7979         * <p> 
    8080         * Trains the model by generating a trie from which probabilities are 
    81          * calculated. 
     81         * calculated. The trie is newly generated based solely on the passed 
     82         * sequences. If an existing model should only be updated, use 
     83         * {@link #update(Collection)} instead. 
    8284         * </p> 
    8385         *  
     
    8688         */ 
    8789        public void train(Collection<List<Event<?>>> sequences) { 
    88                 trie = new Trie<Event<?>>(); 
    89  
     90                trie = null; 
     91                update(sequences); 
     92        } 
     93 
     94        /** 
     95         * <p> 
     96         * Trains the model by updating the trie from which the probabilities are 
     97         * calculated. This function updates an existing trie. In case no trie 
     98         * exists yet, a new trie is generated and the function behaves like 
     99         * {@link #train(Collection)}. 
     100         * </p> 
     101         *  
     102         * @param sequences 
     103         *            training data 
     104         */ 
     105        public void update(Collection<List<Event<?>>> sequences) { 
     106                if (trie == null) { 
     107                        trie = new Trie<Event<?>>(); 
     108                } 
    90109                for (List<Event<?>> sequence : sequences) { 
    91110                        List<Event<?>> currentSequence = new LinkedList<Event<?>>(sequence); // defensive 
     
    308327        } 
    309328 
    310         /* (non-Javadoc) 
     329        /* 
     330         * (non-Javadoc) 
     331         *  
    311332         * @see de.ugoe.cs.eventbench.models.IStochasticProcess#getNumFOMStates() 
    312333         */ 
Note: See TracChangeset for help on using the changeset viewer.