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 @@ -6,6 +6,7 @@
- Added SCIP_LPPARAM, setIntParam, setRealParam, getIntParam, getRealParam, isOptimal, getObjVal, getRedcost for lpi
- Added isFeasPositive
### Fixed
- Fixed bug when accessing matrix variable attributes
### Changed
### Removed

Expand Down
28 changes: 14 additions & 14 deletions src/pyscipopt/scip.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
if rc == SCIP_OKAY:
pass
elif rc == SCIP_ERROR:
raise Exception('SCIP: unspecified error!')

Check failure on line 301 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / test-coverage (3.11)

SCIP: unspecified error!
elif rc == SCIP_NOMEMORY:
raise MemoryError('SCIP: insufficient memory error!')
elif rc == SCIP_READERROR:
Expand Down Expand Up @@ -1685,7 +1685,7 @@

"""
vtypes = np.empty(self.shape, dtype=object)
for idx in np.ndindex(self):
for idx in np.ndindex(self.shape):
vtypes[idx] = self[idx].vtype()
return vtypes

Expand All @@ -1700,7 +1700,7 @@

"""
in_lp = np.empty(self.shape, dtype=bool)
for idx in np.ndindex(self):
for idx in np.ndindex(self.shape):
in_lp[idx] = self[idx].isInLP()
return in_lp

Expand All @@ -1715,7 +1715,7 @@
An array of integers. No two should be the same
"""
indices = np.empty(self.shape, dtype=int)
for idx in np.ndindex(self):
for idx in np.ndindex(self.shape):
indices[idx] = self[idx].getIndex()
return indices

Expand All @@ -1730,7 +1730,7 @@
"""

columns = np.empty(self.shape, dtype=object)
for idx in np.index(self):
for idx in np.ndindex(self.shape):
columns[idx] = self[idx].getCol()
return columns

Expand All @@ -1744,7 +1744,7 @@

"""
lbs = np.empty(self.shape, dtype=float)
for idx in np.ndindex(self):
for idx in np.ndindex(self.shape):
lbs[idx] = self[idx].getLbOriginal()
return lbs

Expand All @@ -1758,7 +1758,7 @@

"""
ubs = np.empty(self.shape, dtype=float)
for idx in np.ndindex(self):
for idx in np.ndindex(self.shape):
ubs[idx] = self[idx].getUbOriginal()
return ubs

Expand All @@ -1772,7 +1772,7 @@

"""
lbs = np.empty(self.shape, dtype=float)
for idx in np.ndindex(self):
for idx in np.ndindex(self.shape):
lbs[idx] = self[idx].getLbGlobal()
return lbs

Expand All @@ -1786,7 +1786,7 @@

"""
ubs = np.empty(self.shape, dtype=float)
for idx in np.ndindex(self):
for idx in np.ndindex(self.shape):
ubs[idx] = self[idx].getUbGlobal()
return ubs

Expand All @@ -1800,7 +1800,7 @@

"""
lbs = np.empty(self.shape, dtype=float)
for idx in np.ndindex(self):
for idx in np.ndindex(self.shape):
lbs[idx] = self[idx].getLbLocal()
return lbs

Expand All @@ -1814,7 +1814,7 @@

"""
ubs = np.empty(self.shape, dtype=float)
for idx in np.ndindex(self):
for idx in np.ndindex(self.shape):
ubs[idx] = self[idx].getUbLocal()
return ubs

Expand All @@ -1828,7 +1828,7 @@

"""
objs = np.empty(self.shape, dtype=float)
for idx in np.ndindex(self):
for idx in np.ndindex(self.shape):
objs[idx] = self[idx].getObj()
return objs

Expand All @@ -1842,7 +1842,7 @@

"""
lpsols = np.empty(self.shape, dtype=float)
for idx in np.ndindex(self):
for idx in np.ndindex(self.shape):
lpsols[idx] = self[idx].getLPSol()
return lpsols

Expand All @@ -1856,7 +1856,7 @@

"""
avgsols = np.empty(self.shape, dtype=float)
for idx in np.ndindex(self):
for idx in np.ndindex(self.shape):
avgsols[idx] = self[idx].getAvgSol()
return avgsols

Expand All @@ -1876,7 +1876,7 @@

"""
mayround = np.empty(self.shape, dtype=bool)
for idx in np.ndindex(self):
for idx in np.ndindex(self.shape):
mayround[idx] = self[idx].varMayRound()
return mayround

Expand Down
16 changes: 16 additions & 0 deletions tests/test_matrix_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,22 @@ def test_documentation():
assert (isinstance(cons, MatrixExprCons))
assert (isinstance(cons[0][0], ExprCons))

def test_MatrixVariable_attributes():
m = Model()
x = m.addMatrixVar(shape=(2,2), vtype='C', name='x', ub=np.array([[5, 6], [2, 8]]), obj=1)
assert x.vtype().tolist() == [['CONTINUOUS', 'CONTINUOUS'], ['CONTINUOUS', 'CONTINUOUS']]
assert x.isInLP().tolist() == [[False, False], [False, False]]
assert x.getIndex().tolist() == [[0, 1], [2, 3]]
assert x.getLbGlobal().tolist() == [[0, 0], [0, 0]]
assert x.getUbGlobal().tolist() == [[5, 6], [2, 8]]
assert x.getObj().tolist() == [[1, 1], [1, 1]]
m.setMaximize()
m.optimize()
assert x.getUbLocal().tolist() == [[5, 6], [2, 8]]
assert x.getLbLocal().tolist() == [[5, 6], [2, 8]]
assert x.getLPSol().tolist() == [[5, 6], [2, 8]]
assert x.getAvgSol().tolist() == [[5, 6], [2, 8]]
assert x.varMayRound().tolist() == [[True, True], [True, True]]

@pytest.mark.skip(reason="Performance test")
def test_performance():
Expand Down