wpi.associations.arminer
Class ARMinerItemset

java.lang.Object
  extended bywpi.associations.arminer.ARMinerItemset
All Implemented Interfaces:
java.io.Serializable

public class ARMinerItemset
extends java.lang.Object
implements java.io.Serializable

ARMinerItemset.java

An itemset is an ordered list of integers that identify items coupled with a float value representing the support of the itemset as a percentage.

See Also:
Serialized Form

Field Summary
private  int capacity
          The capacity of the itemset.
private  int index
          Internal index used for cycling through the itemset's items.
private  boolean mark
          The mark of the itemset.
private  int[] set
          The itemset.
private  int size
          The number of items in the itemset.
private static int SIZE_INCR
           
private  int sum
           
private  float support
          The support of the itemset.
private  long weight
          The weight of the itemset.
 
Constructor Summary
ARMinerItemset()
          Creates a new empty itemset.
ARMinerItemset(ARMinerItemset itemset)
          Create a new itemset by copying a given one.
ARMinerItemset(int c)
          Create a new empty itemset of specified capacity.
 
Method Summary
 ARMinerItemset add(ARMinerItemset itemset)
          Return a new ARMinerItemset that contains all those items that appear in this ARMinerItemset and in itemset.
 boolean addItem(int item)
          Add a new item to the itemset.
 boolean canCombineWith(ARMinerItemset itemset)
          Check whether two itemsets can be combined.
 ARMinerItemset combineWith(ARMinerItemset itemset)
          Combine two itemsets into a new one that will contain all the items in the first itemset plus the last item in the second itemset.
 boolean doesIntersect(ARMinerItemset itemset)
          Return true if this itemset has items in common with itemset.
 int getFirstItem()
          Return first item in set.
 int getItem(int i)
          Return i-th item in set.
 int getNextItem()
          Return next item in set.
 float getSupport()
          Return support of itemset.
 long getWeight()
          Return weight of itemset.
 boolean hasAttributes(java.util.Vector attributes)
          Return true if this itemset has the set of attributes with itemset.
 boolean hasMoreItems()
          Return true if there are more items in the itemset.
 void incrementWeight()
          Increment the weight of the itemset.
 boolean isEqualTo(ARMinerItemset itemset)
          Checks equality with a given itemset.
 boolean isIncludedIn(ARMinerItemset itemset)
          Checks inclusion in a given itemset.
 boolean isMarked()
          Return itemset mark.
static void main(java.lang.String[] args)
          for testing purposes only !!!
 boolean mark()
          Mark the itemset.
static void pruneDuplicates(java.util.Vector v)
          Remove all duplicate itemsets from the vector v
static void pruneNonMaximal(java.util.Vector v)
          Remove all non-maximal itemsets from the vector v
 boolean removeItem(int item)
          Removes a given item from the itemset.
 boolean removeLastItem()
          Removes last item (which has the greatest value) from the itemset.
 void setSupport(float newSupport)
          Set the support of the itemset.
 void setWeight(long newWeight)
          Set the weight of the itemset.
 int size()
          Return size of itemset.
 ARMinerItemset subtract(ARMinerItemset itemset)
          Return a new ARMinerItemset that contains only those items that do not appear in itemset.
 int sum()
          Gets the sum of the items in the itemset
 java.lang.String toString()
          Return a String representation of the ARMinerItemset.
 boolean unmark()
          Unmark the itemset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SIZE_INCR

private static final int SIZE_INCR
See Also:
Constant Field Values

capacity

private int capacity
The capacity of the itemset.


size

private int size
The number of items in the itemset.


set

private int[] set
The itemset.


support

private float support
The support of the itemset.


weight

private long weight
The weight of the itemset.


mark

private boolean mark
The mark of the itemset.


index

private int index
Internal index used for cycling through the itemset's items.


sum

private int sum
Constructor Detail

ARMinerItemset

public ARMinerItemset()
Creates a new empty itemset.


ARMinerItemset

public ARMinerItemset(int c)
Create a new empty itemset of specified capacity.

Parameters:
c - the capacity of the itemset
Throws:
java.lang.IllegalArgumentException - c is negative or zero

ARMinerItemset

public ARMinerItemset(ARMinerItemset itemset)
Create a new itemset by copying a given one.

Parameters:
itemset - the itemset to be copied
Throws:
java.lang.IllegalArgumentException - itemset is null
Method Detail

getSupport

public float getSupport()
Return support of itemset.


getWeight

public long getWeight()
Return weight of itemset.


getItem

public int getItem(int i)
Return i-th item in set.

Parameters:
i - the index of the item to get
Returns:
the i-th item
Throws:
java.lang.IndexOutOfBoundsException - i is an invalid index

getFirstItem

public int getFirstItem()
Return first item in set.

Returns:
first item
Throws:
java.lang.IndexOutOfBoundsException - there is no first item

getNextItem

public int getNextItem()
Return next item in set.

Returns:
next item
Throws:
java.lang.IndexOutOfBoundsException - there is no next item

hasMoreItems

public boolean hasMoreItems()
Return true if there are more items in the itemset. You can call this method to find out whether you can call getNext without raising an exception.

Returns:
true if there are more items, false if not

size

public int size()
Return size of itemset.

Returns:
size of itemset

hasAttributes

public boolean hasAttributes(java.util.Vector attributes)
Return true if this itemset has the set of attributes with itemset.

Returns:
true if itemset contains items of this itemset, false otherwise.
Throws:
java.lang.IllegalArgumentException - itemset is null

doesIntersect

public boolean doesIntersect(ARMinerItemset itemset)
Return true if this itemset has items in common with itemset.

Parameters:
itemset - the itemset with which we compare
Returns:
true if itemset contains items of this itemset, false otherwise.
Throws:
java.lang.IllegalArgumentException - itemset is null

subtract

public ARMinerItemset subtract(ARMinerItemset itemset)
Return a new ARMinerItemset that contains only those items that do not appear in itemset.

Parameters:
itemset - the itemset whose items we want to subtract
Returns:
an ARMinerItemset containing only those items of this ARMinerItemset that do not appear in itemset.
Throws:
java.lang.IllegalArgumentException - itemset is null

add

public ARMinerItemset add(ARMinerItemset itemset)
Return a new ARMinerItemset that contains all those items that appear in this ARMinerItemset and in itemset.

Parameters:
itemset - the itemset whose items we want to add
Returns:
an ARMinerItemset containing all those items that appear in this ARMinerItemset and in itemset.
Throws:
java.lang.IllegalArgumentException - itemset is null

addItem

public boolean addItem(int item)
Add a new item to the itemset.

Parameters:
item - the item to be added
Returns:
true if item was added, false if it wasn't added (was already there!)
Throws:
java.lang.IllegalArgumentException - item is <= 0

removeItem

public boolean removeItem(int item)
Removes a given item from the itemset.

Parameters:
item - the item to remove
Returns:
true if item was removed, false if it wasn't removed (was not found in itemset!)
Throws:
java.lang.IllegalArgumentException - item is <= 0

removeLastItem

public boolean removeLastItem()
Removes last item (which has the greatest value) from the itemset.

Returns:
true if item was removed, false if it wasn't removed (the itemset was empty)

setSupport

public void setSupport(float newSupport)
Set the support of the itemset.

Parameters:
newSupport - the support of the itemset
Throws:
java.lang.IllegalArgumentException - newSupport is < 0 or > 100

setWeight

public void setWeight(long newWeight)
Set the weight of the itemset.

Parameters:
newWeight - the weight of the itemset
Throws:
java.lang.IllegalArgumentException - newWeight is < 0

incrementWeight

public void incrementWeight()
Increment the weight of the itemset.


isEqualTo

public boolean isEqualTo(ARMinerItemset itemset)
Checks equality with a given itemset.

Parameters:
itemset - the itemset against which we test for equality
Throws:
java.lang.IllegalArgumentException - itemset is null

isIncludedIn

public boolean isIncludedIn(ARMinerItemset itemset)
Checks inclusion in a given itemset.

Parameters:
itemset - the itemset against which we test for inclusion
Throws:
java.lang.IllegalArgumentException - itemset is null

mark

public boolean mark()
Mark the itemset.

Returns:
true if itemset was already marked, false otherwise

unmark

public boolean unmark()
Unmark the itemset.

Returns:
true if itemset was marked, false otherwise

isMarked

public boolean isMarked()
Return itemset mark.

Returns:
true if itemset is marked, false otherwise

toString

public java.lang.String toString()
Return a String representation of the ARMinerItemset.

Returns:
String representation of ARMinerItemset

canCombineWith

public boolean canCombineWith(ARMinerItemset itemset)
Check whether two itemsets can be combined. Two itemsets can be combined if they differ only in the last item.

Parameters:
itemset - itemset with which to combine
Returns:
true if the itemsets can be combined, false otherwise
Throws:
java.lang.IllegalArgumentException - itemset is null

combineWith

public ARMinerItemset combineWith(ARMinerItemset itemset)
Combine two itemsets into a new one that will contain all the items in the first itemset plus the last item in the second itemset.

Parameters:
itemset - itemset with which to combine
Returns:
an itemset that combines the two itemsets as described above
Throws:
java.lang.IllegalArgumentException - itemset is null

sum

public int sum()
Gets the sum of the items in the itemset


pruneNonMaximal

public static void pruneNonMaximal(java.util.Vector v)
Remove all non-maximal itemsets from the vector v

Parameters:
v - the collection of itemsets

pruneDuplicates

public static void pruneDuplicates(java.util.Vector v)
Remove all duplicate itemsets from the vector v

Parameters:
v - the collection of itemsets

main

public static void main(java.lang.String[] args)
for testing purposes only !!!