Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
885865a
Refactor _VarArray initialization and type checks
Zeroto521 Jul 31, 2025
9451cc6
Refactor _VarArray to support MatrixVariable input
Zeroto521 Jul 31, 2025
7ee3a6f
Add test for indicator constraint with matrix binary var
Zeroto521 Jul 31, 2025
2cde7a6
Update CHANGELOG.md
Zeroto521 Jul 31, 2025
50bb995
Declare ptr variable in create_ptr function
Zeroto521 Jul 31, 2025
d72f951
Refactor create_ptr to remove redundant size argument
Zeroto521 Jul 31, 2025
110679f
Refactor _VarArray initialization logic
Zeroto521 Jul 31, 2025
f181cf4
Update CHANGELOG
Zeroto521 Jul 31, 2025
0346c52
Update test for addConsIndicator with activeone flag
Zeroto521 Jul 31, 2025
68f2e44
ENH: flatten list
Zeroto521 Aug 1, 2025
5580e12
BUG: use `np.ravel` avoid to run out of vars range
Zeroto521 Aug 1, 2025
8fc900c
Merge branch 'master' into fix/1043
Joao-Dionisio Aug 2, 2025
d52eb54
test binvar with (1, 1, 1) matrix
Zeroto521 Aug 3, 2025
8424c6d
test binvar with (2, 3) matrix
Zeroto521 Aug 3, 2025
710a836
test binvar with (2, 1) list of lists
Zeroto521 Aug 3, 2025
3b64e79
correct index
Zeroto521 Aug 3, 2025
2be1117
Add TypeError test for addConsIndicator with binvar
Zeroto521 Aug 4, 2025
7277e55
Merge branch 'master' into fix/1043
Joao-Dionisio Aug 16, 2025
09e3a0f
Only requiring a 1D array
Zeroto521 Aug 18, 2025
c749183
TST: raise an error while get not 1D array
Zeroto521 Aug 18, 2025
cba76c2
MAINT: Update error message
Zeroto521 Aug 18, 2025
44de7b7
TST: update error type
Zeroto521 Aug 18, 2025
1fd24a9
Update CHANGELOG.md
Zeroto521 Aug 18, 2025
1a3d2e1
Fix _VarArray initialization for empty input
Zeroto521 Aug 18, 2025
e17f68b
Remove _VarArray changing from changelog
Zeroto521 Aug 18, 2025
d280764
TST: update the comparing method
Zeroto521 Aug 18, 2025
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
Prev Previous commit
Next Next commit
Refactor _VarArray to support MatrixVariable input
Updated the _VarArray class constructor to handle MatrixVariable inputs in addition to Variable, list, and tuple. Refactored pointer allocation logic into a helper function for improved code clarity and maintainability.
  • Loading branch information
Zeroto521 committed Jul 31, 2025
commit 9451cc6fdf3685bcb43ba44d33524781fabbae08
22 changes: 13 additions & 9 deletions src/pyscipopt/scip.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -2467,19 +2467,23 @@ cdef class _VarArray:
cdef int size

def __cinit__(self, object vars):
if isinstance(vars, Variable):
self.size = 1
self.ptr = <SCIP_VAR**> malloc(sizeof(SCIP_VAR*))
self.ptr[0] = (<Variable>vars).scip_var

elif isinstance(vars, (list, tuple)):
self.size = len(vars)
self.ptr = <SCIP_VAR**> malloc(self.size * sizeof(SCIP_VAR*)) if self.size > 0 else NULL
def create_ptr(size: int, vars: Union[list, tuple, MatrixVariable]):
ptr = <SCIP_VAR**> malloc(self.size * sizeof(SCIP_VAR*)) if size > 0 else NULL
for i, var in enumerate(vars):
if not isinstance(var, Variable):
raise TypeError(f"Expected Variable, got {type(var)}.")
self.ptr[i] = (<Variable>var).scip_var
ptr[i] = (<Variable>var).scip_var
return ptr

if isinstance(vars, Variable):
self.size = 1
self.ptr = create_ptr([vars])
elif isinstance(vars, (list, tuple)):
self.size = len(vars)
self.ptr = create_ptr(vars)
elif isinstance(vars, MatrixVariable):
self.size = vars.size
self.ptr = create_ptr(np.ravel(vars))
else:
raise TypeError(f"Expected Variable or list of Variable, got {type(vars)}.")

Expand Down