net.sf.javabdd
Class BuDDyFactory

java.lang.Object
  extended by net.sf.javabdd.BDDFactory
      extended by net.sf.javabdd.BDDFactoryIntImpl
          extended by net.sf.javabdd.BuDDyFactory

public class BuDDyFactory
extends BDDFactoryIntImpl

An implementation of BDDFactory that relies on the BuDDy library through a native interface. You can use this by calling the "BuDDyFactory.init()" method with the desired arguments. This will return you an instance of the BDDFactory class that you can use. Call "done()" on that instance when you are finished.

This class (and the BuDDy library) do NOT support multithreading. Furthermore, there can be only one instance active at a time. You can only call "init()" again after you have called "done()" on the original instance. It is not recommended to call "init()" again after calling "done()" unless you are _completely_ sure that all BDD objects that reference the old factory have been freed.

If you really need multiple BDD factories, consider using the JFactory class for the additional BDD factories --- JFactory can have multiple factory instances active at a time.

Version:
$Id: BuDDyFactory.java 476 2007-03-06 06:08:40Z joewhaley $
Author:
John Whaley
See Also:
BDDFactory

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.javabdd.BDDFactoryIntImpl
BDDFactoryIntImpl.IntBDD, BDDFactoryIntImpl.IntBDDBitVector, BDDFactoryIntImpl.IntBDDVarSet, BDDFactoryIntImpl.IntBDDVarSetWithFinalizer, BDDFactoryIntImpl.IntBDDWithFinalizer, BDDFactoryIntImpl.IntZDDVarSet, BDDFactoryIntImpl.IntZDDVarSetWithFinalizer
 
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 String REVISION
           
 
Fields inherited from class net.sf.javabdd.BDDFactoryIntImpl
to_free, to_free_length
 
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
 
Method Summary
protected  void addref_impl(int v)
           
 void addVarBlock(int first, int last, boolean fixed)
          Adds a new variable block for reordering.
protected  int apply_impl(int v1, int v2, BDDFactory.BDDOp opr)
           
protected  int applyAll_impl(int v1, int v2, BDDFactory.BDDOp opr, int v3)
           
protected  int applyEx_impl(int v1, int v2, BDDFactory.BDDOp opr, int v3)
           
protected  int applyUni_impl(int v1, int v2, BDDFactory.BDDOp opr, int v3)
           
 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  int compose_impl(int v1, int v2, int var)
           
protected  int constrain_impl(int v1, int v2)
           
protected  void delref_impl(int v)
           
 void disableReorder()
          Disable automatic reordering until enableReorder is called.
 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.
protected  int exist_impl(int v1, int v2)
           
protected  int forAll_impl(int v1, int v2)
           
protected  int fullSatOne_impl(int v)
           
 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.
protected  int high_impl(int v)
           
static BDDFactory init(int nodenum, int cachesize)
           
protected  void initialize(int nodenum, int cachesize)
          Compare to bdd_init.
protected  int invalid_bdd_impl()
           
 boolean isInitialized()
          Returns true if this BDD factory is initialized, false otherwise.
protected  int ite_impl(int v1, int v2, int v3)
           
protected  int ithVar_impl(int var)
           
protected  int level_impl(int v)
           
 int level2Var(int level)
          Convert from a BDD level to a BDD variable.
 BDD load(String filename)
          Loads a BDD from a file.
protected  int low_impl(int v)
           
protected  int makenode_impl(int lev, int lo, int hi)
           
 BDDPairing makePair()
          Make a new BDDPairing object.
protected  int nithVar_impl(int var)
           
protected  int nodeCount_impl(int v)
           
protected  int nodeCount_impl2(int[] v)
           
protected  int not_impl(int v1)
           
protected  int one_impl()
           
protected  double pathCount_impl(int v)
           
 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.
protected  void printTable_impl(int v)
           
 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.
protected  int replace_impl(int v, BDDPairing p)
           
protected  int restrict_impl(int v1, int v2)
           
protected  double satCount_impl(int v)
           
protected  int satOne_impl(int v)
           
protected  int satOne_impl2(int v1, int v2, boolean pol)
           
 void save(String filename, BDD b)
          Saves a BDD to a file.
 double setCacheRatio(double x)
          Sets the cache ratio for the operator caches.
 int setCacheSize(int x)
          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 x)
          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.
protected  int simplify_impl(int v1, int v2)
           
protected  int support_impl(int v)
           
 void swapVar(int v1, int v2)
          Swap two variables.
protected  int unique_impl(int v1, int v2)
           
protected  int var_impl(int v)
           
 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.
protected  int[] varProfile_impl(int v)
           
protected  int veccompose_impl(int v, BDDPairing p)
           
protected  int zero_impl()
           
 
Methods inherited from class net.sf.javabdd.BDDFactoryIntImpl
deferredFree, emptySet, finalize, handleDeferredFree, ithVar, makeBDD, makeBDDVarSet, nithVar, nodeCount, one, printTable, universe_impl, universe, unwrap, unwrap, unwrap, zero
 
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, createBitVector, createDomain, doCallbacks, extDomain, 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, unregisterCallback, unregisterGCCallback, unregisterReorderCallback, unregisterResizeCallback
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

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

init

public static BDDFactory init(int nodenum,
                              int cachesize)

addref_impl

protected void addref_impl(int v)
Specified by:
addref_impl in class BDDFactoryIntImpl

delref_impl

protected void delref_impl(int v)
Specified by:
delref_impl in class BDDFactoryIntImpl

zero_impl

protected int zero_impl()
Specified by:
zero_impl in class BDDFactoryIntImpl

one_impl

protected int one_impl()
Specified by:
one_impl in class BDDFactoryIntImpl

invalid_bdd_impl

protected int invalid_bdd_impl()
Specified by:
invalid_bdd_impl in class BDDFactoryIntImpl

var_impl

protected int var_impl(int v)
Specified by:
var_impl in class BDDFactoryIntImpl

level_impl

protected int level_impl(int v)
Specified by:
level_impl in class BDDFactoryIntImpl

low_impl

protected int low_impl(int v)
Specified by:
low_impl in class BDDFactoryIntImpl

high_impl

protected int high_impl(int v)
Specified by:
high_impl in class BDDFactoryIntImpl

ithVar_impl

protected int ithVar_impl(int var)
Specified by:
ithVar_impl in class BDDFactoryIntImpl

nithVar_impl

protected int nithVar_impl(int var)
Specified by:
nithVar_impl in class BDDFactoryIntImpl

makenode_impl

protected int makenode_impl(int lev,
                            int lo,
                            int hi)
Specified by:
makenode_impl in class BDDFactoryIntImpl

ite_impl

protected int ite_impl(int v1,
                       int v2,
                       int v3)
Specified by:
ite_impl in class BDDFactoryIntImpl

apply_impl

protected int apply_impl(int v1,
                         int v2,
                         BDDFactory.BDDOp opr)
Specified by:
apply_impl in class BDDFactoryIntImpl

not_impl

protected int not_impl(int v1)
Specified by:
not_impl in class BDDFactoryIntImpl

applyAll_impl

protected int applyAll_impl(int v1,
                            int v2,
                            BDDFactory.BDDOp opr,
                            int v3)
Specified by:
applyAll_impl in class BDDFactoryIntImpl

applyEx_impl

protected int applyEx_impl(int v1,
                           int v2,
                           BDDFactory.BDDOp opr,
                           int v3)
Specified by:
applyEx_impl in class BDDFactoryIntImpl

applyUni_impl

protected int applyUni_impl(int v1,
                            int v2,
                            BDDFactory.BDDOp opr,
                            int v3)
Specified by:
applyUni_impl in class BDDFactoryIntImpl

compose_impl

protected int compose_impl(int v1,
                           int v2,
                           int var)
Specified by:
compose_impl in class BDDFactoryIntImpl

constrain_impl

protected int constrain_impl(int v1,
                             int v2)
Specified by:
constrain_impl in class BDDFactoryIntImpl

restrict_impl

protected int restrict_impl(int v1,
                            int v2)
Specified by:
restrict_impl in class BDDFactoryIntImpl

simplify_impl

protected int simplify_impl(int v1,
                            int v2)
Specified by:
simplify_impl in class BDDFactoryIntImpl

support_impl

protected int support_impl(int v)
Specified by:
support_impl in class BDDFactoryIntImpl

exist_impl

protected int exist_impl(int v1,
                         int v2)
Specified by:
exist_impl in class BDDFactoryIntImpl

forAll_impl

protected int forAll_impl(int v1,
                          int v2)
Specified by:
forAll_impl in class BDDFactoryIntImpl

unique_impl

protected int unique_impl(int v1,
                          int v2)
Specified by:
unique_impl in class BDDFactoryIntImpl

fullSatOne_impl

protected int fullSatOne_impl(int v)
Specified by:
fullSatOne_impl in class BDDFactoryIntImpl

replace_impl

protected int replace_impl(int v,
                           BDDPairing p)
Specified by:
replace_impl in class BDDFactoryIntImpl

veccompose_impl

protected int veccompose_impl(int v,
                              BDDPairing p)
Specified by:
veccompose_impl in class BDDFactoryIntImpl

nodeCount_impl

protected int nodeCount_impl(int v)
Specified by:
nodeCount_impl in class BDDFactoryIntImpl

pathCount_impl

protected double pathCount_impl(int v)
Specified by:
pathCount_impl in class BDDFactoryIntImpl

satCount_impl

protected double satCount_impl(int v)
Specified by:
satCount_impl in class BDDFactoryIntImpl

satOne_impl

protected int satOne_impl(int v)
Specified by:
satOne_impl in class BDDFactoryIntImpl

satOne_impl2

protected int satOne_impl2(int v1,
                           int v2,
                           boolean pol)
Specified by:
satOne_impl2 in class BDDFactoryIntImpl

nodeCount_impl2

protected int nodeCount_impl2(int[] v)
Specified by:
nodeCount_impl2 in class BDDFactoryIntImpl

varProfile_impl

protected int[] varProfile_impl(int v)
Specified by:
varProfile_impl in class BDDFactoryIntImpl

printTable_impl

protected void printTable_impl(int v)
Specified by:
printTable_impl in class BDDFactoryIntImpl

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

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

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

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

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

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

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

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

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.

Overrides:
done in class BDDFactoryIntImpl

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

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

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

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

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

setNodeTableSize

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

Sets the node table size.

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

setCacheSize

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

Sets cache size.

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

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

makePair

public BDDPairing makePair()
Description copied from class: BDDFactory

Make a new BDDPairing object.

Compare to bdd_newpair.

Specified by:
makePair in class BDDFactory

load

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

Loads a BDD from a file.

Compare to bdd_load.

Overrides:
load in class BDDFactory

save

public void save(String filename,
                 BDD b)
Description copied from class: BDDFactory

Saves a BDD to a file.

Compare to bdd_save.

Overrides:
save 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

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.