c++ code for pseudo-Boolean function manipulation.
This code allows efficient read-and-write of pseudo-Boolean functions. The current implementation only includes quadratic pseudo-Boolean functions (QPBF).
We store a QPBF as a sparse matrix. This sparse matrix is stored in a heap. An coefficient
On initialization, the user should specify the number of boolean variables in the QPBF. This is not essentially necessary, however, we make it a rule for consistency check.
We provide two ways to access each entry
One can completely delete an entry via delTermX, which not only set that entry to zero, but also release the memory space.
We allow +,- operation between QPBFs, as well as * operation between QPBFs and scalars. After these operations take place, some entries might become zeros, but they are still kept in the memory. One may get rid of them with clean() function.
Clear() function destroy the whole QPBF.
size() returns the number of nonzero entries in the QPBF.
numvar() returns the number of boolean variables.
To extend the number of boolean variables in the QPBF, one can use updatenumvar(). Currently, we do not support reducing the number of Boolean variables.
One may also evaluate the value of a QPBF with respect to a Boolean vector y using evaluate().