- java.lang.Object
-
- org.logicng.knowledgecompilation.bdds.jbuddy.BDDOperations
-
public class BDDOperations extends Object
A collection of operations on a BDD kernel.- Since:
- 2.0.0
- Version:
- 2.4.0
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]allunsatProfileprotected BDDKernelkprotected intsupportIDprotected intsupportMaxprotected int[]supportSet
-
Constructor Summary
Constructors Constructor Description BDDOperations(BDDKernel k)Constructs a new object which will perform operations on the given kernel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<int[]>allNodes(int r)Returns all nodes for a given root node in their internal representation.List<byte[]>allSat(int r)Returns all models for a given BDD.protected voidallSatRec(int r, List<byte[]> models, byte[] allsatProfile)List<byte[]>allUnsat(int r)Returns all unsatisfiable assignments for a given BDD.protected voidallUnsatRec(int r, List<byte[]> models)intfullSatOne(int r)Returns a full model in all variables for the given BDD.protected intfullSatOneRec(int r)intnodeCount(int r)Returns the number of nodes for a given BDD.BigIntegerpathCountOne(int r)Returns the number of paths to the terminal node 'one'.protected BigIntegerpathCountRecOne(int r, int miscid)protected BigIntegerpathCountRecZero(int r, int miscid)BigIntegerpathCountZero(int r)Returns the number of paths to the terminal node 'zero'.BigIntegersatCount(int r)Returns the model count for the given BDD.protected BigIntegersatCountRec(int root, int miscid)intsatOne(int r)Finds one satisfying variable assignment and returns it as BDD.protected intsatOneRec(int r)intsatOneSet(int r, int var, int pol)Returns an arbitrary model for a given BDD ornullwhich contains at least the given variables.protected intsatOneSetRec(int r, int var, int satPolarity)intsupport(int r)Returns all the variables that a given BDD depends on.protected voidsupportRec(int r, int[] support)FormulatoFormula(int r, boolean followPathsToTrue)Returns a formula representation of this BDD.protected FormulatoFormulaRec(int r, boolean followPathsToTrue)int[]varProfile(int r)Returns how often each variable occurs in the given BDD.protected voidvarProfileRec(int r, int[] varprofile)
-
-
-
Field Detail
-
k
protected final BDDKernel k
-
allunsatProfile
protected byte[] allunsatProfile
-
supportID
protected int supportID
-
supportMax
protected int supportMax
-
supportSet
protected int[] supportSet
-
-
Constructor Detail
-
BDDOperations
public BDDOperations(BDDKernel k)
Constructs a new object which will perform operations on the given kernel.- Parameters:
k- the kernel
-
-
Method Detail
-
satOne
public int satOne(int r)
Finds one satisfying variable assignment and returns it as BDD.- Parameters:
r- the BDD root node- Returns:
- the satisfying variable assignment of the BDD as a BDD itself
-
satOneRec
protected int satOneRec(int r) throws BDDKernel.BddReorderRequest- Throws:
BDDKernel.BddReorderRequest
-
satOneSet
public int satOneSet(int r, int var, int pol)Returns an arbitrary model for a given BDD ornullwhich contains at least the given variables. If a variable is a don't care variable, it will be assigned with the given default value.- Parameters:
r- the BDD root nodevar- the set of variable which has to be contained in the model as a BDDpol- the default value for don't care variables as a BDD- Returns:
- an arbitrary model of this BDD
-
satOneSetRec
protected int satOneSetRec(int r, int var, int satPolarity) throws BDDKernel.BddReorderRequest- Throws:
BDDKernel.BddReorderRequest
-
fullSatOne
public int fullSatOne(int r)
Returns a full model in all variables for the given BDD.- Parameters:
r- the BDD root node- Returns:
- a full model of this BDD
-
fullSatOneRec
protected int fullSatOneRec(int r) throws BDDKernel.BddReorderRequest- Throws:
BDDKernel.BddReorderRequest
-
allSat
public List<byte[]> allSat(int r)
Returns all models for a given BDD.- Parameters:
r- the BDD root node- Returns:
- all models for the BDD
-
allSatRec
protected void allSatRec(int r, List<byte[]> models, byte[] allsatProfile)
-
satCount
public BigInteger satCount(int r)
Returns the model count for the given BDD.- Parameters:
r- the BDD root node- Returns:
- the model count for the BDD
-
satCountRec
protected BigInteger satCountRec(int root, int miscid)
-
pathCountOne
public BigInteger pathCountOne(int r)
Returns the number of paths to the terminal node 'one'.- Parameters:
r- the BDD root node- Returns:
- the number of paths to the terminal node 'one'
-
pathCountRecOne
protected BigInteger pathCountRecOne(int r, int miscid)
-
pathCountZero
public BigInteger pathCountZero(int r)
Returns the number of paths to the terminal node 'zero'.- Parameters:
r- the BDD root node- Returns:
- the number of paths to the terminal node 'zero'
-
pathCountRecZero
protected BigInteger pathCountRecZero(int r, int miscid)
-
allUnsat
public List<byte[]> allUnsat(int r)
Returns all unsatisfiable assignments for a given BDD.- Parameters:
r- the BDD root node- Returns:
- all unsatisfiable assignments for the BDD
-
allUnsatRec
protected void allUnsatRec(int r, List<byte[]> models)
-
support
public int support(int r)
Returns all the variables that a given BDD depends on.- Parameters:
r- the BDD root node- Returns:
- all the variables that the BDD depends on
-
supportRec
protected void supportRec(int r, int[] support)
-
nodeCount
public int nodeCount(int r)
Returns the number of nodes for a given BDD.- Parameters:
r- the BDD root node- Returns:
- the number of nodes for the BDD
-
varProfile
public int[] varProfile(int r)
Returns how often each variable occurs in the given BDD.- Parameters:
r- the BDD root node- Returns:
- how often each variable occurs in the BDD
-
varProfileRec
protected void varProfileRec(int r, int[] varprofile)
-
allNodes
public List<int[]> allNodes(int r)
Returns all nodes for a given root node in their internal representation. The internal representation is stored in an array:[node number, variable, low, high]- Parameters:
r- the BDD root node- Returns:
- all Nodes in their internal representation
-
toFormula
public Formula toFormula(int r, boolean followPathsToTrue)
Returns a formula representation of this BDD. This is done by using the Shannon expansion. IffollowPathsToTrueis activated, the paths leading to thetrueterminal are followed to generate the formula. IffollowPathsToTrueis deactivated, the paths leading to thefalseterminal are followed to generate the formula and the resulting formula is negated. Depending on the formula and the number of satisfying assignments, the generated formula can be more compact using thetruepaths orfalsepaths, respectively.- Parameters:
r- the BDD root nodefollowPathsToTrue- the extraction style- Returns:
- the formula
-
toFormulaRec
protected Formula toFormulaRec(int r, boolean followPathsToTrue)
-
-