Skip to content

Commit

Permalink
Update cibuildwheel to 2.20.0 to fix issue with CentOS mirrors being …
Browse files Browse the repository at this point in the history
…EOL (#202)

* Update cibuildwheel to 2.20.0 to fix issue with CentOS mirrors being EOL

* CyLP isn't compatible with numpy 2.0

* Replace old PyArray names

* Add hypothesis dependency

* Add missing includes for PyArray_DIM

* Disable Python 3.13 for now. Apparently, CyLP is not compatible yet.

* Try to fix failure on Linux by specifying language level

* Skip pp38-manylinux

---------

Co-authored-by: Ted Ralphs <[email protected]>
  • Loading branch information
a-andre and tkralphs authored Aug 19, 2024
1 parent 90b0f48 commit a73dfe8
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cibuildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
platforms: all

- name: Build wheels
uses: pypa/cibuildwheel@v2.19.1
uses: pypa/cibuildwheel@v2.20.0

- uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion cylp/cpp/ICbcModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PyObject* ICbcModel::getPrimalVariableSolution(){
_import_array();
npy_intp dims = this->solver()->getNumCols();
double* d = (double*)(this->solver()->getColSolution());
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, d );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, d );

return Arr;
}
Expand Down
50 changes: 26 additions & 24 deletions cylp/cpp/IClpSimplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "IClpPackedMatrix.hpp"
#include "OsiClpSolverInterface.hpp"
#include <sstream>
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <numpy/ndarraytypes.h>

int IClpSimplex::argWeightedMax(PyObject* arr, PyObject* arr_ind, PyObject* w, PyObject* w_ind){
//_import_array();
Expand Down Expand Up @@ -345,7 +347,7 @@ bool IClpSimplex::varIsFixed(int ind){
PyObject* IClpSimplex::getStatusArray(){

npy_intp dims = getNumCols() + getNumRows();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_UINT8, this->status_ );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_UINT8, this->status_ );

return Arr;
}
Expand All @@ -354,7 +356,7 @@ PyObject* IClpSimplex::getStatusArray(){
PyObject* IClpSimplex::getReducedCosts(){

npy_intp dims = getNumCols() + getNumRows();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->djRegion() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->djRegion() );

return Arr;
}
Expand All @@ -370,15 +372,15 @@ void IClpSimplex::setReducedCosts(double* rc){
PyObject* IClpSimplex::getComplementarityList(){

npy_intp dims = getNumCols() + getNumRows();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_INT32, QP_ComplementarityList );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT32, QP_ComplementarityList );

return Arr;
}

PyObject* IClpSimplex::getPivotVariable(){

npy_intp dims = getNumRows();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_INT32, this->pivotVariable() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT32, this->pivotVariable() );

return Arr;
}
Expand All @@ -387,113 +389,113 @@ PyObject* IClpSimplex::getPivotVariable(){
PyObject* IClpSimplex::getPrimalRowSolution(){

npy_intp dims = getNumRows();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->primalRowSolution() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->primalRowSolution() );

return Arr;
}

PyObject* IClpSimplex::getPrimalColumnSolution(){

npy_intp dims = getNumCols();
PyObject *Arr = PyArray_SimpleNewFromData(1, &dims, PyArray_DOUBLE, this->primalColumnSolution() );
PyObject *Arr = PyArray_SimpleNewFromData(1, &dims, NPY_DOUBLE, this->primalColumnSolution() );

return Arr;
}

PyObject* IClpSimplex::getPrimalColumnSolutionAll(){
npy_intp dims = getNumCols() + getNumRows();
PyObject *Arr = PyArray_SimpleNewFromData(1, &dims, PyArray_DOUBLE, this->primalColumnSolution() );
PyObject *Arr = PyArray_SimpleNewFromData(1, &dims, NPY_DOUBLE, this->primalColumnSolution() );
return Arr;
}

PyObject* IClpSimplex::getSolutionRegion(){
npy_intp dims = getNumCols() + getNumRows();
PyObject *Arr = PyArray_SimpleNewFromData(1, &dims, PyArray_DOUBLE, this->solutionRegion() );
PyObject *Arr = PyArray_SimpleNewFromData(1, &dims, NPY_DOUBLE, this->solutionRegion() );
return Arr;
}

PyObject* IClpSimplex::getCostRegion(){
npy_intp dims = getNumCols() + getNumRows();
PyObject *Arr = PyArray_SimpleNewFromData(1, &dims, PyArray_DOUBLE, this->costRegion() );
PyObject *Arr = PyArray_SimpleNewFromData(1, &dims, NPY_DOUBLE, this->costRegion() );
return Arr;
}

PyObject* IClpSimplex::getDualRowSolution(){

npy_intp dims = getNumRows();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->dualRowSolution() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->dualRowSolution() );

return Arr;
}

PyObject* IClpSimplex::getDualColumnSolution(){

npy_intp dims = getNumCols();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->dualColumnSolution() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->dualColumnSolution() );

return Arr;
}

PyObject* IClpSimplex::getObjective(){

npy_intp dims = getNumCols();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->objective() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->objective() );
return Arr;
}

PyObject* IClpSimplex::getRowLower(){

npy_intp dims = getNumRows();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->rowLower() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->rowLower() );
return Arr;
}

PyObject* IClpSimplex::getRowUpper(){

npy_intp dims = getNumRows();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->rowUpper() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->rowUpper() );
return Arr;
}

PyObject* IClpSimplex::getUpper(){

npy_intp dims = getNumRows() + getNumCols();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->upperRegion() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->upperRegion() );
return Arr;
}

PyObject* IClpSimplex::getLower(){

npy_intp dims = getNumRows() + getNumCols();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->lowerRegion() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->lowerRegion() );
return Arr;
}

PyObject* IClpSimplex::getColLower(){

npy_intp dims = getNumCols();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->columnLower() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->columnLower() );
return Arr;
}

PyObject* IClpSimplex::getColUpper(){

npy_intp dims = getNumCols();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->columnUpper() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->columnUpper() );
return Arr;
}

PyObject* IClpSimplex::getColumnScale(){

npy_intp dims = getNumCols();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, columnScale_);
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, columnScale_);
return Arr;
}

PyObject* IClpSimplex::getRowScale(){

npy_intp dims = getNumRows();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, rowScale_ );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, rowScale_ );
return Arr;
}

Expand All @@ -503,9 +505,9 @@ PyObject* IClpSimplex::getIntegerInformation(){
npy_intp dims = getNumCols();
PyObject* Arr;
if (this->integerInformation())
Arr = PyArray_SimpleNewFromData(1, &dims, PyArray_INT8, this->integerInformation());
Arr = PyArray_SimpleNewFromData(1, &dims, NPY_INT8, this->integerInformation());
else
Arr = PyArray_ZEROS(1, &dims, PyArray_INT8, 0);
Arr = PyArray_ZEROS(1, &dims, NPY_INT8, 0);
return Arr;
}

Expand Down Expand Up @@ -1391,7 +1393,7 @@ PyObject* IClpSimplex::filterVars(PyObject* inds){
npy_intp inds_len = PyArray_DIM(inds, 0);
if (inds_len == 0){
npy_intp dims = 0;
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_INT, tempIntArray );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT, tempIntArray );
return Arr;
}
if (tempArrayExists == false)
Expand All @@ -1417,7 +1419,7 @@ PyObject* IClpSimplex::filterVars(PyObject* inds){
}

npy_intp dims = ind_count;
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_INT, tempIntArray );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT, tempIntArray );
return Arr;

}
Expand Down
7 changes: 5 additions & 2 deletions cylp/cpp/ICoinIndexedVector.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "ICoinIndexedVector.hpp"

#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <numpy/ndarraytypes.h>

ICoinIndexedVector::ICoinIndexedVector(){
_import_array();
}
Expand All @@ -9,7 +12,7 @@ PyObject* ICoinIndexedVector::getIndicesNPArray(){

npy_intp dims = this->getNumElements();
PyObject *Arr = PyArray_SimpleNewFromData(1, &dims,
PyArray_INT32,
NPY_INT32,
this->getIndices());
return Arr;
}
Expand All @@ -18,7 +21,7 @@ PyObject* ICoinIndexedVector::getDenseVectorNPArray(){

npy_intp dims = this->capacity();
PyObject *Arr = PyArray_SimpleNewFromData(1, &dims,
PyArray_DOUBLE,
NPY_DOUBLE,
this->denseVector());
return Arr;
}
Expand Down
24 changes: 12 additions & 12 deletions cylp/cpp/ICoinMpsIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,87 +88,87 @@ double * ICoinMpsIO::IObjCoefficients() const
PyObject* ICoinMpsIO::np_getColLower(){
npy_intp dims = this->getNumCols();
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->IColLower() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->IColLower() );
return Arr;
}


PyObject* ICoinMpsIO::np_getColUpper(){
npy_intp dims = this->getNumCols();
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->IColUpper() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->IColUpper() );
return Arr;
}

PyObject* ICoinMpsIO::np_getRowSense(){
npy_intp dims = this->getNumRows();
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_INT8, this->IRowSense() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT8, this->IRowSense() );
return Arr;
}


PyObject* ICoinMpsIO::np_getRightHandSide(){
npy_intp dims = this->getNumRows();
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->IRightHandSide() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->IRightHandSide() );
return Arr;
}

PyObject* ICoinMpsIO::np_getRowRange(){
npy_intp dims = this->getNumRows();
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->IRowRange() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->IRowRange() );
return Arr;
}

PyObject* ICoinMpsIO::np_getRowLower(){
npy_intp dims = this->getNumRows();
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->IRowLower() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->IRowLower() );
return Arr;
}

PyObject* ICoinMpsIO::np_getRowUpper(){
npy_intp dims = this->getNumRows();
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->IRowUpper() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->IRowUpper() );
return Arr;
}

PyObject* ICoinMpsIO::np_getObjCoefficients(){
npy_intp dims = this->getNumCols();
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->IObjCoefficients() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->IObjCoefficients() );
return Arr;
}

PyObject* ICoinMpsIO::np_integerColumns(){
npy_intp dims = this->getNumCols();
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_INT8, this->IintegerColumns() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT8, this->IintegerColumns() );
return Arr;
}


PyObject* ICoinMpsIO::getQPColumnStarts(){
npy_intp dims = this->getNumCols() + 1;
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_INT32, d_colStart );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT32, d_colStart );
return Arr;
}

PyObject* ICoinMpsIO::getQPColumns(){
npy_intp dims = d_colStart[this->getNumCols()];
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_INT32, d_cols );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT32, d_cols );
return Arr;
}

PyObject* ICoinMpsIO::getQPElements(){
npy_intp dims = d_colStart[this->getNumCols()];
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, d_elements );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, d_elements );
return Arr;
}

Expand Down
8 changes: 4 additions & 4 deletions cylp/cpp/ICoinPackedMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@ PyObject* ICoinPackedMatrix::np_getIndices(){

npy_intp dims = this->getNumElements();
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_INT32, this->IgetIndices() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT32, this->IgetIndices() );
return Arr;
}

PyObject* ICoinPackedMatrix::np_getElements(){

npy_intp dims = this->getNumElements();
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_DOUBLE, this->IgetElements() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->IgetElements() );
return Arr;
}

PyObject* ICoinPackedMatrix::np_getMajorIndices(){

npy_intp dims = this->getNumElements();
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_INT32, this->getMajorIndices() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT32, this->getMajorIndices() );
return Arr;
}


PyObject* ICoinPackedMatrix::np_getVectorStarts(){
npy_intp dims = this->getMajorDim() + 1;
_import_array();
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, PyArray_INT32, this->IgetVectorStarts() );
PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT32, this->IgetVectorStarts() );
return Arr;
}

Expand Down
Loading

0 comments on commit a73dfe8

Please sign in to comment.