diff --git a/src/main/native/cbc4j.cpp b/src/main/native/cbc4j.cpp index 9557187d16d9c31f5451949ac8b5ddbde46d13b3..3b6da913fbe1b204fe78b024794e52fbc676f68c 100644 --- a/src/main/native/cbc4j.cpp +++ b/src/main/native/cbc4j.cpp @@ -39,6 +39,10 @@ double bestSolution(CbcModel& c, int colIndex){ return c.bestSolution()[colIndex]; } +const double* bestSolution(CbcModel& c){ + return c.bestSolution(); +} + void branchAndBound(CbcModel& c, int doStatistics){ c.branchAndBound(doStatistics); std::cout.flush(); diff --git a/src/main/native/cbc4j.hpp b/src/main/native/cbc4j.hpp index 89094368c236487685f3efee1e7eb7f4fb3dfa0c..cae05f208eca8cbac0771ac0674d3fabcec40098 100644 --- a/src/main/native/cbc4j.hpp +++ b/src/main/native/cbc4j.hpp @@ -13,6 +13,7 @@ using namespace std; void addCol(OsiClpSolverInterface& osi, int numberElements, const int *rows, const double *elements, const double collb, const double colub, const double obj); void addRow(OsiClpSolverInterface& osi, int numberElements, const int *columns, const double *element, const double rowlb, const double rowub); double bestSolution(CbcModel& c, int colIndex); +const double* bestSolution(CbcModel& c); void branchAndBound(CbcModel& c, int doStatistics = 0); void callCbc0 (CbcModel &m); int callCbc1 (int argc, const char *argv[], CbcModel & babSolver); diff --git a/src/main/native/cbc4j.i b/src/main/native/cbc4j.i index 87290cb2d0973981ae1a609d7f680d55d69e9376..9ffe6b604b442849817b066d8eeddae50c7d95c9 100644 --- a/src/main/native/cbc4j.i +++ b/src/main/native/cbc4j.i @@ -11,12 +11,13 @@ using namespace std; typedef std::string String; %typemap(out) const double* { -$result = SWIG_JavaArrayOutDouble(jenv, $1, arg1->getNumCols()); +$result = ($1) ? SWIG_JavaArrayOutDouble(jenv, $1, arg1->getNumCols()) : 0; } extern void addCol(OsiClpSolverInterface& osi, int numberElements, const int *rows, const double *elements, const double collb, const double colub, const double obj); extern void addRow(OsiClpSolverInterface& osi, int numberElements, const int *columns, const double *element, const double rowlb, const double rowub); extern double bestSolution(CbcModel& c, int colIndex); +extern const double* bestSolution(CbcModel& c); extern void branchAndBound(CbcModel& c, int doStatistics = 0); extern void callCbc0 (CbcModel &m); extern int callCbc1 (int argc, const char *argv[], CbcModel & babSolver);