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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Added tests for `getObjVal()` and `getVal()`
- Added `addConsLinear()` to add linear constraints from variables and coefficients without building an expression
### Fixed
- Fixed `MatrixVariable.varMayRound()` rounding direction
- Fixed `lotsizing_lazy` example: lock the handler's variables in `conslock` so presolve cannot aggregate them away (#1252)
- Dual and Farkas getters for linear, knapsack, and logicor constraints now return zero when presolving has removed them.
- Fixed incorrect `getObjVal()` result when called before `getBestSol()` (e.g., in event handlers).
Expand Down
2 changes: 1 addition & 1 deletion src/pyscipopt/scip.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -2186,7 +2186,7 @@ class MatrixVariable(MatrixExpr):
"""
mayround = np.empty(self.shape, dtype=bool)
for idx in np.ndindex(self.shape):
mayround[idx] = self[idx].varMayRound()
mayround[idx] = self[idx].varMayRound(direction)
return mayround

cdef class Constraint:
Expand Down
14 changes: 14 additions & 0 deletions tests/test_matrix_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,20 @@ def test_MatrixVariable_attributes():
assert x.getAvgSol().tolist() == [[5, 6], [2, 8]]
assert x.varMayRound().tolist() == [[True, True], [True, True]]


def test_matrix_var_may_round_direction():
m = Model()
x = m.addMatrixVar((2,), vtype="I")
# downward rounding is blocked; upward rounding is allowed
m.addVarLocks(x[0], nlocksdown=1, nlocksup=0)
# downward rounding is allowed; upward rounding is blocked
m.addVarLocks(x[1], nlocksdown=0, nlocksup=1)

assert x.varMayRound().tolist() == [False, True]
assert x.varMayRound("down").tolist() == [False, True]
assert x.varMayRound("up").tolist() == [True, False]


@pytest.mark.skip(reason="Performance test")
def test_add_cons_performance():
start_orig = time()
Expand Down
Loading