Package org.mcp.sat
Class MutableSATInteger
java.lang.Object
org.mcp.sat.SATInteger
org.mcp.sat.MutableSATInteger
- All Implemented Interfaces:
Serializable
MutableSATInteger represents a mutable bit-vector for SAT-based integer encoding.
Provides methods for constructing, copying, and manipulating SAT integer variables, as well as converting SAT assignments to integer values.
- Since:
- 2025-02-28
- Author:
- See Also:
-
Field Summary
Fields inherited from class org.mcp.sat.SATInteger
_bitvec, _factory, _maxVal -
Constructor Summary
ConstructorsConstructorDescriptionMutableSATInteger(org.logicng.formulas.FormulaFactory factory, int length) Constructs a MutableSATInteger with the given length, initializing all bits as free variables.MutableSATInteger(org.logicng.formulas.FormulaFactory factory, org.logicng.formulas.Variable[] bitvec) Constructs a MutableSATInteger from a bit vector.Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks equality with another object.protected org.logicng.formulas.FormulafirstBitsEqual(long value, int length) Returns a formula representing the firstlengthbits equal to the given value.inthashCode()Returns the hash code for this MutableSATInteger.static MutableSATIntegermakeFromIndex(org.logicng.formulas.FormulaFactory factory, int length, int start, boolean reverse) Creates a MutableSATInteger from a bitvector index.longsatAssignmentToLong(org.logicng.datastructures.Assignment assignment) Converts a SAT assignment to a long value.Methods inherited from class org.mcp.sat.SATInteger
getBitvec, getFactory, getValueSatisfying, getValueSatisfyingToInt, getValuesSatisfying, size, value
-
Constructor Details
-
MutableSATInteger
public MutableSATInteger(org.logicng.formulas.FormulaFactory factory, org.logicng.formulas.Variable[] bitvec) Constructs a MutableSATInteger from a bit vector.- Parameters:
factory- the formula factorybitvec- the bit vector
-
MutableSATInteger
public MutableSATInteger(org.logicng.formulas.FormulaFactory factory, int length) Constructs a MutableSATInteger with the given length, initializing all bits as free variables.- Parameters:
factory- the formula factorylength- the number of bits
-
MutableSATInteger
Copy constructor.- Parameters:
other- the MutableSATInteger to copy
-
-
Method Details
-
makeFromIndex
public static MutableSATInteger makeFromIndex(org.logicng.formulas.FormulaFactory factory, int length, int start, boolean reverse) Creates a MutableSATInteger from a bitvector index.- Parameters:
factory- the formula factorylength- the number of bitsstart- the starting indexreverse- whether to reverse the bit order- Returns:
- a new MutableSATInteger
-
satAssignmentToLong
public long satAssignmentToLong(org.logicng.datastructures.Assignment assignment) Converts a SAT assignment to a long value.- Specified by:
satAssignmentToLongin classSATInteger- Parameters:
assignment- the SAT assignment- Returns:
- the corresponding long value
-
firstBitsEqual
protected org.logicng.formulas.Formula firstBitsEqual(long value, int length) Returns a formula representing the firstlengthbits equal to the given value.- Specified by:
firstBitsEqualin classSATInteger- Parameters:
value- the value to comparelength- the number of bits to check- Returns:
- the formula representing the equality
-
equals
Checks equality with another object. -
hashCode
public int hashCode()Returns the hash code for this MutableSATInteger.
-