net.sf.javabdd
Class TypedBDDFactory

java.lang.Object
  extended by net.sf.javabdd.BDDFactory
      extended by net.sf.javabdd.TypedBDDFactory

public class TypedBDDFactory
extends BDDFactory

This BDD factory keeps track of what domains each BDD uses, and complains if you try to do an operation where the domains do not match.

Version:
$Id: TypedBDDFactory.java 456 2006-07-17 05:19:54Z joewhaley $
Author:
John Whaley
See Also:
BDDFactory

Nested Class Summary
 class TypedBDDFactory.TypedBDD
          A BDD with types (domains) attached to it.
 class TypedBDDFactory.TypedBDDVarSet
           
 
Nested classes/interfaces inherited from class net.sf.javabdd.BDDFactory
BDDFactory.BDDOp, BDDFactory.CacheStats, BDDFactory.GCStats, BDDFactory.LoadHash, BDDFactory.ReorderMethod, BDDFactory.ReorderStats
 
Field Summary
static Comparator domain_comparator
           
static String REVISION
           
 
Fields inherited from class net.sf.javabdd.BDDFactory
and, biimp, cachestats, diff, domain, fdvarnum, firstbddvar, gc_callbacks, gcstats, imp, invimp, less, nand, nor, or, reorder_callbacks, REORDER_NONE, REORDER_RANDOM, REORDER_SIFT, REORDER_SIFTITE, REORDER_WIN2, REORDER_WIN2ITE, REORDER_WIN3, REORDER_WIN3ITE, reorderstats, resize_callbacks, tokenizer, xor
 
Constructor Summary
TypedBDDFactory(BDDFactory f)
           
 
Method Summary
 void addVarBlock(int first, int last, boolean fixed)
          Adds a new variable block for reordering.
 Set allDomains()
           
 void autoReorder(BDDFactory.ReorderMethod method)
          Enables automatic reordering.
 void autoReorder(BDDFactory.ReorderMethod method, int max)
          Enables automatic reordering with the given (maximum) number of reorderings.
 void clearError()
          Clears any outstanding error condition.
 void clearVarBlocks()
          Clears all the variable blocks that have been defined by calls to addVarBlock.
protected  BDDBitVector createBitVector(int a)
          Implementors must implement this factory method to create BDDBitVector objects of the correct type.
protected  BDDDomain createDomain(int a, BigInteger b)
          Implementors must implement this factory method to create BDDDomain objects of the correct type.
 void disableReorder()
          Disable automatic reordering until enableReorder is called.
static String domainNames(Set dom)
           
 void done()
          This function frees all memory used by the BDD package and resets the package to its uninitialized state.
 void enableReorder()
          Enable automatic reordering after a call to disableReorder.
 BDDDomain[] extDomain(long[] domainSizes)
           
 int getCacheSize()
          Get the current size of the cache, in entries.
 int getNodeNum()
          Get the number of active nodes in use.
 int getNodeTableSize()
          Get the number of allocated nodes.
 BDDFactory.ReorderMethod getReorderMethod()
          Returns the current reorder method as defined by autoReorder.
 int getReorderTimes()
          Returns the number of allowed reorderings left.
 String getVersion()
          Get the BDD library version.
static BDDFactory init(int nodenum, int cachesize)
           
protected  void initialize(int nodenum, int cachesize)
          Compare to bdd_init.
 boolean isInitialized()
          Returns true if this BDD factory is initialized, false otherwise.
 BDD ithVar(int var)
          Returns a BDD representing the I'th variable.
 int level2Var(int level)
          Convert from a BDD level to a BDD variable.
 BDD load(String filename)
          Loads a BDD from a file.
static Map makeMap()
           
 BDDPairing makePair()
          Make a new BDDPairing object.
static Set makeSet()
           
static Set makeSet(Set s)
           
 BDD nithVar(int var)
          Returns a BDD representing the negation of the I'th variable.
 int nodeCount(Collection r)
          Counts the number of shared nodes in a collection of BDDs.
 BDD one()
          Get the constant true BDD.
 void printAll()
          Prints all used entries in the node table.
 void printOrder()
          Prints an indented list of the variable blocks.
 void printStat()
          Print cache statistics.
 void printTable(BDD b)
          Prints the node table entries used by a BDD.
 void reorder(BDDFactory.ReorderMethod m)
          Reorder the BDD with the given method.
 int reorderGain()
          Calculate the gain in size after a reordering.
 int reorderVerbose(int v)
          Enables verbose information about reordering.
 void save(String filename, BDD var)
          Saves a BDD to a file.
 double setCacheRatio(double x)
          Sets the cache ratio for the operator caches.
 int setCacheSize(int size)
          Sets cache size.
 void setError(int code)
          Sets the error condition.
 double setIncreaseFactor(double x)
          Set factor by which to increase node table after a garbage collection.
 int setMaxIncrease(int x)
          Set maximum number of nodes by which to increase node table after a garbage collection.
 int setMaxNodeNum(int size)
          Set the maximum available number of BDD nodes.
 double setMinFreeNodes(double x)
          Set minimum percentage of nodes to be reclaimed after a garbage collection.
 int setNodeTableSize(int size)
          Sets the node table size.
 int setVarNum(int num)
          Set the number of used BDD variables.
 void setVarOrder(int[] neworder)
          This function sets the current variable order to be the one defined by neworder.
 void swapVar(int v1, int v2)
          Swap two variables.
 int var2Level(int var)
          Convert from a BDD variable to a BDD level.
 void varBlockAll()
          Add a variable block for all variables.
 int varNum()
          Returns the number of defined variables.
 BDDDomain whichDomain(int var)
           
 BDD zero()
          Get the constant false BDD.
 
Methods inherited from class net.sf.javabdd.BDDFactory
addVarBlock, bdd_default_gbchandler, bdd_default_reohandler, bdd_default_reshandler, buildCube, buildCube, buildVector, buildVector, buildVector, buildVector, clearAllDomains, constantVector, constantVector, doCallbacks, emptySet, extDomain, extDomain, extDomain, extDomain, extVarNum, gbc_handler, getCacheStats, getDomain, getGCStats, getProperty, getReorderStats, getVarOrder, init, isZDD, load, load, loadhash_get, makePair, makePair, makePair, makeSet, makeSet, makeVarOrdering, numberOfDomains, overlapDomain, readNext, registerCallback, registerGCCallback, registerReorderCallback, registerResizeCallback, reset, resize_handler, save_rec_original, save_rec, save, universe, unregisterCallback, unregisterGCCallback, unregisterReorderCallback, unregisterResizeCallback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

domain_comparator

public static final Comparator domain_comparator

REVISION

public static final String REVISION
See Also:
Constant Field Values
Constructor Detail

TypedBDDFactory

public TypedBDDFactory(BDDFactory f)
Method Detail

init

public static BDDFactory init(int nodenum,
                              int cachesize)

zero

public BDD zero()
Description copied from class: BDDFactory

Get the constant false BDD.

Compare to bdd_false.

Specified by:
zero in class BDDFactory

one

public BDD one()
Description copied from class: BDDFactory

Get the constant true BDD.

Compare to bdd_true.

Specified by:
one in class BDDFactory

initialize

protected void initialize(int nodenum,
                          int cachesize)
Description copied from class: BDDFactory

Compare to bdd_init.

Specified by:
initialize in class BDDFactory
Parameters:
nodenum - the initial number of BDD nodes
cachesize - the size of caches used by the BDD operators

isInitialized

public boolean isInitialized()
Description copied from class: BDDFactory

Returns true if this BDD factory is initialized, false otherwise.

Compare to bdd_isrunning.

Specified by:
isInitialized in class BDDFactory
Returns:
true if this BDD factory is initialized

done

public void done()
Description copied from class: BDDFactory

This function frees all memory used by the BDD package and resets the package to its uninitialized state. The BDD package is no longer usable after this call.

Compare to bdd_done.

Specified by:
done in class BDDFactory

setError

public void setError(int code)
Description copied from class: BDDFactory

Sets the error condition. This will cause the BDD package to throw an exception at the next garbage collection.

Specified by:
setError in class BDDFactory
Parameters:
code - the error code to set

clearError

public void clearError()
Description copied from class: BDDFactory

Clears any outstanding error condition.

Specified by:
clearError in class BDDFactory

setMaxNodeNum

public int setMaxNodeNum(int size)
Description copied from class: BDDFactory

Set the maximum available number of BDD nodes.

Compare to bdd_setmaxnodenum.

Specified by:
setMaxNodeNum in class BDDFactory
Parameters:
size - maximum number of nodes
Returns:
old value

setNodeTableSize

public int setNodeTableSize(int size)
Description copied from class: BDDFactory

Sets the node table size.

Specified by:
setNodeTableSize in class BDDFactory
Parameters:
size - new size of table
Returns:
old size of table

setCacheSize

public int setCacheSize(int size)
Description copied from class: BDDFactory

Sets cache size.

Specified by:
setCacheSize in class BDDFactory
Returns:
old cache size

setMinFreeNodes

public double setMinFreeNodes(double x)
Description copied from class: BDDFactory

Set minimum percentage of nodes to be reclaimed after a garbage collection. If this percentage is not reclaimed, the node table will be grown. The range of x is 0..1. The default is .20.

Compare to bdd_setminfreenodes.

Specified by:
setMinFreeNodes in class BDDFactory
Parameters:
x - number from 0 to 1
Returns:
old value

setIncreaseFactor

public double setIncreaseFactor(double x)
Description copied from class: BDDFactory

Set factor by which to increase node table after a garbage collection. The amount of growth is still limited by setMaxIncrease().

Specified by:
setIncreaseFactor in class BDDFactory
Parameters:
x - factor by which to increase node table after GC
Returns:
old value

setMaxIncrease

public int setMaxIncrease(int x)
Description copied from class: BDDFactory

Set maximum number of nodes by which to increase node table after a garbage collection.

Compare to bdd_setmaxincrease.

Specified by:
setMaxIncrease in class BDDFactory
Parameters:
x - maximum number of nodes by which to increase node table
Returns:
old value

setCacheRatio

public double setCacheRatio(double x)
Description copied from class: BDDFactory

Sets the cache ratio for the operator caches. When the node table grows, operator caches will also grow to maintain the ratio.

Compare to bdd_setcacheratio.

Specified by:
setCacheRatio in class BDDFactory
Parameters:
x - cache ratio

varNum

public int varNum()
Description copied from class: BDDFactory

Returns the number of defined variables.

Compare to bdd_varnum.

Specified by:
varNum in class BDDFactory

setVarNum

public int setVarNum(int num)
Description copied from class: BDDFactory

Set the number of used BDD variables. It can be called more than one time, but only to increase the number of variables.

Compare to bdd_setvarnum.

Specified by:
setVarNum in class BDDFactory
Parameters:
num - new number of BDD variables
Returns:
old number of BDD variables

whichDomain

public BDDDomain whichDomain(int var)

ithVar

public BDD ithVar(int var)
Description copied from class: BDDFactory

Returns a BDD representing the I'th variable. (One node with the children true and false.) The requested variable must be in the (zero-indexed) range defined by setVarNum.

Compare to bdd_ithvar.

Specified by:
ithVar in class BDDFactory
Parameters:
var - the variable number
Returns:
the I'th variable on success, otherwise the constant false BDD

nithVar

public BDD nithVar(int var)
Description copied from class: BDDFactory

Returns a BDD representing the negation of the I'th variable. (One node with the children false and true.) The requested variable must be in the (zero-indexed) range defined by setVarNum.

Compare to bdd_nithvar.

Specified by:
nithVar in class BDDFactory
Parameters:
var - the variable number
Returns:
the negated I'th variable on success, otherwise the constant false BDD

printAll

public void printAll()
Description copied from class: BDDFactory

Prints all used entries in the node table.

Compare to bdd_printall.

Specified by:
printAll in class BDDFactory

printTable

public void printTable(BDD b)
Description copied from class: BDDFactory

Prints the node table entries used by a BDD.

Compare to bdd_printtable.

Specified by:
printTable in class BDDFactory

load

public BDD load(String filename)
         throws IOException
Description copied from class: BDDFactory

Loads a BDD from a file.

Compare to bdd_load.

Overrides:
load in class BDDFactory
Throws:
IOException

save

public void save(String filename,
                 BDD var)
          throws IOException
Description copied from class: BDDFactory

Saves a BDD to a file.

Compare to bdd_save.

Overrides:
save in class BDDFactory
Throws:
IOException

level2Var

public int level2Var(int level)
Description copied from class: BDDFactory

Convert from a BDD level to a BDD variable.

Compare to bdd_level2var.

Specified by:
level2Var in class BDDFactory

var2Level

public int var2Level(int var)
Description copied from class: BDDFactory

Convert from a BDD variable to a BDD level.

Compare to bdd_var2level.

Specified by:
var2Level in class BDDFactory

reorder

public void reorder(BDDFactory.ReorderMethod m)
Description copied from class: BDDFactory

Reorder the BDD with the given method.

Compare to bdd_reorder.

Specified by:
reorder in class BDDFactory

autoReorder

public void autoReorder(BDDFactory.ReorderMethod method)
Description copied from class: BDDFactory

Enables automatic reordering. If method is REORDER_NONE then automatic reordering is disabled.

Compare to bdd_autoreorder.

Specified by:
autoReorder in class BDDFactory

autoReorder

public void autoReorder(BDDFactory.ReorderMethod method,
                        int max)
Description copied from class: BDDFactory

Enables automatic reordering with the given (maximum) number of reorderings. If method is REORDER_NONE then automatic reordering is disabled.

Compare to bdd_autoreorder_times.

Specified by:
autoReorder in class BDDFactory

getReorderMethod

public BDDFactory.ReorderMethod getReorderMethod()
Description copied from class: BDDFactory

Returns the current reorder method as defined by autoReorder.

Compare to bdd_getreorder_method.

Specified by:
getReorderMethod in class BDDFactory
Returns:
ReorderMethod

getReorderTimes

public int getReorderTimes()
Description copied from class: BDDFactory

Returns the number of allowed reorderings left. This value can be defined by autoReorder.

Compare to bdd_getreorder_times.

Specified by:
getReorderTimes in class BDDFactory

disableReorder

public void disableReorder()
Description copied from class: BDDFactory

Disable automatic reordering until enableReorder is called. Reordering is enabled by default as soon as any variable blocks have been defined.

Compare to bdd_disable_reorder.

Specified by:
disableReorder in class BDDFactory

enableReorder

public void enableReorder()
Description copied from class: BDDFactory

Enable automatic reordering after a call to disableReorder.

Compare to bdd_enable_reorder.

Specified by:
enableReorder in class BDDFactory

reorderVerbose

public int reorderVerbose(int v)
Description copied from class: BDDFactory

Enables verbose information about reordering. A value of zero means no information, one means some information and greater than one means lots of information.

Specified by:
reorderVerbose in class BDDFactory
Parameters:
v - the new verbose level
Returns:
the old verbose level

setVarOrder

public void setVarOrder(int[] neworder)
Description copied from class: BDDFactory

This function sets the current variable order to be the one defined by neworder. The variable parameter neworder is interpreted as a sequence of variable indices and the new variable order is exactly this sequence. The array must contain all the variables defined so far. If, for instance the current number of variables is 3 and neworder contains [1; 0; 2] then the new variable order is v1

Note that this operation must walk through the node table many times, and therefore it is much more efficient to call this when the node table is small.

Specified by:
setVarOrder in class BDDFactory
Parameters:
neworder - new variable order

addVarBlock

public void addVarBlock(int first,
                        int last,
                        boolean fixed)
Description copied from class: BDDFactory

Adds a new variable block for reordering.

Creates a new variable block with the variables numbered first through last, inclusive.

The fixed parameter sets the block to be fixed (no reordering of its child blocks is allowed) or free.

Compare to bdd_intaddvarblock.

Specified by:
addVarBlock in class BDDFactory

varBlockAll

public void varBlockAll()
Description copied from class: BDDFactory

Add a variable block for all variables.

Adds a variable block for all BDD variables declared so far. Each block contains one variable only. More variable blocks can be added later with the use of addVarBlock -- in this case the tree of variable blocks will have the blocks of single variables as the leafs.

Compare to bdd_varblockall.

Specified by:
varBlockAll in class BDDFactory

clearVarBlocks

public void clearVarBlocks()
Description copied from class: BDDFactory

Clears all the variable blocks that have been defined by calls to addVarBlock.

Compare to bdd_clrvarblocks.

Specified by:
clearVarBlocks in class BDDFactory

printOrder

public void printOrder()
Description copied from class: BDDFactory

Prints an indented list of the variable blocks.

Compare to bdd_printorder.

Specified by:
printOrder in class BDDFactory

nodeCount

public int nodeCount(Collection r)
Description copied from class: BDDFactory

Counts the number of shared nodes in a collection of BDDs. Counts all distinct nodes that are used in the BDDs -- if a node is used in more than one BDD then it only counts once.

Compare to bdd_anodecount.

Specified by:
nodeCount in class BDDFactory

getNodeTableSize

public int getNodeTableSize()
Description copied from class: BDDFactory

Get the number of allocated nodes. This includes both dead and active nodes.

Compare to bdd_getallocnum.

Specified by:
getNodeTableSize in class BDDFactory

getNodeNum

public int getNodeNum()
Description copied from class: BDDFactory

Get the number of active nodes in use. Note that dead nodes that have not been reclaimed yet by a garbage collection are counted as active.

Compare to bdd_getnodenum.

Specified by:
getNodeNum in class BDDFactory

getCacheSize

public int getCacheSize()
Description copied from class: BDDFactory

Get the current size of the cache, in entries.

Specified by:
getCacheSize in class BDDFactory
Returns:
size of cache

reorderGain

public int reorderGain()
Description copied from class: BDDFactory

Calculate the gain in size after a reordering. The value returned is (100*(A-B))/A, where A is previous number of used nodes and B is current number of used nodes.

Compare to bdd_reorder_gain.

Specified by:
reorderGain in class BDDFactory

printStat

public void printStat()
Description copied from class: BDDFactory

Print cache statistics.

Compare to bdd_printstat.

Specified by:
printStat in class BDDFactory

makePair

public BDDPairing makePair()
Description copied from class: BDDFactory

Make a new BDDPairing object.

Compare to bdd_newpair.

Specified by:
makePair in class BDDFactory

swapVar

public void swapVar(int v1,
                    int v2)
Description copied from class: BDDFactory

Swap two variables.

Compare to bdd_swapvar.

Specified by:
swapVar in class BDDFactory

createDomain

protected BDDDomain createDomain(int a,
                                 BigInteger b)
Description copied from class: BDDFactory

Implementors must implement this factory method to create BDDDomain objects of the correct type.

Overrides:
createDomain in class BDDFactory

createBitVector

protected BDDBitVector createBitVector(int a)
Description copied from class: BDDFactory

Implementors must implement this factory method to create BDDBitVector objects of the correct type.

Overrides:
createBitVector in class BDDFactory

extDomain

public BDDDomain[] extDomain(long[] domainSizes)
Overrides:
extDomain in class BDDFactory

makeSet

public static Set makeSet()

makeSet

public static Set makeSet(Set s)

allDomains

public Set allDomains()

makeMap

public static Map makeMap()

domainNames

public static String domainNames(Set dom)

getVersion

public String getVersion()
Description copied from class: BDDFactory
Get the BDD library version.

Specified by:
getVersion in class BDDFactory
Returns:
version string


Copyright © 2003-2007 John Whaley. All Rights Reserved.