Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.jstacs.models.discrete
Class Constraint

    java.lang.Object
      de.jstacs.models.discrete.Constraint

All Implemented Interfaces:
  Storable

Direct Known Subclasses:
  InhConstraint

    public abstract class Constraint

extends Object
implements Storable

The main class for all constraints on models. This class centralize all specific constraint from a partitioning constraint.

Author:
  Jens Keilwagen

Field Summary
`protected double[]` | `counts` The counts for each specific constraint
`protected double[]` | `freq` The frequencies estimated from the counts
`protected int[]` | `usedPositions` The used positions

Constructor Summary
`Constraint(int[] usedPositions, int n)` The main constructor.
`Constraint(StringBuffer xml)` The constructor for creating an object from an StringBuffer.

Method Summary
`void` | `add(int index, double weight)` Adds the `weight` to the count with index `index`.
`void` | `add(Sequence seq, int start, double weight)` This method determines the specific constraint that is fulfilled by the sequence and adds the `weight` to the specific counter.
`protected abstract void` | `appendAdditionalInfo(StringBuffer xml)` This method appends additional information that are not stored in the base class to the StringBuffer.
`protected Constraint` | `clone()`
`abstract void` | `estimate(double ess)` Estimates the (smoothed) relative frequencies using the ess.
`protected void` | `estimateUnConditional(int start, int end, double pc, boolean exceptionWhenNoData)` Estimates unconditionally.
`protected abstract void` | `extractAdditionalInfo(StringBuffer xml)` This method parses additional information from the StringBuffer that are not parsed in the base class.
`double` | `getCount(int index)` Returns the current count with index `index`
`double` | `getFreq(int index)` Returns the current frequency with index `index`
`double` | `getFreq(Sequence seq, int start)` This method determines the specific constraint that is fullfilled by the sequence beginning at `start`.
`int` | `getMarginalOrder()` Returns the marginal order i.e. the number of used random variables.
`int` | `getNumberOfSpecificConstraints()` Returns the number of specific constraint.
`int` | `getPosition(int index)` Returns the position with index `index`
`int[]` | `getPositions()` Returns a clone of array of used positions.
`protected abstract String` | `getXMLTag()` Returns the XML-tag that is used for the class to en- or decode.
`void` | `reset()` This method resets all member variables the are in someway counters, frequencies, ...
`abstract int` | `satisfiesSpecificConstraint(Sequence seq, int start)` This method returns the index of the specific constraint that is fullfilled by the sequence beginning at `start`.
`abstract String` | `toString()`
`StringBuffer` | `toXML()` This method returns an XML-representation of an instance of the implementing class.

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### counts

    protected double[] counts

  The counts for each specific constraint

### freq

    protected double[] freq

  The frequencies estimated from the counts

### usedPositions

    protected int[] usedPositions

  The used positions

Constructor Detail

### Constraint

    public Constraint(int[] usedPositions,
                      int n)

  The main constructor. Checks that each position is used maximally once.

  Parameters:
    `usedPositions` - the used positions (will be cloned), hva to be non-negative
    `n` - the number of specific constraints

### Constraint

    public Constraint(StringBuffer xml)
               throws NonParsableException

  The constructor for creating an object from an StringBuffer. The StringBuffer contains the constraint in XML-format.

  Parameters:
    `xml` - the StringBuffer
  Throws:
    `NonParsableException` - if the StringBuffer is not parseable

Method Detail

### add

    public void add(int index,
                    double weight)

  Adds the `weight` to the count with index `index`.

  Parameters:
    `index` - the index
    `weight` - the weight

### add

    public void add(Sequence seq,
                    int start,
                    double weight)

  This method determines the specific constraint that is fulfilled by the sequence and adds the `weight` to the specific counter.

  Parameters:
    `seq` - the sequence
    `start` - the start position
    `weight` - the weight for the sequence

### clone

    protected Constraint clone()
                        throws CloneNotSupportedException

  Overrides:
    `clone` in class `Object`
  Throws:
    `CloneNotSupportedException`

### estimate

    public abstract void estimate(double ess)

  Estimates the (smoothed) relative frequencies using the ess.

  Parameters:
    `ess` - the ESS

### estimateUnConditional

    protected void estimateUnConditional(int start,
                                         int end,
                                         double pc,
                                         boolean exceptionWhenNoData)

  Estimates unconditionally.

  Parameters:
    `start` - the start index
    `end` - the end index
    `pc` - the pseudocount for each parameter
    `exceptionWhenNoData` - if `true` an (runtime) exception is thrown if no data was available to estimate the parameters

### appendAdditionalInfo

    protected abstract void appendAdditionalInfo(StringBuffer xml)

  This method appends additional information that are not stored in the base class to the StringBuffer.

  Parameters:
    `xml` - the StringBuffer that is used for appending additional information

### getCount

    public double getCount(int index)

  Returns the current count with index `index`

  Parameters:
    `index` - the index
  Returns:
    the current count

### getFreq

    public double getFreq(int index)

  Returns the current frequency with index `index`

  Parameters:
    `index` - the index
  Returns:
    the current frequency

### getFreq

    public double getFreq(Sequence seq,
                          int start)

  This method determines the specific constraint that is fullfilled by the sequence beginning at `start`.

  Parameters:
    `seq` - the sequence
    `start` - the start position
  Returns:
    the according frequency

### getMarginalOrder

    public int getMarginalOrder()

  Returns the marginal order i.e. the number of used random variables.

  Returns:
    the marginal order

### getNumberOfSpecificConstraints

    public int getNumberOfSpecificConstraints()

  Returns the number of specific constraint.

  Returns:
    the number of specific constraint

### getPosition

    public int getPosition(int index)

  Returns the position with index `index`

  Parameters:
    `index` - the index
  Returns:
    the position with index `index`

### getPositions

    public int[] getPositions()

  Returns a clone of array of used positions.

  Returns:
    a clone of array of used positions

### getXMLTag

    protected abstract String getXMLTag()

  Returns the XML-tag that is used for the class to en- or decode.

  Returns:
    the XML-tag that is used for the class to en- or decode

### reset

    public void reset()

  This method resets all member variables the are in someway counters, frequencies, ...

### satisfiesSpecificConstraint

    public abstract int satisfiesSpecificConstraint(Sequence seq,
                                                    int start)

  This method returns the index of the specific constraint that is fullfilled by the sequence beginning at `start`.

  Parameters:
    `seq` - the sequence
    `start` - the start position
  Returns:
    the index of the fulfilled, specific constraint

### extractAdditionalInfo

    protected abstract void extractAdditionalInfo(StringBuffer xml)
                                           throws NonParsableException

  This method parses additional information from the StringBuffer that are not parsed in the base class.

  Parameters:
    `xml` - the StringBuffer to parse
  Throws:
    `NonParsableException` - if something with the parsing went wrong

### toString

    public abstract String toString()

  Overrides:
    `toString` in class `Object`

### toXML

    public StringBuffer toXML()

  Description copied from interface: `Storable`
  This method returns an XML-representation of an instance of the implementing class.

  Specified by:
    `toXML` in interface `Storable`
  Returns:
    the XML-representation

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD