public class Zbdd
extends Object
implements Cloneable
Zero-suppressed decision diagram on Wikipedia.
This class is not thread-safe.
| Modifier and Type | Class and Description |
|---|---|
static interface |
Zbdd.CubeVisitor
Cube visitor interface to be used with
visitCubes(int, CubeVisitor). |
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_NODES
Maximum number of nodes.
|
protected static int |
ZBDD_BASE |
protected static int |
ZBDD_EMPTY |
| Modifier | Constructor and Description |
|---|---|
|
Zbdd() |
protected |
Zbdd(@NotNull Zbdd zbdd) |
|
Zbdd(@NotNull ZbddCapacityAdvisor capacityAdvisor) |
| Modifier and Type | Method and Description |
|---|---|
protected int |
__atomize_cache(int zbdd) |
protected int |
__atomize(int zbdd) |
protected int |
__change_cache(int zbdd,
int var) |
protected int |
__change(int zbdd,
int var) |
protected boolean |
__contains(int p,
int q) |
protected int |
__count_cache(int zbdd) |
protected int |
__count(int zbdd) |
protected int |
__decRef(int zbdd) |
protected int |
__difference_cache(int p,
int q) |
protected int |
__difference(int p,
int q) |
protected int |
__divide_cache(int p,
int q) |
protected int |
__divide(int p,
int q) |
protected int |
__incRef(int zbdd) |
protected int |
__intersect_cache(int p,
int q) |
protected int |
__intersect(int p,
int q) |
protected int |
__modulo_cache(int p,
int q) |
protected int |
__modulo(int p,
int q) |
protected int |
__multiply_cache(int p,
int q) |
protected int |
__multiply(int p,
int q) |
protected int |
__removeBase_cache(int zbdd) |
protected int |
__removeBase(int zbdd) |
protected int |
__subset0_cache(int zbdd,
int var) |
protected int |
__subset0(int zbdd,
int var) |
protected int |
__subset1_cache(int zbdd,
int var) |
protected int |
__subset1(int zbdd,
int var) |
protected int |
__union_cache(int p,
int q) |
protected int |
__union(int p,
int q) |
@Range(from=0L,to=357913941L) int |
atomize(@Range(from=0L,to=357913941L) int zbdd) |
int |
base()
Returns the base zbdd set.
|
@Range(from=0L,to=357913941L) int |
change(@Range(from=0L,to=357913941L) int zbdd,
@Range(from=1L,to=2147483647L) int var) |
protected int |
checkVar(int var) |
protected int |
checkZbdd(int zbdd,
@NotNull String param) |
void |
clear()
Clear all nodes from this zbdd instance.
|
Zbdd |
clone() |
@Range(from=0L,to=357913941L) boolean |
contains(@Range(from=0L,to=357913941L) int p,
@Range(from=0L,to=357913941L) int q) |
@Range(from=0L,to=2147483647L) int |
count(@Range(from=0L,to=357913941L) int zbdd) |
@Range(from=1L,to=2147483647L) int |
createVar()
Create a new literal/variable.
|
@Range(from=0L,to=357913941L) int |
cube(int... cubeVars)
Returns a zbdd set with the given
vars combined as its only element. |
@Range(from=0L,to=357913941L) int |
cube(@Range(from=1L,to=2147483647L) int var)
Returns a zbdd set with the given
var as its only element. |
int |
decRef(@Range(from=0L,to=357913941L) int zbdd) |
@Range(from=0L,to=357913941L) int |
difference(@Range(from=0L,to=357913941L) int p,
@Range(from=0L,to=357913941L) int q) |
@Range(from=0L,to=357913941L) int |
divide(@Range(from=0L,to=357913941L) int p,
@Range(from=0L,to=357913941L) int q) |
int |
empty()
Returns the empty zbdd set.
|
protected void |
ensureCapacity() |
@Range(from=0L,to=357913939L) int |
gc() |
@NotNull ZbddLiteralResolver |
getLiteralResolver()
Returns the literal resolver associated with this zbdd instance.
|
protected @Range(from=0L,to=357913941L) int |
getNode(@Range(from=1L,to=2147483647L) int var,
@Range(from=0L,to=357913941L) int p0,
@Range(from=0L,to=357913941L) int p1) |
protected @Range(from=0L,to=357913941L) int |
getP0(int zbdd) |
protected @Range(from=0L,to=357913941L) int |
getP1(int zbdd) |
@NotNull ZbddStatistics |
getStatistics()
Returns the statistics for this zbdd instance.
|
protected int |
getVar(int zbdd) |
ZbddCache |
getZbddCache()
Returns the currently assigned zbdd cache implementation.
|
protected @Range(from=0L,to=357913941L) int |
hash(int var,
int p0,
int p1) |
int |
incRef(@Range(from=0L,to=357913941L) int zbdd) |
@Range(from=0L,to=357913941L) int |
intersect(@Range(from=0L,to=357913941L) int p,
@Range(from=0L,to=357913941L) int q) |
static boolean |
isBase(@Range(from=0L,to=357913941L) int zbdd) |
static boolean |
isEmpty(@Range(from=0L,to=357913941L) int zbdd)
Tells if the zbdd set identified by
zbdd is empty. |
@Range(from=0L,to=357913941L) int |
modulo(@Range(from=0L,to=357913941L) int p,
@Range(from=0L,to=357913941L) int q) |
@Range(from=0L,to=357913941L) int |
multiply(@Range(from=0L,to=357913941L) int p,
@Range(from=0L,to=357913941L) int q) |
@Range(from=0L,to=357913941L) int |
removeBase(@Range(from=0L,to=357913941L) int zbdd) |
void |
setLiteralResolver(@NotNull ZbddLiteralResolver literalResolver) |
void |
setZbddCache(ZbddCache zbddCache)
Sets or removes a zbdd cache.
|
@Range(from=0L,to=357913941L) int |
subset0(@Range(from=0L,to=357913941L) int zbdd,
@Range(from=1L,to=2147483647L) int var) |
@Range(from=0L,to=357913941L) int |
subset1(@Range(from=0L,to=357913941L) int zbdd,
@Range(from=1L,to=2147483647L) int var) |
@NotNull String |
toString(@Range(from=0L,to=357913941L) int zbdd) |
@Range(from=0L,to=357913941L) int |
union(@Range(from=0L,to=357913941L) int p,
@Range(from=0L,to=357913941L) int q) |
void |
visitCubes(@Range(from=0L,to=357913941L) int zbdd,
@NotNull Zbdd.CubeVisitor visitor) |
public static final int MAX_NODES
protected static final int ZBDD_EMPTY
protected static final int ZBDD_BASE
public Zbdd()
public Zbdd(@NotNull @NotNull ZbddCapacityAdvisor capacityAdvisor)
@Contract(mutates="this,param1") public void setZbddCache(ZbddCache zbddCache)
Sets or removes a zbdd cache.
The zbdd implementation without caching is already very fast. If the same operations on zbdds are performed frequently then adding a cache may help to improve performance. However, if the operations performed are mostly unique (like the 8-queens problem) then adding a cache will reduce the overall performance.
Make sure to test your zbdd operationsthe with and without a cache in order to find out whether adding a cache is going to improve performance or not.
zbddCache - zbdd cache instance or null to remove a previously assigned cache@Contract(pure=true) public ZbddCache getZbddCache()
null if no zbdd cache was assigned@Contract(pure=true) @NotNull public @NotNull ZbddLiteralResolver getLiteralResolver()
null@Contract(mutates="this") public void setLiteralResolver(@NotNull @NotNull ZbddLiteralResolver literalResolver)
@Contract(pure=true) @NotNull public @NotNull ZbddStatistics getStatistics()
Returns the statistics for this zbdd instance. The returned object is a singleton and will reflect the actual statistics at any time.
null@Contract(mutates="this") public void clear()
Clear all nodes from this zbdd instance. If a zbdd cache is assigned it will be cleared as well.
This method clears all variables and nodes. It does not free up allocated memory.
ZbddCache.clear()@Contract(pure=true) public static boolean isEmpty(@Range(from=0L,to=357913941L) int zbdd)
zbdd is empty.zbdd - zbdd nodetrue if the set is empty, false otherwiseempty()@Contract(pure=true) public static boolean isBase(@Range(from=0L,to=357913941L) int zbdd)
base()@Contract(mutates="this") public @Range(from=1L,to=2147483647L) int createVar()
@Contract(pure=true) public final int empty()
isEmpty(int)@Contract(pure=true) public final int base()
isBase(int)@Contract(mutates="this") public @Range(from=0L,to=357913941L) int cube(@Range(from=1L,to=2147483647L) int var)
Returns a zbdd set with the given var as its only element.
Example:
Zbdd zbdd = new Zbdd();
int v1 = zbdd.createVar();
int singleton = zbdd.cube(v1);
String s = zbdd.toString(singleton); // = "{ v1 }"
var - valid variablevar as its only element@Contract(mutates="this") public @Range(from=0L,to=357913941L) int cube(int... cubeVars)
Returns a zbdd set with the given vars combined as its only element.
Example:
Zbdd zbdd = new Zbdd();
int v1 = zbdd.createVar();
int v2 = zbdd.createVar();
int v3 = zbdd.createVar();
int singleton = zbdd.cube(v1, v3);
String s = zbdd.toString(singleton); // = "{ v1.v3 }"
cubeVars - valid variablescubeVars as its only element@Contract(mutates="this") public @Range(from=0L,to=357913941L) int subset0(@Range(from=0L,to=357913941L) int zbdd, @Range(from=1L,to=2147483647L) int var)
@Contract(mutates="this") protected int __subset0_cache(int zbdd, int var)
@Contract(mutates="this") public @Range(from=0L,to=357913941L) int subset1(@Range(from=0L,to=357913941L) int zbdd, @Range(from=1L,to=2147483647L) int var)
@Contract(mutates="this") protected int __subset1_cache(int zbdd, int var)
@Contract(mutates="this") public @Range(from=0L,to=357913941L) int change(@Range(from=0L,to=357913941L) int zbdd, @Range(from=1L,to=2147483647L) int var)
@Contract(mutates="this") protected int __change_cache(int zbdd, int var)
@Contract(pure=true) public @Range(from=0L,to=2147483647L) int count(@Range(from=0L,to=357913941L) int zbdd)
@Contract(mutates="this") public @Range(from=0L,to=357913941L) int union(@Range(from=0L,to=357913941L) int p, @Range(from=0L,to=357913941L) int q)
@Contract(mutates="this") public @Range(from=0L,to=357913941L) int intersect(@Range(from=0L,to=357913941L) int p, @Range(from=0L,to=357913941L) int q)
@Contract(mutates="this") protected int __intersect_cache(int p, int q)
@Contract(mutates="this") public @Range(from=0L,to=357913941L) int difference(@Range(from=0L,to=357913941L) int p, @Range(from=0L,to=357913941L) int q)
@Contract(mutates="this") protected int __difference_cache(int p, int q)
@Contract(mutates="this") public @Range(from=0L,to=357913941L) int multiply(@Range(from=0L,to=357913941L) int p, @Range(from=0L,to=357913941L) int q)
@Contract(mutates="this") protected int __multiply_cache(int p, int q)
@Contract(mutates="this") public @Range(from=0L,to=357913941L) int divide(@Range(from=0L,to=357913941L) int p, @Range(from=0L,to=357913941L) int q)
@Contract(mutates="this") public @Range(from=0L,to=357913941L) int modulo(@Range(from=0L,to=357913941L) int p, @Range(from=0L,to=357913941L) int q)
@Contract(mutates="this") public @Range(from=0L,to=357913941L) int atomize(@Range(from=0L,to=357913941L) int zbdd)
@Contract(mutates="this") public @Range(from=0L,to=357913941L) int removeBase(@Range(from=0L,to=357913941L) int zbdd)
@Contract(mutates="this") protected int __removeBase_cache(int zbdd)
@Contract(mutates="this") public @Range(from=0L,to=357913941L) boolean contains(@Range(from=0L,to=357913941L) int p, @Range(from=0L,to=357913941L) int q)
@Contract(mutates="this") protected @Range(from=0L,to=357913941L) int getNode(@Range(from=1L,to=2147483647L) int var, @Range(from=0L,to=357913941L) int p0, @Range(from=0L,to=357913941L) int p1)
@Contract(value="_ -> param1", mutates="this") public int incRef(@Range(from=0L,to=357913941L) int zbdd)
@Contract(value="_ -> param1", mutates="this") public int decRef(@Range(from=0L,to=357913941L) int zbdd)
@Contract(value="_, _ -> param1") @MustBeInvokedByOverriders protected int checkZbdd(int zbdd, @NotNull @NotNull String param)
@Contract(value="_ -> param1") @MustBeInvokedByOverriders protected int checkVar(int var)
@Contract(value="_ -> new", pure=true) @NotNull public @NotNull String toString(@Range(from=0L,to=357913941L) int zbdd)