Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cython/pycddlib.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,12 @@ def block_elimination(mat: Matrix, col_set: Container[int]) -> Matrix:
It does this by using the generators of the dual linear system,
where the generators are calculated using the double description algorithm.

.. warning::

You must specify the indices of the columns associated with the variable(s) you want to remove.
Column 0 refers to the coefficient vector `b` from the matrix [b A].
Thus, column 1 is associated with the 1st variable, etc.

.. note::

The output is not guaranteed to be minimal,
Expand All @@ -1186,6 +1192,8 @@ def block_elimination(mat: Matrix, col_set: Container[int]) -> Matrix:
"""
if mat.dd_mat.representation != dd_Inequality:
raise ValueError("rep_type must be INEQUALITY")
if 0 in col_set:
raise ValueError("Column indices must be > 0.")
cdef set_type dd_colset = NULL
cdef dd_MatrixPtr dd_mat = NULL
cdef dd_ErrorType error = dd_NoError
Expand Down
9 changes: 9 additions & 0 deletions test/test_block_elimination.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pytest import raises
from test import assert_matrix_almost_equal

import cdd
Expand Down Expand Up @@ -43,3 +44,11 @@ def test_block_elimination_3() -> None:
# 0 <= 2 - x
assert_matrix_almost_equal(mat2.array, [[2, -1]])
assert mat2.lin_set == set()


def test_block_elimination_4() -> None:
# 0 = -2 + x + y, 0 <= y
array = [[-2, 1, 1], [0, 0, 1]]
mat = cdd.matrix_from_array(array, rep_type=cdd.RepType.INEQUALITY, lin_set=[0])
with raises(ValueError):
cdd.block_elimination(mat, {0})
Loading