Ignore:
Timestamp:
08/16/12 12:34:24 (12 years ago)
Author:
sherbold
Message:
  • countless adaptations throughout nearly all components to remove errors introduced due to the refactoring of the event core
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/quest-core-usageprofiles/src/main/java/de/ugoe/cs/quest/usageprofiles/TrieBasedModel.java

    r518 r547  
    4949         * </p> 
    5050         */ 
    51         protected Trie<Event<?>> trie = null; 
     51        protected Trie<Event> trie = null; 
    5252 
    5353        /** 
     
    101101         *             thrown is sequences is null 
    102102         */ 
    103         public void train(Collection<List<? extends Event<?>>> sequences) { 
     103        public void train(Collection<List<Event>> sequences) { 
    104104                trie = null; 
    105105                update(sequences); 
     
    119119         *             thrown is sequences is null 
    120120         */ 
    121         public void update(Collection<List<? extends Event<?>>> sequences) { 
     121        public void update(Collection<List<Event>> sequences) { 
    122122                if (sequences == null) { 
    123123                        throw new InvalidParameterException("sequences must not be null"); 
    124124                } 
    125125                if (trie == null) { 
    126                         trie = new Trie<Event<?>>(); 
    127                 } 
    128                 for (List<? extends Event<?>> sequence : sequences) { 
    129                         List<Event<?>> currentSequence = new LinkedList<Event<?>>(sequence); // defensive 
     126                        trie = new Trie<Event>(); 
     127                } 
     128                for (List<Event> sequence : sequences) { 
     129                        List<Event> currentSequence = new LinkedList<Event>(sequence); // defensive 
    130130                                                                                                                                                                        // copy 
    131131                        currentSequence.add(0, Event.STARTEVENT); 
     
    142142         */ 
    143143        @Override 
    144         public List<? extends Event<?>> randomSequence() { 
     144        public List<Event> randomSequence() { 
    145145                return randomSequence(Integer.MAX_VALUE, true); 
    146146        } 
     
    152152         */ 
    153153        @Override 
    154         public List<? extends Event<?>> randomSequence(int maxLength, 
     154        public List<Event> randomSequence(int maxLength, 
    155155                        boolean validEnd) { 
    156                 List<Event<?>> sequence = new LinkedList<Event<?>>(); 
     156                List<Event> sequence = new LinkedList<Event>(); 
    157157                if (trie != null) { 
    158158                        boolean endFound = false; 
    159159                        while (!endFound) { // outer loop for length checking 
    160                                 sequence = new LinkedList<Event<?>>(); 
    161                                 IncompleteMemory<Event<?>> context = new IncompleteMemory<Event<?>>( 
     160                                sequence = new LinkedList<Event>(); 
     161                                IncompleteMemory<Event> context = new IncompleteMemory<Event>( 
    162162                                                trieOrder - 1); 
    163163                                context.add(Event.STARTEVENT); 
     
    166166                                        double randVal = r.nextDouble(); 
    167167                                        double probSum = 0.0; 
    168                                         List<Event<?>> currentContext = context.getLast(trieOrder); 
    169                                         for (Event<?> symbol : trie.getKnownSymbols()) { 
     168                                        List<Event> currentContext = context.getLast(trieOrder); 
     169                                        for (Event symbol : trie.getKnownSymbols()) { 
    170170                                                probSum += getProbability(currentContext, symbol); 
    171171                                                if (probSum >= randVal) { 
     
    262262                String[] stateStrings = new String[getNumSymbols()]; 
    263263                int i = 0; 
    264                 for (Event<?> symbol : trie.getKnownSymbols()) { 
     264                for (Event symbol : trie.getKnownSymbols()) { 
    265265                        if (symbol.toString() == null) { 
    266266                                stateStrings[i] = "null"; 
     
    279279         */ 
    280280        @Override 
    281         public Collection<? extends Event<?>> getEvents() { 
    282                 if (trie == null) { 
    283                         return new HashSet<Event<?>>(); 
     281        public Collection<Event> getEvents() { 
     282                if (trie == null) { 
     283                        return new HashSet<Event>(); 
    284284                } else { 
    285285                        return trie.getKnownSymbols(); 
     
    294294         */ 
    295295        @Override 
    296         public Collection<List<? extends Event<?>>> generateSequences(int length) { 
     296        public Collection<List<Event>> generateSequences(int length) { 
    297297                return generateSequences(length, false); 
    298298        } 
     
    306306         */ 
    307307        @Override 
    308         public Set<List<? extends Event<?>>> generateSequences(int length, 
     308        public Set<List<Event>> generateSequences(int length, 
    309309                        boolean fromStart) { 
    310                 Set<List<? extends Event<?>>> sequenceSet = new LinkedHashSet<List<? extends Event<?>>>(); 
     310                Set<List<Event>> sequenceSet = new LinkedHashSet<List<Event>>(); 
    311311                if (length < 1) { 
    312312                        throw new InvalidParameterException( 
     
    315315                if (length == 1) { 
    316316                        if (fromStart) { 
    317                                 List<Event<?>> subSeq = new LinkedList<Event<?>>(); 
     317                                List<Event> subSeq = new LinkedList<Event>(); 
    318318                                subSeq.add(Event.STARTEVENT); 
    319319                                sequenceSet.add(subSeq); 
    320320                        } else { 
    321                                 for (Event<?> event : getEvents()) { 
    322                                         List<Event<?>> subSeq = new LinkedList<Event<?>>(); 
     321                                for (Event event : getEvents()) { 
     322                                        List<Event> subSeq = new LinkedList<Event>(); 
    323323                                        subSeq.add(event); 
    324324                                        sequenceSet.add(subSeq); 
     
    327327                        return sequenceSet; 
    328328                } 
    329                 Collection<? extends Event<?>> events = getEvents(); 
    330                 Collection<List<? extends Event<?>>> seqsShorter = generateSequences( 
     329                Collection<Event> events = getEvents(); 
     330                Collection<List<Event>> seqsShorter = generateSequences( 
    331331                                length - 1, fromStart); 
    332                 for (Event<?> event : events) { 
    333                         for (List<? extends Event<?>> seqShorter : seqsShorter) { 
    334                                 Event<?> lastEvent = event; 
     332                for (Event event : events) { 
     333                        for (List<Event> seqShorter : seqsShorter) { 
     334                                Event lastEvent = event; 
    335335                                if (getProbability(seqShorter, lastEvent) > 0.0) { 
    336                                         List<Event<?>> subSeq = new ArrayList<Event<?>>(seqShorter); 
     336                                        List<Event> subSeq = new ArrayList<Event>(seqShorter); 
    337337                                        subSeq.add(lastEvent); 
    338338                                        sequenceSet.add(subSeq); 
     
    351351         */ 
    352352        @Override 
    353         public Collection<List<? extends Event<?>>> generateValidSequences( 
     353        public Collection<List<Event>> generateValidSequences( 
    354354                        int length) { 
    355355                // check for min-length implicitly done by generateSequences 
    356                 Collection<List<? extends Event<?>>> allSequences = generateSequences( 
     356                Collection<List<Event>> allSequences = generateSequences( 
    357357                                length, true); 
    358                 Collection<List<? extends Event<?>>> validSequences = new LinkedHashSet<List<? extends Event<?>>>(); 
    359                 for (List<? extends Event<?>> sequence : allSequences) { 
     358                Collection<List<Event>> validSequences = new LinkedHashSet<List<Event>>(); 
     359                for (List<Event> sequence : allSequences) { 
    360360                        if (sequence.size() == length 
    361361                                        && Event.ENDEVENT.equals(sequence.get(sequence.size() - 1))) { 
     
    374374         */ 
    375375        @Override 
    376         public double getProbability(List<? extends Event<?>> sequence) { 
     376        public double getProbability(List<Event> sequence) { 
    377377                if (sequence == null) { 
    378378                        throw new InvalidParameterException("sequence must not be null"); 
    379379                } 
    380380                double prob = 1.0; 
    381                 List<Event<?>> context = new LinkedList<Event<?>>(); 
    382                 for (Event<?> event : sequence) { 
     381                List<Event> context = new LinkedList<Event>(); 
     382                for (Event event : sequence) { 
    383383                        prob *= getProbability(context, event); 
    384384                        context.add(event); 
Note: See TracChangeset for help on using the changeset viewer.