Commit 91487e66 authored by Patrik Dufresne's avatar Patrik Dufresne

Add a method to return bestSolution with single JNI call.

To avoid multiple call to get the best solution of the linear problem,
add a method to return a double[].
parent 80bcb320
......@@ -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();
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment