Package org.mcp.core
Class MCPBitVector
java.lang.Object
org.mcp.core.MCPBitVector
Represents a symbolic bit vector for sets of constraints, supporting both BDD and SAT backends.
Provides logical operations (and, or, not, implication, etc.) and conversion between BDD and SAT representations. Each instance is associated with a backend type and the corresponding factory.
- Since:
- 2025-02-28
- Author:
-
Constructor Summary
ConstructorsConstructorDescriptionMCPBitVector(Object value, MCPFactory.MCPType type) Constructs a new MCPBitVector with the given value and backend type.MCPBitVector(MCPBitVector other) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionand(MCPBitVector other) Performs a logical AND with another MCPBitVector.andWith(MCPBitVector other) Performs an in-place logical AND with another MCPBitVector (modifies this instance for SAT).biimp(MCPBitVector other) Performs logical bi-implication (equivalence) with another MCPBitVector.copy()Returns a deep copy of this MCPBitVector.diff(MCPBitVector other) Computes the difference (this AND NOT other) with another MCPBitVector.diffWith(MCPBitVector other) Computes the in-place difference (this AND NOT other) with another MCPBitVector (modifies this instance for SAT).booleanChecks equality with another object.Returns the factory (BDDFactory or FormulaFactory) associated with this bit vector.getType()Returns the backend type of this bit vector.getValue()Returns the underlying value (BDD or Formula) of this bit vector.inthashCode()Returns the hash code for this bit vector.id()Returns a copy of this bit vector (for BDD, returns a new reference).imp(MCPBitVector other) Performs logical implication (this => other).impWith(MCPBitVector other) Performs in-place logical implication (this => other) (modifies this instance for SAT).booleanisBDD()Checks if this bit vector uses the BDD backend.booleanisOne()Checks if this bit vector represents logical true (tautology).booleanisSAT()Checks if this bit vector uses the SAT backend.booleanisZero()Checks if this bit vector represents logical false (contradiction).not()Performs logical NOT on this bit vector.or(MCPBitVector other) Performs a logical OR with another MCPBitVector.doublesatCount()Returns the number of satisfying assignments for this bit vector.voidsetFactory(Object factory) Sets the factory (BDDFactory or FormulaFactory) for this bit vector.toString()Returns a string representation of this bit vector.withFactory(Object factory) Returns a new MCPBitVector with the same value and the given factory set.
-
Constructor Details
-
MCPBitVector
Constructs a new MCPBitVector with the given value and backend type.- Parameters:
value- the underlying value (BDD or Formula)type- the backend type (BDD or SAT)
-
MCPBitVector
Copy constructor. Creates a deep copy of the given MCPBitVector.- Parameters:
other- the MCPBitVector to copy
-
-
Method Details
-
setFactory
Sets the factory (BDDFactory or FormulaFactory) for this bit vector.- Parameters:
factory- the factory object
-
getFactory
Returns the factory (BDDFactory or FormulaFactory) associated with this bit vector.- Returns:
- the factory object
-
or
Performs a logical OR with another MCPBitVector.- Parameters:
other- the other bit vector- Returns:
- a new MCPBitVector representing the OR result
-
and
Performs a logical AND with another MCPBitVector.- Parameters:
other- the other bit vector- Returns:
- a new MCPBitVector representing the AND result
-
andWith
Performs an in-place logical AND with another MCPBitVector (modifies this instance for SAT).- Parameters:
other- the other bit vector- Returns:
- a new MCPBitVector representing the AND result
-
diff
Computes the difference (this AND NOT other) with another MCPBitVector.- Parameters:
other- the other bit vector- Returns:
- a new MCPBitVector representing the difference
-
diffWith
Computes the in-place difference (this AND NOT other) with another MCPBitVector (modifies this instance for SAT).- Parameters:
other- the other bit vector- Returns:
- a new MCPBitVector representing the difference
-
withFactory
Returns a new MCPBitVector with the same value and the given factory set.- Parameters:
factory- the factory to set- Returns:
- a new MCPBitVector with the factory set
-
getValue
Returns the underlying value (BDD or Formula) of this bit vector.- Returns:
- the underlying value
-
equals
Checks equality with another object. -
hashCode
public int hashCode()Returns the hash code for this bit vector. -
toString
Returns a string representation of this bit vector. -
isZero
public boolean isZero()Checks if this bit vector represents logical false (contradiction).- Returns:
- true if contradiction, false otherwise
-
isOne
public boolean isOne()Checks if this bit vector represents logical true (tautology).- Returns:
- true if tautology, false otherwise
-
satCount
public double satCount()Returns the number of satisfying assignments for this bit vector. For SAT, returns 1 if satisfiable, 0 otherwise.- Returns:
- the number of satisfying assignments
-
imp
Performs logical implication (this => other).- Parameters:
other- the other bit vector- Returns:
- a new MCPBitVector representing the implication
-
impWith
Performs in-place logical implication (this => other) (modifies this instance for SAT).- Parameters:
other- the other bit vector- Returns:
- a new MCPBitVector representing the implication
-
not
Performs logical NOT on this bit vector.- Returns:
- a new MCPBitVector representing the negation
-
biimp
Performs logical bi-implication (equivalence) with another MCPBitVector.- Parameters:
other- the other bit vector- Returns:
- a new MCPBitVector representing the equivalence
-
id
Returns a copy of this bit vector (for BDD, returns a new reference).- Returns:
- a new MCPBitVector copy
-
getType
Returns the backend type of this bit vector.- Returns:
- the MCPType (BDD or SAT)
-
isBDD
public boolean isBDD()Checks if this bit vector uses the BDD backend.- Returns:
- true if BDD, false otherwise
-
isSAT
public boolean isSAT()Checks if this bit vector uses the SAT backend.- Returns:
- true if SAT, false otherwise
-
copy
Returns a deep copy of this MCPBitVector.- Returns:
- a new MCPBitVector copy
-