Tags: scipopt/PySCIPOpt
Tags
BUG: `_VarArray` can't handle `MatrixVar` (#1044) * Refactor _VarArray initialization and type checks Simplifies and clarifies the logic for initializing _VarArray by restructuring type checks and error handling. Now uses f-strings for error messages and ensures consistent handling of empty lists and invalid types. * 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. * Add test for indicator constraint with matrix binary var Introduces a new test to verify that addConsIndicator works correctly when the binary variable is a matrix variable, addressing issue #1043. * Update CHANGELOG.md * Declare ptr variable in create_ptr function To fix "Storing unsafe C derivative of temporary Python reference" * Refactor create_ptr to remove redundant size argument The create_ptr function in _VarArray.__cinit__ no longer takes a separate size argument and instead uses len(vars) directly. This simplifies the function signature and reduces redundancy. * Refactor _VarArray initialization logic Inlined the pointer creation logic in _VarArray's __cinit__ method, removing the inner create_ptr function. This simplifies the code and improves readability while maintaining the same functionality. * Update CHANGELOG * Update test for addConsIndicator with activeone flag The test now checks addConsIndicator with both activeone=True and activeone=False, and updates the objective to use binvar.sum(). * ENH: flatten list * BUG: use `np.ravel` avoid to run out of vars range * test binvar with (1, 1, 1) matrix * test binvar with (2, 3) matrix * test binvar with (2, 1) list of lists * correct index * Add TypeError test for addConsIndicator with binvar * Only requiring a 1D array * TST: raise an error while get not 1D array * MAINT: Update error message * TST: update error type * Update CHANGELOG.md * Fix _VarArray initialization for empty input Ensures _VarArray initializes ptr and size to NULL and 0, respectively, before processing input. Prevents allocation and assignment errors when an empty or invalid input is provided. * Remove _VarArray changing from changelog * TST: update the comparing method Co-authored-by: DominikKamp <[email protected]> --------- Co-authored-by: João Dionísio <[email protected]> Co-authored-by: DominikKamp <[email protected]>
Expose Matrix types (#959) * Create branch * start of tests * Added extra dimension * Update tests * First working test * First working test * Expr from matrix variables test * Working version of ExprCons with le * Can now add linear matrix constraints * More robust Matrix classes * add todo * Clean up addMatrixCons function * Add MatrixVar methods * Update TODOs * Add getter functions to matrixConstraint class@ git push * Add checks for missing numpy * Add matrix API to readthedocs * Add minor grammar stuff. Add GCG to similar software * Remove universal build. Add type asserts * Update pipelines to include numpy * Add numpy as a dependency * Remove cimports for now * Support adding MatrixExprCons in addConss * Changed tests a bit * Support querying solution values using MatrixExpr * Add a test * Remove SCIP bug from tests. Already reported * Update CHANGELOG * Add info for 5.4.0 release * Make numpy a dependency (not just at build time) * Most comments addressed * Add test for documentation * Fix documentation * Add solution value accessing to docs * Format test file * Update docs/tutorials/matrix.rst Co-authored-by: Mohammed Ghannam <[email protected]> * Update docs/tutorials/matrix.rst Co-authored-by: Mohammed Ghannam <[email protected]> * Expose Matrix types --------- Co-authored-by: Mark Turner <[email protected]> Co-authored-by: Joao-Dionisio <[email protected]> Co-authored-by: Mark Turner <[email protected]> Co-authored-by: João Dionísio <[email protected]>
New matrix variable functionality (#957) * Create branch * start of tests * Added extra dimension * Update tests * First working test * First working test * Expr from matrix variables test * Working version of ExprCons with le * Can now add linear matrix constraints * More robust Matrix classes * add todo * Clean up addMatrixCons function * Add MatrixVar methods * Update TODOs * Add getter functions to matrixConstraint class@ git push * Add checks for missing numpy * Add matrix API to readthedocs * Add minor grammar stuff. Add GCG to similar software * Remove universal build. Add type asserts * Update pipelines to include numpy * Add numpy as a dependency * Remove cimports for now * Support adding MatrixExprCons in addConss * Changed tests a bit * Support querying solution values using MatrixExpr * Add a test * Remove SCIP bug from tests. Already reported * Update CHANGELOG * Add info for 5.4.0 release * Make numpy a dependency (not just at build time) * Most comments addressed * Add test for documentation * Fix documentation * Add solution value accessing to docs * Format test file * Update docs/tutorials/matrix.rst Co-authored-by: Mohammed Ghannam <[email protected]> * Update docs/tutorials/matrix.rst Co-authored-by: Mohammed Ghannam <[email protected]> --------- Co-authored-by: Mark Turner <[email protected]> Co-authored-by: Mohammed Ghannam <[email protected]> Co-authored-by: Mark Turner <[email protected]> Co-authored-by: Mohammed Ghannam <[email protected]>
PreviousNext