Commit 6b304b31 authored by Patrik Dufresne's avatar Patrik Dufresne

Rename javacbc to cbc4j. Cleanup cpp code. Sort members.

parent 00893789
......@@ -11,13 +11,13 @@
<compile.target>x86_64-linux-gnu</compile.target>
<compile.ldflags></compile.ldflags>
<compile.cxxflags></compile.cxxflags>
<javacbc.lib.name>libjavacbc${javacbc.version}.so</javacbc.lib.name>
<javacbc.platform.dir>linux/x86_64</javacbc.platform.dir>
<cbc4j.lib.name>libcbc4j${cbc4j.version}.so</cbc4j.lib.name>
<cbc4j.platform.dir>linux/x86_64</cbc4j.platform.dir>
</properties>
<build>
<plugins>
<!-- Compile cbc and javacbc -->
<!-- The configuration is defined in the parent pom -->
<!-- Compile cbc and cbc4j -->
<!-- The configuration is defined in the parent pom -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
......@@ -56,15 +56,15 @@
failonerror="true">
<arg value="install" />
</exec>
<!-- Compile javacbc -->
<!-- Compile cbc4j -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING JAVACBC" />
<echo message="COMPILING CBC4J" />
<echo message="------------------------------------------------------------------------" />
<copy todir="${project.build.directory}/javacbc">
<copy todir="${project.build.directory}/cbc4j">
<fileset dir="../src/main/native" />
</copy>
<mkdir dir="${swig.generated.sources}/${swig.package.dir}" />
<exec executable="make" dir="${project.build.directory}/javacbc"
<exec executable="make" dir="${project.build.directory}/cbc4j"
failonerror="true">
<env key="SWIG_OUTDIR" path="${swig.generated.sources}/${swig.package.dir}" />
<env key="SWIG_PACKAGE" value="${swig.package.name}" />
......@@ -72,10 +72,10 @@
<env key="JAVADIR" path="/usr/lib/jvm/default-java"/>
<env key="TARGET" value="${compile.target}"/>
<env key="LDFLAGS" value="${compile.ldflags}"/>
<env key="LIBJAVACBC" value ="${javacbc.lib.name}" />
<env key="LIBCBC4J" value ="${cbc4j.lib.name}" />
</exec>
<mkdir dir="${javacbc.generated.resources}/${javacbc.platform.dir}" />
<copy file="${project.build.directory}/javacbc/${javacbc.lib.name}" tofile="${javacbc.generated.resources}/${javacbc.platform.dir}/${javacbc.lib.name}" />
<mkdir dir="${cbc4j.generated.resources}/${cbc4j.platform.dir}" />
<copy file="${project.build.directory}/cbc4j/${cbc4j.lib.name}" tofile="${cbc4j.generated.resources}/${cbc4j.platform.dir}/${cbc4j.lib.name}" />
</target>
</configuration>
</execution>
......@@ -109,7 +109,7 @@
<configuration>
<resources>
<resource>
<directory>${javacbc.generated.resources}</directory>
<directory>${cbc4j.generated.resources}</directory>
</resource>
</resources>
</configuration>
......
......@@ -11,13 +11,13 @@
<compile.target>i686-w64-mingw32</compile.target>
<compile.ldflags>-static-libgcc -static-libstdc++</compile.ldflags>
<compile.cxxflags>-D__MINGW64__</compile.cxxflags>
<javacbc.lib.name>javacbc${javacbc.version}.dll</javacbc.lib.name>
<javacbc.platform.dir>win/x86</javacbc.platform.dir>
<cbc4j.lib.name>cbc4j${cbc4j.version}.dll</cbc4j.lib.name>
<cbc4j.platform.dir>win/x86</cbc4j.platform.dir>
</properties>
<build>
<plugins>
<!-- Compile cbc and javacbc -->
<!-- The configuration is defined in the parent pom -->
<!-- Compile cbc and cbc4j -->
<!-- The configuration is defined in the parent pom -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
......@@ -56,15 +56,15 @@
failonerror="true">
<arg value="install" />
</exec>
<!-- Compile javacbc -->
<!-- Compile cbc4j -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING JAVACBC" />
<echo message="COMPILING CBC4J" />
<echo message="------------------------------------------------------------------------" />
<copy todir="${project.build.directory}/javacbc">
<copy todir="${project.build.directory}/cbc4j">
<fileset dir="../src/main/native" />
</copy>
<mkdir dir="${swig.generated.sources}/${swig.package.dir}" />
<exec executable="make" dir="${project.build.directory}/javacbc"
<exec executable="make" dir="${project.build.directory}/cbc4j"
failonerror="true">
<env key="SWIG_OUTDIR" path="${swig.generated.sources}/${swig.package.dir}" />
<env key="SWIG_PACKAGE" value="${swig.package.name}" />
......@@ -72,10 +72,10 @@
<env key="JAVADIR" path="/usr/lib/jvm/default-java"/>
<env key="TARGET" value="${compile.target}"/>
<env key="LDFLAGS" value="${compile.ldflags}"/>
<env key="LIBJAVACBC" value ="${javacbc.lib.name}" />
<env key="LIBCBC4J" value ="${cbc4j.lib.name}" />
</exec>
<mkdir dir="${javacbc.generated.resources}/${javacbc.platform.dir}" />
<copy file="${project.build.directory}/javacbc/${javacbc.lib.name}" tofile="${javacbc.generated.resources}/${javacbc.platform.dir}/${javacbc.lib.name}" />
<mkdir dir="${cbc4j.generated.resources}/${cbc4j.platform.dir}" />
<copy file="${project.build.directory}/cbc4j/${cbc4j.lib.name}" tofile="${cbc4j.generated.resources}/${cbc4j.platform.dir}/${cbc4j.lib.name}" />
</target>
</configuration>
</execution>
......@@ -109,7 +109,7 @@
<configuration>
<resources>
<resource>
<directory>${javacbc.generated.resources}</directory>
<directory>${cbc4j.generated.resources}</directory>
</resource>
</resources>
</configuration>
......
......@@ -11,13 +11,13 @@
<compile.target>x86_64-w64-mingw32</compile.target>
<compile.ldflags>-static-libgcc -static-libstdc++</compile.ldflags>
<compile.cxxflags></compile.cxxflags>
<javacbc.lib.name>javacbc${javacbc.version}.dll</javacbc.lib.name>
<javacbc.platform.dir>win/x86_64</javacbc.platform.dir>
<cbc4j.lib.name>cbc4j${cbc4j.version}.dll</cbc4j.lib.name>
<cbc4j.platform.dir>win/x86_64</cbc4j.platform.dir>
</properties>
<build>
<plugins>
<!-- Compile cbc and javacbc -->
<!-- The configuration is defined in the parent pom -->
<!-- Compile cbc and cbc4j -->
<!-- The configuration is defined in the parent pom -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
......@@ -56,15 +56,15 @@
failonerror="true">
<arg value="install" />
</exec>
<!-- Compile javacbc -->
<!-- Compile cbc4j -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING JAVACBC" />
<echo message="COMPILING CBC4J" />
<echo message="------------------------------------------------------------------------" />
<copy todir="${project.build.directory}/javacbc">
<copy todir="${project.build.directory}/cbc4j">
<fileset dir="../src/main/native" />
</copy>
<mkdir dir="${swig.generated.sources}/${swig.package.dir}" />
<exec executable="make" dir="${project.build.directory}/javacbc"
<exec executable="make" dir="${project.build.directory}/cbc4j"
failonerror="true">
<env key="SWIG_OUTDIR" path="${swig.generated.sources}/${swig.package.dir}" />
<env key="SWIG_PACKAGE" value="${swig.package.name}" />
......@@ -72,10 +72,10 @@
<env key="JAVADIR" path="/usr/lib/jvm/default-java"/>
<env key="TARGET" value="${compile.target}"/>
<env key="LDFLAGS" value="${compile.ldflags}"/>
<env key="LIBJAVACBC" value ="${javacbc.lib.name}" />
<env key="LIBCBC4J" value ="${cbc4j.lib.name}" />
</exec>
<mkdir dir="${javacbc.generated.resources}/${javacbc.platform.dir}" />
<copy file="${project.build.directory}/javacbc/${javacbc.lib.name}" tofile="${javacbc.generated.resources}/${javacbc.platform.dir}/${javacbc.lib.name}" />
<mkdir dir="${cbc4j.generated.resources}/${cbc4j.platform.dir}" />
<copy file="${project.build.directory}/cbc4j/${cbc4j.lib.name}" tofile="${cbc4j.generated.resources}/${cbc4j.platform.dir}/${cbc4j.lib.name}" />
</target>
</configuration>
</execution>
......@@ -109,7 +109,7 @@
<configuration>
<resources>
<resource>
<directory>${javacbc.generated.resources}</directory>
<directory>${cbc4j.generated.resources}</directory>
</resource>
</resources>
</configuration>
......
......@@ -27,7 +27,7 @@
</distributionManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javacbc.version>10</javacbc.version>
<cbc4j.version>10</cbc4j.version>
<!-- Define the version of cbc dependency -->
<cbc.version>2.8.3</cbc.version>
<!-- Define location of the source -->
......@@ -38,8 +38,8 @@
<swig.package.dir>com/patrikdufresne/cbc4j</swig.package.dir>
<!-- Define destination of generated source -->
<swig.generated.sources>${project.build.directory}/generated-sources/swig</swig.generated.sources>
<!-- Define destination of generated javacbc lib -->
<javacbc.generated.resources>${project.build.directory}/generated-resources/javacbc</javacbc.generated.resources>
<!-- Define destination of generated cbc4j lib -->
<cbc4j.generated.resources>${project.build.directory}/generated-resources/cbc4j</cbc4j.generated.resources>
</properties>
<build>
<plugins>
......
......@@ -37,15 +37,15 @@ public class CBCLibrary {
/**
* cbc java library name.
*/
private static final String JAVACBC_JAVA_LIBNAME = "javacbc10";
private static final String CBC4J_JAVA_LIBNAME = "cbc4j10";
/**
* Relative cbc path according to current architecture.
*/
private static final String JAVACBC_LIB_DIR;
private static final String CBC4J_LIB_DIR;
/**
* cbc library path property name.
*/
private static final String JAVACBC_LIBRARY_PATH = "javacbc.library.path";
private static final String CBC4J_LIBRARY_PATH = "cbc4j.library.path";
/**
* The resource class path separator.
* <p>
......@@ -62,7 +62,7 @@ public class CBCLibrary {
/* Initialize the constant */
DELIMITER = System.getProperty("line.separator"); //$NON-NLS-1$
SEPARATOR = System.getProperty("file.separator"); //$NON-NLS-1$
JAVACBC_LIB_DIR = ".cbc" + SEPARATOR + "lib" + SEPARATOR + os() + SEPARATOR + arch(); //$NON-NLS-1$ $NON-NLS-2$
CBC4J_LIB_DIR = ".cbc" + SEPARATOR + "lib" + SEPARATOR + os() + SEPARATOR + arch(); //$NON-NLS-1$ $NON-NLS-2$
}
/**
......@@ -179,7 +179,7 @@ public class CBCLibrary {
* is the library can't be loaded.
*/
public static void load() {
loadLibrary(JAVACBC_JAVA_LIBNAME);
loadLibrary(CBC4J_JAVA_LIBNAME);
}
/**
......@@ -227,7 +227,7 @@ public class CBCLibrary {
StringBuffer message = new StringBuffer();
/* Try loading library from glpk library path */
String path = System.getProperty(JAVACBC_LIBRARY_PATH); //$NON-NLS-1$
String path = System.getProperty(CBC4J_LIBRARY_PATH); //$NON-NLS-1$
if (path != null) {
path = new File(path).getAbsolutePath();
if (load(path, libName1, message)) return;
......@@ -242,7 +242,7 @@ public class CBCLibrary {
String fileName1 = mapLibraryName(libName1);
if (path == null) {
path = System.getProperty("user.home"); //$NON-NLS-1$
File dir = new File(path, JAVACBC_LIB_DIR);
File dir = new File(path, CBC4J_LIB_DIR);
if ((dir.exists() && dir.isDirectory()) || dir.mkdirs()) {
path = dir.getAbsolutePath();
} else {
......
#Makefile for javaCbc
#Makefile for cbc4j
$(LIBJAVACBC): javacbc.o javacbc_wrap.o
$(TARGET)-g++ -shared -DNDEBUG javacbc.o javacbc_wrap.o -L$(CBCDIR)/lib -lCbcSolver -lCbc -lCgl -lOsiClp -lOsiCbc -lOsi -lClp -lCoinUtils -lm $(LDFLAGS) -o $(LIBJAVACBC)
$(LIBCBC4J): cbc4j.o cbc4j_wrap.o
$(TARGET)-g++ -shared -DNDEBUG cbc4j.o cbc4j_wrap.o -L$(CBCDIR)/lib -lCbcSolver -lCbc -lCgl -lOsiClp -lOsiCbc -lOsi -lClp -lCoinUtils -lm $(LDFLAGS) -o $(LIBCBC4J)
javacbc.o: javacbc.cpp javacbc.hpp
$(TARGET)-g++ -fPIC -c javacbc.cpp -I$(CBCDIR)/include/coin -I$(JAVADIR)/include/ -I$(JAVADIR)/include/linux -I.
cbc4j.o: cbc4j.cpp cbc4j.hpp
$(TARGET)-g++ -fPIC -c cbc4j.cpp -I$(CBCDIR)/include/coin -I$(JAVADIR)/include/ -I$(JAVADIR)/include/linux -I.
javacbc_wrap.o: javacbc_wrap.cxx
$(TARGET)-g++ -fPIC -c javacbc_wrap.cxx -I$(CBCDIR)/include/coin -I$(JAVADIR)/include/ -I$(JAVADIR)/include/linux -I.
cbc4j_wrap.o: cbc4j_wrap.cxx
$(TARGET)-g++ -fPIC -c cbc4j_wrap.cxx -I$(CBCDIR)/include/coin -I$(JAVADIR)/include/ -I$(JAVADIR)/include/linux -I.
javacbc_wrap.cxx: javacbc.i javacbc.hpp
swig -outdir "$(SWIG_OUTDIR)" -package "$(SWIG_PACKAGE)" -c++ -java javacbc.i
cbc4j_wrap.cxx: cbc4j.i cbc4j.hpp
swig -outdir "$(SWIG_OUTDIR)" -package "$(SWIG_PACKAGE)" -c++ -java cbc4j.i
all: $(LIBJAVACBC)
all: $(LIBCBC4J)
%module cbc4j
%{
#include "cbc4j.hpp"
%}
%include "arrays_java.i";
%include "std_string.i";
%include "various.i"
%apply double[] {double *};
%apply int[] {int *};
%apply char **STRING_ARRAY { const char *argv[] }
using namespace std;
typedef std::string String;
%typemap(out) const double* {
$result = SWIG_JavaArrayOutDouble(jenv, $1, arg1->getNumCols());
}
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 void branchAndBound(CbcModel& c, int doStatistics = 0);
extern void callCbc0 (CbcModel &m);
extern int callCbc1 (int argc, const char *argv[], CbcModel & babSolver);
extern void deleteCbcModel(CbcModel* c);
extern void deleteCols(OsiClpSolverInterface& osi, const int num, const int *colIndices);
extern void deleteRows(OsiClpSolverInterface& osi, const int num, const int *rowIndices);
extern void deleteOsiClpSolverInterface(OsiClpSolverInterface* solver);
extern double getCbcColSolution(CbcModel& c, int colIndex);
extern double getCbcRowLower(CbcModel& c, int rowIndex);
extern double getCbcRowUpper(CbcModel& c, int rowIndex);
extern double getCoefficient(OsiClpSolverInterface& osi, int row, int col);
extern double getColLower(CbcModel& c, int colIndex);
extern double getColLower(OsiClpSolverInterface& osi, int elementIndex);
extern std::string getColName(OsiClpSolverInterface& osi, int colIndex, unsigned maxLen=std::string::npos);
extern double getColSolution(OsiClpSolverInterface& osi, int colIndex);
extern double getColSolution(OsiSolverInterface& osi, int colIndex);
extern double getColUpper(CbcModel& c, int colIndex);
extern double getColUpper(OsiClpSolverInterface& osi, int elementIndex);
extern double getInfinity(CbcModel& c);
extern double getInfinity(OsiClpSolverInterface& osi);
extern double getObjCoefficients(CbcModel& c, int colIndex);
extern double getObjSense(CbcModel& c);
extern int getNumCols(CbcModel& c);
extern int getNumCols(OsiClpSolverInterface& osi);
extern int getNumRows(CbcModel& c);
extern int getNumRows(OsiClpSolverInterface& osi);
extern double getObjCoefficients(OsiClpSolverInterface& osi, int elementIndex);
extern const double* getObjCoefficients(OsiClpSolverInterface& osi);
extern double getObjValue(CbcModel& c);
extern double getObjValue(OsiClpSolverInterface& osi);
extern double getObjValue(OsiSolverInterface& c);
extern double getObjSense(OsiClpSolverInterface& osi);
extern double getRowLower(CbcModel& c, int rowIndex);
extern double getRowLower(OsiClpSolverInterface& osi, int rowIndex);
extern std::string getRowName(OsiClpSolverInterface& osi, int rowIndex, unsigned maxLen=std::string::npos);
extern double getRowUpper(CbcModel& c, int rowIndex);
extern double getRowUpper(OsiClpSolverInterface& osi, int rowIndex);
extern void initialSolve(CbcModel& c);
extern void initialSolve(OsiClpSolverInterface& solver);
extern bool isBinary(CbcModel& c, int colIndex);
extern bool isBinary(OsiClpSolverInterface& osi, int colIndex);
extern bool isContinuous(CbcModel& c, int colIndex);
extern bool isContinuous(OsiClpSolverInterface& osi, int colNumber);
extern bool isInteger(CbcModel& c, int colIndex);
extern bool isInteger(OsiClpSolverInterface& osi, int colIndex);
extern bool isProvenOptimal(CbcModel& c);
extern bool isProvenOptimal(OsiClpSolverInterface& osi);
extern bool isProvenInfeasible(CbcModel& c);
extern CbcModel* newCbcModel(OsiClpSolverInterface& s);
extern OsiClpSolverInterface* newOsiClpSolverInterface();
extern void modifyCoefficient(OsiClpSolverInterface& osi, int row, int column, double newElement, bool keepZero=false);
extern int readLp(OsiClpSolverInterface& osi, const char *filename, const double epsilon=1e-5);
extern void resolve(OsiSolverInterface& osi);
extern void setCoefficients(OsiClpSolverInterface& osi, int row, int numberElements, const int *cols, const double *coefs);
extern void setColBounds(OsiClpSolverInterface& osi, int elementIndex, double lower, double upper);
extern void setColLower(OsiClpSolverInterface& osi, int elementIndex, double elementValue);
extern void setColName(OsiClpSolverInterface& osi, int colIndex, std::string name);
extern void setColUpper(OsiClpSolverInterface& osi, int elementIndex, double elementValue);
extern void setContinuous(OsiClpSolverInterface& osi, int index);
extern void setInteger(OsiClpSolverInterface& osi, int index);
extern void setLogLevel(CbcModel& c, int n);
extern void setLogLevel(OsiClpSolverInterface& s, int n);
extern void setObjective(OsiClpSolverInterface& osi, const double *array);
extern void setObjCoeff(OsiClpSolverInterface& osi, int elementIndex, double elementValue);
extern void setObjCoefficients(OsiClpSolverInterface& osi, int numberElements, const int *rows, const double *coefs);
extern void setObjSense(CbcModel& c, double s);
extern void setObjSense(OsiClpSolverInterface& osi, double s);
extern void setRowLower(OsiClpSolverInterface& osi, int elementIndex, double elementValue);
extern void setRowName(OsiClpSolverInterface& osi, int rowIndex, std::string name);
extern void setRowUpper(OsiClpSolverInterface& osi, int elementIndex, double elementValue);
extern OsiClpSolverInterface* solver(CbcModel& m);
extern int status(CbcModel& c);
extern void writeLp(OsiClpSolverInterface& osi, const char *filename, const char *extension="lp", double epsilon=1e-5, int numberAcross=10, int decimals=5, double objSense=0.0, bool useRowNames=true);
%module javacbc
%{
#include "javacbc.hpp"
%}
%include "arrays_java.i";
%include "std_string.i";
%include "various.i"
%apply double[] {double *};
%apply int[] {int *};
%apply char **STRING_ARRAY { const char *argv[] }
using namespace std;
typedef std::string String;
// Solve initial LP relaxation.
extern void initialSolve(OsiClpSolverInterface &solver);
extern void setInt(OsiClpSolverInterface &solver, int i);
// Default Constructor.
extern OsiClpSolverInterface* newOsiClpSolverInterface();
// Delete OsiClpSolverInterface
extern void deleteOsiClpSolverInterface(OsiClpSolverInterface* solver);
// Create a new instance of CbcModel
extern CbcModel* newCbcModel(OsiClpSolverInterface &s);
extern void deleteCbcModel(CbcModel* c);
extern void initialSolve(CbcModel &c);
extern void branchAndBound(CbcModel &c, int doStatistics = 0);
extern int status(CbcModel &c);
extern bool isProvenOptimal(CbcModel &c);
extern bool isProvenInfeasible(CbcModel &c);
extern int getNumCols(CbcModel &c);
extern int getNumRows(CbcModel &c) ;
extern double getColLower(CbcModel &c, int colIndex);
extern double getColUpper(CbcModel &c, int colIndex);
extern double getObjCoefficients(CbcModel &c, int colIndex);
extern double getCbcColSolution(CbcModel &c, int colIndex);
extern double getRowLower(CbcModel &c, int rowIndex);
extern double getRowUpper(CbcModel &c, int rowIndex);
extern double getCbcRowLower(CbcModel &c, int rowIndex);
extern double getCbcRowUpper(CbcModel &c, int rowIndex);
extern double getObjSense(CbcModel &c);
extern void setObjSense(CbcModel &c, double s);
extern bool isContinuous(CbcModel &c, int colIndex);
extern bool isBinary(CbcModel &c, int colIndex);
extern bool isInteger(CbcModel &c, int colIndex);
extern const CoinPackedMatrix* getMatrixByCol(CbcModel &c);
extern double getInfinity(CbcModel &c);
extern double getObjValue(CbcModel &c);
extern void setLogLevel(CbcModel &c, int n);
//OsiClpSolverInterface proxy functions and constructor
//Methods returning info on how the solution process terminated
extern bool isProvenOptimal(OsiClpSolverInterface &osi); //Is optimality proven?
//Methods related to querying the input data
extern int getNumCols(OsiClpSolverInterface &osi);// Get number of columns.
extern int getNumRows(OsiClpSolverInterface &osi);// Get number of rows.
extern std::string getRowName(OsiClpSolverInterface &osi, int rowIndex, unsigned maxLen=std::string::npos);// Return name of row if one exists or Rnnnnnnn maxLen is currently ignored and only there to match the signature from the base class!
extern std::string getColName(OsiClpSolverInterface &osi, int colIndex, unsigned maxLen=std::string::npos);// Return name of column if one exists or Cnnnnnnn maxLen is currently ignored and only there to match the signature from the base class!
extern double getColLower(OsiClpSolverInterface &osi, int elementIndex); // Get pointer to array[getNumCols()] of column lower bounds.
extern double getColUpper(OsiClpSolverInterface &osi, int elementIndex); // Get pointer to array[getNumCols()] of column upper bounds.
extern double getObjCoefficients(OsiClpSolverInterface &osi, int elementIndex); // Get pointer to array[getNumCols()] of objective function coefficients.
extern double getRowLower(OsiClpSolverInterface &osi, int rowIndex);// Get pointer to array[getNumRows()] of row lower bounds.
extern double getRowUpper(OsiClpSolverInterface &osi, int rowIndex);// Get pointer to array[getNumRows()] of row upper bounds.
extern double getObjSense(OsiClpSolverInterface &osi);// Get objective function sense (1 for min (default), -1 for max).
extern void setObjSense(OsiClpSolverInterface &osi, double s);// Sets objective function sense (1 for min (default), -1 for max).
extern bool isContinuous(OsiClpSolverInterface &osi, int colNumber);// Return true if column is continuous.
extern bool isBinary(OsiClpSolverInterface &osi, int colIndex);// Return true if variable is binary.
extern bool isInteger(OsiClpSolverInterface &osi, int colIndex);// Return true if column is integer.
extern const CoinPackedMatrix * getMatrixByCol(OsiClpSolverInterface &osi);// Get pointer to column-wise copy of matrix.
extern double getInfinity(OsiClpSolverInterface &osi);// Get solver's value for infinity.
//Methods related to querying the solution
extern double getColSolution(OsiClpSolverInterface &osi, int colIndex);// Get pointer to array[getNumCols()] of primal solution vector.
extern double getObjValue(OsiClpSolverInterface &osi);// Get objective function value.
//Changing bounds on variables and constraints
void setObjCoeff(OsiClpSolverInterface &osi, int elementIndex, double elementValue);// Set an objective function coefficient.
void setColLower(OsiClpSolverInterface &osi, int elementIndex, double elementValue);// Set a single column lower bound, Use -DBL_MAX for -infinity.
void setColUpper(OsiClpSolverInterface &osi, int elementIndex, double elementValue);// Set a single column upper bound, Use DBL_MAX for infinity.
void setColBounds(OsiClpSolverInterface &osi, int elementIndex, double lower, double upper);// Set a single column lower and upper bound.
void setRowLower(OsiClpSolverInterface &osi, int elementIndex, double elementValue);// Set a single row lower bound, Use -DBL_MAX for -infinity.
void setRowUpper(OsiClpSolverInterface &osi, int elementIndex, double elementValue);// Set a single row upper bound, Use DBL_MAX for infinity.
void setObjective(OsiClpSolverInterface &osi, const double *array);// Set the objective coefficients for all columns array [getNumCols()] is an array of values for the objective.
void setRowName(OsiClpSolverInterface &osi, int rowIndex, std::string name);// Set name of row.
void setColName(OsiClpSolverInterface &osi, int colIndex, std::string name);// Set name of column.
//Integrality related changing methods
void setContinuous(OsiClpSolverInterface &osi, int index);// Set the index-th variable to be a continuous variable.
void setInteger(OsiClpSolverInterface &osi, int index);// Set the index-th variable to be an integer variable.
//Methods to expand a problem.
//Note that if a column is added then by default
//it will correspond to a continuous variable.
extern void addCol(OsiClpSolverInterface &osi, int numberElements, const int *rows, const double *elements, const double collb, const double colub, const double obj);// Add a column (primal variable) to the problem.
extern void deleteCols(OsiClpSolverInterface &osi, const int num, const int *colIndices);// Remove a set of columns (primal variables) from the problem.
extern void addRow(OsiClpSolverInterface &osi, int numberElements, const int *columns, const double *element, const double rowlb, const double rowub);// Add a row (constraint) to the problem.
extern void modifyCoefficient(OsiClpSolverInterface &osi, int row, int column, double newElement, bool keepZero=false);
extern void deleteRows(OsiClpSolverInterface &osi, const int num, const int *rowIndices);// Delete a set of rows (constraints) from the problem.
//Methods to input a problem
extern int readLp(OsiClpSolverInterface &osi, const char *filename, const double epsilon=1e-5);// Read file in LP format (with names).
extern void writeLp(OsiClpSolverInterface &osi, const char *filename, const char *extension="lp", double epsilon=1e-5, int numberAcross=10, int decimals=5, double objSense=0.0, bool useRowNames=true);// Write the problem into an Lp file of the given filename.
// Resolve an LP relaxation after problem modification.
extern void resolve(OsiSolverInterface& osi);
// Returns solver - has current state.
extern OsiClpSolverInterface* solver(CbcModel &m);
// Set current log (detail) level.
extern void setLogLevel(OsiClpSolverInterface &s, int n);
// Get pointer to array[getNumCols()] of objective function coefficients.
%typemap(out) const double* {
$result = SWIG_JavaArrayOutDouble(jenv, $1, arg1->getNumCols());
}
extern const double* getObjCoefficients(OsiClpSolverInterface &osi);
// Sets the objective coefficient
extern void setObjCoefficients(OsiClpSolverInterface &osi, int numberElements, const int *rows, const double *coefs);
// Sets the coefficients for a row
extern void setCoefficients(OsiClpSolverInterface &osi, int row, int numberElements, const int *cols, const double *coefs);
// Return the coefficient.
extern double getCoefficient(OsiClpSolverInterface &osi, int row, int col);
// Run the solver using CbcMain0
extern void callCbc0 (CbcModel &babSolver);
// Run the solver using CbcMain1
extern int callCbc1 (int argc, const char *argv[], CbcModel &babSolver);
// Get objective function value.
extern double getObjValue(OsiSolverInterface& c);
// Get pointer to array[getNumCols()] of primal solution vector.
extern double getColSolution(OsiSolverInterface& osi, int colIndex);
extern double bestSolution(CbcModel& c, int colIndex);
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