net.sf.bddbddb
Class BDDRelation

java.lang.Object
  extended by net.sf.bddbddb.Relation
      extended by net.sf.bddbddb.BDDRelation

public class BDDRelation
extends Relation

An implementation of Relation that uses BDDs.

Version:
$Id: BDDRelation.java 650 2006-11-29 08:08:45Z joewhaley $
Author:
jwhaley

Field Summary
static java.lang.String BDD_INPUT_SUFFIX
           
static java.lang.String BDD_OUTPUT_SUFFIX
           
protected  java.util.List domains
          List of BDDDomains that are used in this relation.
protected  net.sf.javabdd.BDD relation
          Value of relation.
static boolean SMART_LOAD
           
protected  BDDSolver solver
          Link to solver.
protected  byte special_type
           
static java.lang.String TUPLES_INPUT_SUFFIX
           
static java.lang.String TUPLES_OUTPUT_SUFFIX
           
 
Fields inherited from class net.sf.bddbddb.Relation
attributes, id, name, negated
 
Method Summary
static java.lang.String activeDomains(net.sf.javabdd.BDD r)
          Return a string representation of the active domains of the given relation.
 boolean add(java.math.BigInteger[] tuple)
          Adds the given tuple to this relation.
 boolean add(int a)
          Add a single to this relation.
 boolean add(int a, int b)
          Add a double to this relation.
 boolean add(int a, int b, int c)
          Add a triple to this relation.
 boolean contains(int k, java.math.BigInteger j)
          Returns true iff this relation contains a tuple where the kth field is value j.
 Relation copy()
          Make a copy of this relation.
 double dsize()
          Return the number of tuples in this relation, in double format.
 void free()
          Free the memory associated with this relation.
 Attribute getAttribute(net.sf.javabdd.BDDDomain d)
          Get the attribute that is assigned to the given BDDDomain.
 net.sf.javabdd.BDD getBDD()
          Return the value of this relation in BDD form.
 net.sf.javabdd.BDDDomain getBDDDomain(Attribute a)
          Get the BDDDomain that matches the given attribute, or null if the attribute hasn't been assigned one yet.
 net.sf.javabdd.BDDDomain getBDDDomain(int i)
          Get the BDDDomain with the given index.
 java.util.List getBDDDomains()
          Returns the list of BDD domains this relation is using.
 net.sf.javabdd.BDDVarSet getDomainSet()
           
 BDDSolver getSolver()
          Get the solver object.
 void initialize()
          Initialize this relation.
 void initialize2()
          Do more initialization.
 TupleIterator iterator()
          Return an iterator over the tuples of this relation.
 TupleIterator iterator(java.math.BigInteger[] j)
          Return an iterator over the tuples where the fields match the values in the given array.
 TupleIterator iterator(int k)
          Return an iterator over the values in the kth field of the relation.
 TupleIterator iterator(int k, java.math.BigInteger j)
          Return an iterator over the tuples where the kth field has value j.
 void load()
          Load this relation from disk in its native format.
 void load(java.lang.String filename)
          Load this relation from the given file.
 void loadTuples()
          Load the tuple form of this relation from disk.
 void loadTuples(java.lang.String filename)
          Load this relation in tuple form from the given file.
 void save()
          Save the current value of this relation to disk in its native format.
static void save(BDDSolver solver, java.lang.String filename, net.sf.javabdd.BDD relation)
          Save a BDD with a valid header.
 void save(java.lang.String filename)
          Save the value of this relation to the given file.
 void saveTuples()
          Save the current value of this relation to disk in tuple form.
 void saveTuples(java.lang.String filename)
          Save the value of this relation in tuple form to the given file.
 void saveTuples(java.lang.String fileName, net.sf.javabdd.BDD relation)
          Save the given relation in tuple form to the given file.
 void setBDD(net.sf.javabdd.BDD b)
          Set the value of this relation from the given BDD.
 void setDomainAssignment(java.util.List newdom)
          Set the BDD domain assignment of this relation to the given one.
 java.lang.String verboseToString()
          Returns a verbose representation of the relation
 boolean verify()
          Verify that the domains for this BDD are correct.
 boolean verify(net.sf.javabdd.BDD r)
          Verify that the domains for the given BDD match this relation.
 
Methods inherited from class net.sf.bddbddb.Relation
elementsToString, fromXMLElement, getAttribNameMap, getAttribute, getAttribute, getAttributes, getConstraints, getNegated, hashCode, makeNegated, numberOfAttributes, setConstraints, size, toString, toXMLElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BDD_INPUT_SUFFIX

public static java.lang.String BDD_INPUT_SUFFIX

BDD_OUTPUT_SUFFIX

public static java.lang.String BDD_OUTPUT_SUFFIX

TUPLES_INPUT_SUFFIX

public static java.lang.String TUPLES_INPUT_SUFFIX

TUPLES_OUTPUT_SUFFIX

public static java.lang.String TUPLES_OUTPUT_SUFFIX

solver

protected BDDSolver solver
Link to solver.


relation

protected net.sf.javabdd.BDD relation
Value of relation.


domains

protected java.util.List domains
List of BDDDomains that are used in this relation. The indices coincide with those of the attributes.


special_type

protected byte special_type

SMART_LOAD

public static boolean SMART_LOAD
Method Detail

initialize

public void initialize()
Description copied from class: Relation
Initialize this relation.

Specified by:
initialize in class Relation

getDomainSet

public net.sf.javabdd.BDDVarSet getDomainSet()

initialize2

public void initialize2()
Do more initialization. This initializes the values of equivalence relations. Called after variable order is set, so the computation is faster.


verify

public boolean verify()
Verify that the domains for this BDD are correct.

Returns:
whether the domains are correct

verify

public boolean verify(net.sf.javabdd.BDD r)
Verify that the domains for the given BDD match this relation.

Parameters:
r - the given BDD
Returns:
whether the domains match

load

public void load()
          throws java.io.IOException
Description copied from class: Relation
Load this relation from disk in its native format.

Specified by:
load in class Relation
Throws:
java.io.IOException

load

public void load(java.lang.String filename)
          throws java.io.IOException
Load this relation from the given file.

Parameters:
filename - the file to load
Throws:
java.io.IOException

loadTuples

public void loadTuples()
                throws java.io.IOException
Description copied from class: Relation
Load the tuple form of this relation from disk.

Specified by:
loadTuples in class Relation
Throws:
java.io.IOException

loadTuples

public void loadTuples(java.lang.String filename)
                throws java.io.IOException
Description copied from class: Relation
Load this relation in tuple form from the given file.

Specified by:
loadTuples in class Relation
Parameters:
filename - the file to load
Throws:
java.io.IOException

save

public void save()
          throws java.io.IOException
Description copied from class: Relation
Save the current value of this relation to disk in its native format.

Specified by:
save in class Relation
Throws:
java.io.IOException

save

public static void save(BDDSolver solver,
                        java.lang.String filename,
                        net.sf.javabdd.BDD relation)
                 throws java.io.IOException
Save a BDD with a valid header.

Parameters:
solver - solver object
filename - filename to save into
relation - BDD to save
Throws:
java.io.IOException

save

public void save(java.lang.String filename)
          throws java.io.IOException
Save the value of this relation to the given file.

Parameters:
filename - name of file to save
Throws:
java.io.IOException

saveTuples

public void saveTuples()
                throws java.io.IOException
Description copied from class: Relation
Save the current value of this relation to disk in tuple form.

Specified by:
saveTuples in class Relation
Throws:
java.io.IOException

saveTuples

public void saveTuples(java.lang.String filename)
                throws java.io.IOException
Save the value of this relation in tuple form to the given file.

Specified by:
saveTuples in class Relation
Parameters:
filename - name of file to save
Throws:
java.io.IOException

saveTuples

public void saveTuples(java.lang.String fileName,
                       net.sf.javabdd.BDD relation)
                throws java.io.IOException
Save the given relation in tuple form to the given file.

Parameters:
fileName - name of file to save
relation - value to save
Throws:
java.io.IOException

activeDomains

public static java.lang.String activeDomains(net.sf.javabdd.BDD r)
Return a string representation of the active domains of the given relation.

Parameters:
r - relation to check
Returns:
string representation of the active domains

dsize

public double dsize()
Description copied from class: Relation
Return the number of tuples in this relation, in double format.

Specified by:
dsize in class Relation
Returns:
number of tuples in relation

iterator

public TupleIterator iterator()
Description copied from class: Relation
Return an iterator over the tuples of this relation.

Specified by:
iterator in class Relation
Returns:
iterator of BigInteger[]

iterator

public TupleIterator iterator(int k)
Description copied from class: Relation
Return an iterator over the values in the kth field of the relation. k is zero-based.

Specified by:
iterator in class Relation
Parameters:
k - zero-based field number
Returns:
iterator of BigInteger[]

iterator

public TupleIterator iterator(int k,
                              java.math.BigInteger j)
Description copied from class: Relation
Return an iterator over the tuples where the kth field has value j. k is zero-based.

Specified by:
iterator in class Relation
Parameters:
k - zero-based field number
j - value
Returns:
iterator of BigInteger[]

iterator

public TupleIterator iterator(java.math.BigInteger[] j)
Description copied from class: Relation
Return an iterator over the tuples where the fields match the values in the given array. A -1 value in the array matches any value.

Specified by:
iterator in class Relation
Parameters:
j - values
Returns:
iterator of BigInteger[]

contains

public boolean contains(int k,
                        java.math.BigInteger j)
Description copied from class: Relation
Returns true iff this relation contains a tuple where the kth field is value j. k is zero-based.

Specified by:
contains in class Relation
Parameters:
k - zero-based field number
j - value
Returns:
whether the given value appears in the given field

add

public boolean add(int a)
Add a single to this relation.

Parameters:
a - first attribute
Returns:
whether this relation changed

add

public boolean add(int a,
                   int b)
Add a double to this relation.

Parameters:
a - first attribute
b - second attribute
Returns:
whether this relation changed

add

public boolean add(int a,
                   int b,
                   int c)
Add a triple to this relation.

Parameters:
a - first attribute
b - second attribute
c - third attribute
Returns:
whether this relation changed

add

public boolean add(java.math.BigInteger[] tuple)
Description copied from class: Relation
Adds the given tuple to this relation. Returns true if the relation changed.

Specified by:
add in class Relation
Parameters:
tuple - new tuple
Returns:
true iff relation changed

getBDD

public net.sf.javabdd.BDD getBDD()
Return the value of this relation in BDD form.

Returns:
BDD form of this relation

setBDD

public void setBDD(net.sf.javabdd.BDD b)
Set the value of this relation from the given BDD.

Parameters:
b - BDD value to set from

getBDDDomain

public net.sf.javabdd.BDDDomain getBDDDomain(int i)
Get the BDDDomain with the given index.

Parameters:
i - index
Returns:
BDDDomain at that index

getBDDDomain

public net.sf.javabdd.BDDDomain getBDDDomain(Attribute a)
Get the BDDDomain that matches the given attribute, or null if the attribute hasn't been assigned one yet.

Parameters:
a - attribute
Returns:
BDDDomain that matches that attribute

getAttribute

public Attribute getAttribute(net.sf.javabdd.BDDDomain d)
Get the attribute that is assigned to the given BDDDomain.

Parameters:
d - BDD domain
Returns:
attribute

getBDDDomains

public java.util.List getBDDDomains()
Returns the list of BDD domains this relation is using.

Returns:
the list of BDDDomains this relation is using

copy

public Relation copy()
Description copied from class: Relation
Make a copy of this relation. The new relation will have the same attributes and a derived name.

Specified by:
copy in class Relation
Returns:
the new relation

free

public void free()
Description copied from class: Relation
Free the memory associated with this relation. After calling this, the relation can no longer be used.

Specified by:
free in class Relation

getSolver

public BDDSolver getSolver()
Get the solver object.

Returns:
solver object

setDomainAssignment

public void setDomainAssignment(java.util.List newdom)
Set the BDD domain assignment of this relation to the given one.

Parameters:
newdom - new BDD domain assignment

verboseToString

public java.lang.String verboseToString()
Description copied from class: Relation
Returns a verbose representation of the relation

Specified by:
verboseToString in class Relation


Copyright © 2004-2008 Stanford SUIF Compiler Group. All Rights Reserved.