de.jstacs.models.discrete.inhomogeneous
Class InhomogeneousDGM

java.lang.Object
  extended by de.jstacs.models.AbstractModel
      extended by de.jstacs.models.discrete.DiscreteGraphicalModel
          extended by de.jstacs.models.discrete.inhomogeneous.InhomogeneousDGM
All Implemented Interfaces:
InstantiableFromParameterSet, Model, Storable, Cloneable
Direct Known Subclasses:
DAGModel

public abstract class InhomogeneousDGM
extends DiscreteGraphicalModel

This class is the main class for all inhomgeneous discrete graphical models (IDGM).

New instances, loaded instances, clones and instance reinstantiated by fromParameterSet() have the default output stream.

Author:
Jens Keilwagen
See Also:
IDGMParameterSet

Field Summary
protected static OutputStream DEFAULT_STREAM
          The default OutputStream
protected  SafeOutputStream sostream
          This stream is used for comments, ... while the training, ... .
 
Fields inherited from class de.jstacs.models.discrete.DiscreteGraphicalModel
params, trained
 
Fields inherited from class de.jstacs.models.AbstractModel
alphabets, length
 
Constructor Summary
InhomogeneousDGM(IDGMParameterSet params)
          The default constructor.
InhomogeneousDGM(StringBuffer representation)
          This is the constructor for Storable.
 
Method Summary
protected  void check(Sequence sequence, int startpos, int endpos)
          Checks some conditions on a sequence.
 InhomogeneousDGM clone()
          Follows the conventions of Object's clone-method.
abstract  String getStructure()
          Returns a string representation of the graph.
protected  void set(DGMParameterSet parameter, boolean trained)
          Sets the parameters as internal parameters and does some essential computations.
 void setOutputStream(OutputStream stream)
          Sets the output stream for the model.
 
Methods inherited from class de.jstacs.models.discrete.DiscreteGraphicalModel
fromXML, getCurrentParameterSet, getDescription, getESS, getFurtherModelInfos, getXMLTag, isTrained, setFurtherModelInfos, toString, toXML
 
Methods inherited from class de.jstacs.models.AbstractModel
emitSample, getAlphabetContainer, getCharacteristics, getLength, getLogProbFor, getLogProbFor, getLogProbFor, getLogProbFor, getLogProbFor, getMaximalMarkovOrder, getPriorTerm, getProbFor, getProbFor, set, setNewAlphabetContainerInstance, train
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.jstacs.models.Model
getInstanceName, getLogPriorTerm, getNumericalCharacteristics, getProbFor, train
 

Field Detail

sostream

protected SafeOutputStream sostream
This stream is used for comments, ... while the training, ... .


DEFAULT_STREAM

protected static final OutputStream DEFAULT_STREAM
The default OutputStream

Constructor Detail

InhomogeneousDGM

public InhomogeneousDGM(IDGMParameterSet params)
                 throws CloneNotSupportedException,
                        IllegalArgumentException,
                        NonParsableException
The default constructor.

Parameters:
params - the parameter set
Throws:
CloneNotSupportedException - if the parameter set could not be cloned
IllegalArgumentException - if the parameter set is not instantiated
NonParsableException - if the parameter set is not parsable

InhomogeneousDGM

public InhomogeneousDGM(StringBuffer representation)
                 throws NonParsableException
This is the constructor for Storable.

Parameters:
representation - the xml representation
Throws:
NonParsableException - if the representation could not be parsed.
Method Detail

clone

public InhomogeneousDGM clone()
                       throws CloneNotSupportedException
Description copied from class: AbstractModel
Follows the conventions of Object's clone-method.

Specified by:
clone in interface Model
Overrides:
clone in class DiscreteGraphicalModel
Returns:
an object, that is a copy of the current AbstractModel (the member-AlphabetContainer isn't deeply cloned since it is assumed to be immutable). The type of the returned object is defined by the class X directly inherited from AbstractModel. Hence X's clone-method should work as:
1. Object o = (X)super.clone(); 2. all additional member variables of o defined by X that are not of simple data-types like int, double, ... , have to be deeply copied 3. return o
Throws:
CloneNotSupportedException

getStructure

public abstract String getStructure()
                             throws NotTrainedException
Returns a string representation of the graph.

Returns:
a string representation of the graph
Throws:
NotTrainedException - if the structure is not set, this can only be the case if the model is not trained

setOutputStream

public void setOutputStream(OutputStream stream)
Sets the output stream for the model. This stream will sometimes be used to write some information about the training/progress/...

Parameters:
stream - the output stream

check

protected void check(Sequence sequence,
                     int startpos,
                     int endpos)
              throws NotTrainedException,
                     IllegalArgumentException
Description copied from class: DiscreteGraphicalModel
Checks some conditions on a sequence.

Overrides:
check in class DiscreteGraphicalModel
Parameters:
sequence - the sequence
startpos - the startposition
endpos - the endposition
Throws:
NotTrainedException - if the model is not trained
IllegalArgumentException - if some constraints are not fulfilled

set

protected void set(DGMParameterSet parameter,
                   boolean trained)
            throws CloneNotSupportedException,
                   NonParsableException
Description copied from class: DiscreteGraphicalModel
Sets the parameters as internal parameters and does some essential computations. Used in fromParameterSet-methods.

Overrides:
set in class DiscreteGraphicalModel
Parameters:
parameter - the new ParameterSet
trained - the indicator for the model
Throws:
CloneNotSupportedException - if the parmeterSet could not be cloned
NonParsableException - if the parameters of the model could not be parsed