Class SimpleMarkovModel

    • Constructor Detail

      • SimpleMarkovModel

        public SimpleMarkovModel​(int heads,
                                 Alphabet emissionAlpha,
                                 java.lang.String name)
      • SimpleMarkovModel

        public SimpleMarkovModel​(int heads,
                                 Alphabet emissionAlpha)
        Deprecated.
    • Method Detail

      • getChangeSupport

        protected ChangeSupport getChangeSupport​(ChangeType ct)
        Description copied from class: AbstractChangeable
        Called to retrieve the ChangeSupport for this object.

        Your implementation of this method should have the following structure:

         ChangeSupport cs = super.getChangeSupport(ct);
        
         if(someForwarder == null && ct.isMatching(SomeInterface.SomeChangeType)) {
           someForwarder = new ChangeForwarder(...
        
           this.stateVariable.addChangeListener(someForwarder, VariableInterface.AChange);
         }
        
         return cs;
         
        It is usual for the forwarding listeners (someForwarder in this example) to be transient and lazily instantiated. Be sure to register & unregister the forwarder in the code that does the ChangeEvent handling in setter methods.
        Overrides:
        getChangeSupport in class AbstractChangeable
      • stateAlphabet

        public FiniteAlphabet stateAlphabet()
        Description copied from interface: MarkovModel
        FiniteAlphabet of the states.

        We are modeling a finite-state-machine, so there will be a finite set of states.

        The MagicalState returned by getMagicalState is always contained within this as the start/end state.

        Specified by:
        stateAlphabet in interface MarkovModel
        Returns:
        the alphabet over states
      • heads

        public int heads()
        Description copied from interface: MarkovModel
        The number of heads on this model.

        Each head consumes a single SymbolList. A single-head model just consumes/ emits a single sequence. A two-head model performs alignment between two sequences (e.g. smith-waterman). Models with more heads do more interesting things.

        heads() should equal advance().length.

        Specified by:
        heads in interface MarkovModel
        Returns:
        the number of heads in this model.
      • advance

        public int[] advance()
        Description copied from interface: MarkovModel
        The maximum advance for this model.

        Each head consumes a single SymbolList. However, the states that advance through that SymbolList may emit more than one symbol at a time. This array give the maximum advance in each direction.

        Be sure to return a new array each time this is called. This protects the internal state of the object from someone modifying the advance array. Be sure to update this as/when states modify their advance arrays and as/when states are added or removed
        Specified by:
        advance in interface MarkovModel
        Returns:
        the maximum advance of all states for all heads
      • setWeights

        public void setWeights​(State source,
                               Distribution dist)
                        throws IllegalSymbolException,
                               IllegalAlphabetException,
                               ChangeVetoException
        Use this methods to customize the transition probabilities.

        By default, the distribution P(destination | source) is a totally free distribution. This allows the different probabilities to vary. If you wish to change this behaviour (for example, to make one set of transition probabilities equal to another), then use this method to replace the Distribution with one of your own.

        Specified by:
        setWeights in interface MarkovModel
        Parameters:
        source - source State
        dist - the new Distribution over the transition probabilites from source
        Throws:
        IllegalSymbolException - if source is not a member of this model
        IllegalAlphabetException - if dist is not a distribution over the states returned by model.transitionsFrom(source)
        ChangeVetoException - if a listener vetoed this change
      • createTransition

        public void createTransition​(State from,
                                     State to)
                              throws IllegalSymbolException,
                                     ChangeVetoException
        Description copied from interface: MarkovModel
        Makes a transition between two states legal.

        This should inform each TransitionListener that a transition is to be created using preCreateTransition, and if none of the listeners fire a ChangeVetoException, it should create the transition, and then inform each TransitionListener with postCreateTransition.

        Specified by:
        createTransition in interface MarkovModel
        Parameters:
        from - the State currently occupied
        to - the State to move to
        Throws:
        IllegalSymbolException - if either from or to are not legal states
        ChangeVetoException - if creating the transition is vetoed
      • destroyTransition

        public void destroyTransition​(State from,
                                      State to)
                               throws IllegalSymbolException,
                                      ChangeVetoException
        Description copied from interface: MarkovModel
        Breaks a transition between two states legal.

        This should inform each TransitionListener that a transition is to be broken using preDestroyTransition, and if none of the listeners fire a ChangeVetoException, it should break the transition, and then inform each TransitionListener with postDestroyTransition.

        Specified by:
        destroyTransition in interface MarkovModel
        Parameters:
        from - the State currently occupied
        to - the State to move to
        Throws:
        IllegalSymbolException - if either from or to are not legal states
        ChangeVetoException - if breaking the transition is vetoed
      • containsTransition

        public boolean containsTransition​(State from,
                                          State to)
                                   throws IllegalSymbolException
        Description copied from interface: MarkovModel
        Returns wether a transition exists or not.
        Specified by:
        containsTransition in interface MarkovModel
        Parameters:
        from - the transitin source
        to - the transition destination
        Returns:
        true/false depending on wether this model has the transition
        Throws:
        IllegalSymbolException - if either from or to are not states in this model
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object