edu.vt.marian.search
Class MergeSequencer

java.lang.Object
  |
  +--edu.vt.marian.search.MergeSequencer

public class MergeSequencer
extends java.lang.Object
implements SetCollectionSequencer

A MergeSequencer is a Sequencer designed to work on a few component sets. Since the number of sets is small, we can perform a linear search for the set with the next highest element more efficiently than any fancier search.

We expect the weights in any WtdObjSet to drop off, not smoothly, but as a stairstep function. Thus instead of searching for the top element among the (scaled) component sets, we begin be searching for the top two sets, and search only when the top weight in the second set exceeds that in the top set.

See Also:
Sequencer, Enumeration

Constructor Summary
MergeSequencer(int ExpectedNumSets, long classSize, edu.vt.marian.common.Debug d)
          Create a merging sequencer for an expected number of sets.
MergeSequencer(long classSize, edu.vt.marian.common.Debug d)
          Create a merging sequencer for an unknown number of sets.
 
Method Summary
 int addSet(WtdObjSet set)
          Add a new component set to the Sequencer with no scaling constant.
 int expectedNumElts()
          Return the expected number of unique elements in the result sequence.
 boolean hasMoreElements()
           
 int maxNumElts()
          Return the maximum number of unique elements in the result sequence.
 java.lang.Object nextElement()
           
 java.lang.String profile()
          Return a short human-readable string that quickly describes this set.
 java.lang.String toString()
          Return a human-readable string for this entire set (may be large).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MergeSequencer

public MergeSequencer(long classSize,
                      edu.vt.marian.common.Debug d)
Create a merging sequencer for an unknown number of sets.

MergeSequencer

public MergeSequencer(int ExpectedNumSets,
                      long classSize,
                      edu.vt.marian.common.Debug d)
Create a merging sequencer for an expected number of sets.
Parameters:
expectedNumSets - As many sets as we expect to add. Does not need to be perfectly accurate.
Method Detail

addSet

public int addSet(WtdObjSet set)
Add a new component set to the Sequencer with no scaling constant.
Specified by:
addSet in interface SetCollectionSequencer
Parameters:
set - a component weighted object set.
Returns:
ReturnValues.OK -- set was added without problems.
anything else -- problems.

expectedNumElts

public int expectedNumElts()
Return the expected number of unique elements in the result sequence. NOTE: The statistics here are drawn from the hypergeometric distribution. Follow code and documentation in the C++ file "search/woset_coll.cc."

maxNumElts

public int maxNumElts()
Return the maximum number of unique elements in the result sequence. (This is just the sum of all the elements in each component set,)

nextElement

public java.lang.Object nextElement()

hasMoreElements

public boolean hasMoreElements()

toString

public java.lang.String toString()
Return a human-readable string for this entire set (may be large).
Overrides:
toString in class java.lang.Object

profile

public java.lang.String profile()
Return a short human-readable string that quickly describes this set.