Skip to content
Commits on Source (4)
......@@ -6,27 +6,20 @@ variables:
-Djava.awt.headless=true
-Dmaven.repo.local=.m2/repository"
# Cache downloaded dependencies and plugins between builds.
cache:
paths:
- .m2/repository
stages:
- build
before_script:
- export REVISION="$(curl http://git.patrikdufresne.com/pdsl/maven-scm-version/raw/master/version.sh | bash -)"
- echo "REVISION=$REVISION"
test_deploy:
build:
stage: build
before_script:
- export REVISION="$(curl http://git.patrikdufresne.com/pdsl/maven-scm-version/raw/master/version.sh | bash -)"
- echo "REVISION=$REVISION"
# Install SWIG
- wget https://sourceforge.net/projects/swig/files/swig/swig-4.0.0/swig-4.0.0.tar.gz
- tar -zxvf swig-4.0.0.tar.gz
- cd swig-4.0.0
- ./configure && make && make install
- cd ..
script:
- apt-get update && apt-get install -y default-jdk swig build-essential gcc-mingw-w64 mingw-w64 g++-multilib
- apt-get update && apt-get install -y build-essential gcc-mingw-w64 mingw-w64 g++-multilib
- mvn -B -s ./settings.xml -Drevision=${REVISION} clean install deploy
sonar:
stage: build
allow_failure: true
script:
- apt-get update && apt-get install -y default-jdk swig build-essential gcc-mingw-w64 mingw-w64 g++-multilib
- mvn -B -Drevision=${REVISION} -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_TOKEN org.jacoco:jacoco-maven-plugin:prepare-agent clean verify sonar:sonar
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.patrikdufresne.cbc4j</groupId>
......@@ -8,10 +9,10 @@
<artifactId>cbc4j-linux-x86_64</artifactId>
<properties>
<compile.target>x86_64-linux-gnu</compile.target>
<compile.ldflags />
<compile.ldflags />
<compile.cxxflags />
<cbc4j.lib.name>libcbc4j${cbc4j.version}.so</cbc4j.lib.name>
<cbc4j.platform.dir>linux/x86_64</cbc4j.platform.dir>
<cbc4j.lib.name>libcbc4j${cbc4j.version}.so</cbc4j.lib.name>
<cbc4j.platform.dir>linux/x86_64</cbc4j.platform.dir>
</properties>
<build>
<plugins>
......@@ -27,50 +28,54 @@
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- Get the coin-cbc source -->
<get src="${cbc.url}" dest="${cbc.dir}.tgz" skipexisting="true" />
<untar src="${cbc.dir}.tgz" dest="${project.build.directory}" compression="gzip" />
<!-- Configure coin-cbc -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING COIN_CBC" />
<echo message="------------------------------------------------------------------------" />
<chmod dir="${cbc.dir}" perm="+x" includes="configure,**/install-sh" />
<exec executable="./configure" dir="${cbc.dir}" failonerror="true">
<env key="LDFLAGS" value="${compile.ldflags}" />
<env key="CXXFLAGS" value="${compile.cxxflags}" />
<arg value="--disable-shared" />
<arg value="--with-pic" />
<arg value="--target=${compile.target}" />
<arg value="--host=${compile.target}" />
</exec>
<!-- Compile coin-cbc -->
<exec executable="make" dir="${cbc.dir}" failonerror="true" />
<exec executable="make" dir="${cbc.dir}" failonerror="true">
<arg value="install" />
</exec>
<!-- Compile cbc4j -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING CBC4J" />
<echo message="------------------------------------------------------------------------" />
<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}/cbc4j" failonerror="true">
<env key="SWIG_OUTDIR" path="${swig.generated.sources}/${swig.package.dir}" />
<env key="SWIG_PACKAGE" value="${swig.package.name}" />
<env key="CBCDIR" path="${cbc.dir}" />
<env key="JAVADIR" path="/usr/lib/jvm/default-java" />
<env key="TARGET" value="${compile.target}" />
<env key="LDFLAGS" value="${compile.ldflags}" />
<env key="LIBCBC4J" value="${cbc4j.lib.name}" />
</exec>
<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>
<configuration>
<target>
<!-- Get the coin-cbc source -->
<get src="${cbc.url}" dest="${cbc.dir}.tgz" skipexisting="true" />
<untar src="${cbc.dir}.tgz" dest="${project.build.directory}" compression="gzip" />
<!-- Configure coin-cbc -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING COIN_CBC" />
<echo message="------------------------------------------------------------------------" />
<chmod dir="${cbc.dir}" perm="+x" includes="configure,**/install-sh" />
<exec executable="./configure" dir="${cbc.dir}" failonerror="true">
<env key="LDFLAGS" value="${compile.ldflags}" />
<env key="CXXFLAGS" value="${compile.cxxflags}" />
<arg value="--disable-shared" />
<arg value="--with-pic" />
<arg value="--target=${compile.target}" />
<arg value="--host=${compile.target}" />
</exec>
<!-- Compile coin-cbc -->
<exec executable="make" dir="${cbc.dir}" failonerror="true" />
<exec executable="make" dir="${cbc.dir}" failonerror="true">
<arg value="install" />
</exec>
<exec executable="bash" dir="${cbc.dir}" failonerror="true">
<arg value="-c" />
<arg value="for FILE in ${project.basedir}/../patches/*.diff; do patch -p1 &lt; $FILE; done" />
</exec>
<!-- Compile cbc4j -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING CBC4J" />
<echo message="------------------------------------------------------------------------" />
<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}/cbc4j" failonerror="true">
<env key="SWIG_OUTDIR" path="${swig.generated.sources}/${swig.package.dir}" />
<env key="SWIG_PACKAGE" value="${swig.package.name}" />
<env key="CBCDIR" path="${cbc.dir}" />
<env key="JAVADIR" path="/usr/lib/jvm/default-java" />
<env key="TARGET" value="${compile.target}" />
<env key="LDFLAGS" value="${compile.ldflags}" />
<env key="LIBCBC4J" value="${cbc4j.lib.name}" />
</exec>
<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>
</executions>
</plugin>
......@@ -89,7 +94,7 @@
<configuration>
<sources>
<source>${swig.generated.sources}</source>
<source>../src/main/java</source>
<source>../src/main/java</source>
</sources>
</configuration>
</execution>
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.patrikdufresne.cbc4j</groupId>
......@@ -8,10 +9,10 @@
<artifactId>cbc4j-win-i686</artifactId>
<properties>
<compile.target>i686-w64-mingw32</compile.target>
<compile.ldflags>-static-libgcc -static-libstdc++</compile.ldflags>
<compile.ldflags>-static-libgcc -static-libstdc++</compile.ldflags>
<compile.cxxflags>-D__MINGW64__</compile.cxxflags>
<cbc4j.lib.name>cbc4j${cbc4j.version}.dll</cbc4j.lib.name>
<cbc4j.platform.dir>win/x86</cbc4j.platform.dir>
<cbc4j.lib.name>cbc4j${cbc4j.version}.dll</cbc4j.lib.name>
<cbc4j.platform.dir>win/x86</cbc4j.platform.dir>
</properties>
<build>
<plugins>
......@@ -27,50 +28,54 @@
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- Get the coin-cbc source -->
<get src="${cbc.url}" dest="${cbc.dir}.tgz" skipexisting="true" />
<untar src="${cbc.dir}.tgz" dest="${project.build.directory}" compression="gzip" />
<!-- Configure coin-cbc -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING COIN_CBC" />
<echo message="------------------------------------------------------------------------" />
<chmod dir="${cbc.dir}" perm="+x" includes="configure,**/install-sh" />
<exec executable="./configure" dir="${cbc.dir}" failonerror="true">
<env key="LDFLAGS" value="${compile.ldflags}" />
<env key="CXXFLAGS" value="${compile.cxxflags}" />
<arg value="--disable-shared" />
<arg value="--with-pic" />
<arg value="--target=${compile.target}" />
<arg value="--host=${compile.target}" />
</exec>
<!-- Compile coin-cbc -->
<exec executable="make" dir="${cbc.dir}" failonerror="true" />
<exec executable="make" dir="${cbc.dir}" failonerror="true">
<arg value="install" />
</exec>
<!-- Compile cbc4j -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING CBC4J" />
<echo message="------------------------------------------------------------------------" />
<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}/cbc4j" failonerror="true">
<env key="SWIG_OUTDIR" path="${swig.generated.sources}/${swig.package.dir}" />
<env key="SWIG_PACKAGE" value="${swig.package.name}" />
<env key="CBCDIR" path="${cbc.dir}" />
<env key="JAVADIR" path="/usr/lib/jvm/default-java" />
<env key="TARGET" value="${compile.target}" />
<env key="LDFLAGS" value="${compile.ldflags}" />
<env key="LIBCBC4J" value="${cbc4j.lib.name}" />
</exec>
<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>
<configuration>
<target>
<!-- Get the coin-cbc source -->
<get src="${cbc.url}" dest="${cbc.dir}.tgz" skipexisting="true" />
<untar src="${cbc.dir}.tgz" dest="${project.build.directory}" compression="gzip" />
<!-- Configure coin-cbc -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING COIN_CBC" />
<echo message="------------------------------------------------------------------------" />
<chmod dir="${cbc.dir}" perm="+x" includes="configure,**/install-sh" />
<exec executable="./configure" dir="${cbc.dir}" failonerror="true">
<env key="LDFLAGS" value="${compile.ldflags}" />
<env key="CXXFLAGS" value="${compile.cxxflags}" />
<arg value="--disable-shared" />
<arg value="--with-pic" />
<arg value="--target=${compile.target}" />
<arg value="--host=${compile.target}" />
</exec>
<!-- Compile coin-cbc -->
<exec executable="make" dir="${cbc.dir}" failonerror="true" />
<exec executable="make" dir="${cbc.dir}" failonerror="true">
<arg value="install" />
</exec>
<exec executable="bash" dir="${cbc.dir}" failonerror="true">
<arg value="-c" />
<arg value="for FILE in ${project.basedir}/../patches/*.diff; do patch -p1 &lt; $FILE; done" />
</exec>
<!-- Compile cbc4j -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING CBC4J" />
<echo message="------------------------------------------------------------------------" />
<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}/cbc4j" failonerror="true">
<env key="SWIG_OUTDIR" path="${swig.generated.sources}/${swig.package.dir}" />
<env key="SWIG_PACKAGE" value="${swig.package.name}" />
<env key="CBCDIR" path="${cbc.dir}" />
<env key="JAVADIR" path="/usr/lib/jvm/default-java" />
<env key="TARGET" value="${compile.target}" />
<env key="LDFLAGS" value="${compile.ldflags}" />
<env key="LIBCBC4J" value="${cbc4j.lib.name}" />
</exec>
<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>
</executions>
</plugin>
......@@ -89,7 +94,7 @@
<configuration>
<sources>
<source>${swig.generated.sources}</source>
<source>../src/main/java</source>
<source>../src/main/java</source>
</sources>
</configuration>
</execution>
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.patrikdufresne.cbc4j</groupId>
......@@ -8,10 +9,10 @@
<artifactId>cbc4j-win-x86_64</artifactId>
<properties>
<compile.target>x86_64-w64-mingw32</compile.target>
<compile.ldflags>-static-libgcc -static-libstdc++</compile.ldflags>
<compile.ldflags>-static-libgcc -static-libstdc++</compile.ldflags>
<compile.cxxflags />
<cbc4j.lib.name>cbc4j${cbc4j.version}.dll</cbc4j.lib.name>
<cbc4j.platform.dir>win/x86_64</cbc4j.platform.dir>
<cbc4j.lib.name>cbc4j${cbc4j.version}.dll</cbc4j.lib.name>
<cbc4j.platform.dir>win/x86_64</cbc4j.platform.dir>
</properties>
<build>
<plugins>
......@@ -27,50 +28,54 @@
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- Get the coin-cbc source -->
<get src="${cbc.url}" dest="${cbc.dir}.tgz" skipexisting="true" />
<untar src="${cbc.dir}.tgz" dest="${project.build.directory}" compression="gzip" />
<!-- Configure coin-cbc -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING COIN_CBC" />
<echo message="------------------------------------------------------------------------" />
<chmod dir="${cbc.dir}" perm="+x" includes="configure,**/install-sh" />
<exec executable="./configure" dir="${cbc.dir}" failonerror="true">
<env key="LDFLAGS" value="${compile.ldflags}" />
<env key="CXXFLAGS" value="${compile.cxxflags}" />
<arg value="--disable-shared" />
<arg value="--with-pic" />
<arg value="--target=${compile.target}" />
<arg value="--host=${compile.target}" />
</exec>
<!-- Compile coin-cbc -->
<exec executable="make" dir="${cbc.dir}" failonerror="true" />
<exec executable="make" dir="${cbc.dir}" failonerror="true">
<arg value="install" />
</exec>
<!-- Compile cbc4j -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING CBC4J" />
<echo message="------------------------------------------------------------------------" />
<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}/cbc4j" failonerror="true">
<env key="SWIG_OUTDIR" path="${swig.generated.sources}/${swig.package.dir}" />
<env key="SWIG_PACKAGE" value="${swig.package.name}" />
<env key="CBCDIR" path="${cbc.dir}" />
<env key="JAVADIR" path="/usr/lib/jvm/default-java" />
<env key="TARGET" value="${compile.target}" />
<env key="LDFLAGS" value="${compile.ldflags}" />
<env key="LIBCBC4J" value="${cbc4j.lib.name}" />
</exec>
<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>
<configuration>
<target>
<!-- Get the coin-cbc source -->
<get src="${cbc.url}" dest="${cbc.dir}.tgz" skipexisting="true" />
<untar src="${cbc.dir}.tgz" dest="${project.build.directory}" compression="gzip" />
<!-- Configure coin-cbc -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING COIN_CBC" />
<echo message="------------------------------------------------------------------------" />
<chmod dir="${cbc.dir}" perm="+x" includes="configure,**/install-sh" />
<exec executable="./configure" dir="${cbc.dir}" failonerror="true">
<env key="LDFLAGS" value="${compile.ldflags}" />
<env key="CXXFLAGS" value="${compile.cxxflags}" />
<arg value="--disable-shared" />
<arg value="--with-pic" />
<arg value="--target=${compile.target}" />
<arg value="--host=${compile.target}" />
</exec>
<!-- Compile coin-cbc -->
<exec executable="make" dir="${cbc.dir}" failonerror="true" />
<exec executable="make" dir="${cbc.dir}" failonerror="true">
<arg value="install" />
</exec>
<exec executable="bash" dir="${cbc.dir}" failonerror="true">
<arg value="-c" />
<arg value="for FILE in ${project.basedir}/../patches/*.diff; do patch -p1 &lt; $FILE; done" />
</exec>
<!-- Compile cbc4j -->
<echo message="------------------------------------------------------------------------" />
<echo message="COMPILING CBC4J" />
<echo message="------------------------------------------------------------------------" />
<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}/cbc4j" failonerror="true">
<env key="SWIG_OUTDIR" path="${swig.generated.sources}/${swig.package.dir}" />
<env key="SWIG_PACKAGE" value="${swig.package.name}" />
<env key="CBCDIR" path="${cbc.dir}" />
<env key="JAVADIR" path="/usr/lib/jvm/default-java" />
<env key="TARGET" value="${compile.target}" />
<env key="LDFLAGS" value="${compile.ldflags}" />
<env key="LIBCBC4J" value="${cbc4j.lib.name}" />
</exec>
<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>
</executions>
</plugin>
......@@ -89,7 +94,7 @@
<configuration>
<sources>
<source>${swig.generated.sources}</source>
<source>../src/main/java</source>
<source>../src/main/java</source>
</sources>
</configuration>
</execution>
......
--- a/Cbc/include/coin/CbcModel.hpp
+++ b/Cbc/include/coin/CbcModel.hpp
@@ -2346,10 +2346,10 @@
{
return master_;
}
+#ifdef CBC_THREAD
/// From here to end of section - code in CbcThread.cpp until class changed
/// Returns true if locked
bool isLocked() const;
-#ifdef CBC_THREAD
/**
Locks a thread if parallel so that stuff like cut pool
can be updated and/or used.
@@ -2359,12 +2359,6 @@
Unlocks a thread if parallel to say cut pool stuff not needed
*/
void unlockThread();
-#else
- inline void lockThread()
- {
- }
- inline void unlockThread() {}
-#endif
/** Set information in a child
-3 pass pointer to child thread info
-2 just stop
@@ -2389,7 +2383,7 @@
void mergeModels(int numberModel, CbcModel **model,
int numberNodes);
//@}
-
+#endif
///@name semi-private i.e. users should not use
//@{
/// Get how many Nodes it took to solve the problem.
@@ -2430,7 +2424,6 @@
bool &resolved, CoinWarmStartBasis *lastws,
const double *lowerBefore, const double *upperBefore,
OsiSolverBranch *&branches);
- int chooseBranch(CbcNode *newNode, int numberPassesLeft, bool &resolved);
/** Return an empty basis object of the specified size
@@ -2505,8 +2498,6 @@
void synchronizeNumberBeforeTrust(int type = 0);
/// Zap integer information in problem (may leave object info)
void zapIntegerInformation(bool leaveObjects = true);
- /// Use cliques for pseudocost information - return nonzero if infeasible
- int cliquePseudoCosts(int doStatistics);
/// Fill in useful estimates
void pseudoShadow(int type);
/** Return pseudo costs
@@ -3251,7 +3242,6 @@
// So we can call from other programs
// Real main program
class OsiClpSolverInterface;
-int CbcMain(int argc, const char *argv[], OsiClpSolverInterface &solver, CbcModel **babSolver);
int CbcMain(int argc, const char *argv[], CbcModel &babSolver);
// four ways of calling
int callCbc(const char *input2, OsiClpSolverInterface &solver1);
@@ -3264,12 +3254,8 @@
// two ways of calling
int callCbc(const char *input2, CbcModel &babSolver);
int callCbc(const std::string input2, CbcModel &babSolver);
-// And when CbcMain0 already called to initialize
-int callCbc1(const char *input2, CbcModel &babSolver);
-int callCbc1(const std::string input2, CbcModel &babSolver);
// And when CbcMain0 already called to initialize (with call back) (see CbcMain1 for whereFrom)
int callCbc1(const char *input2, CbcModel &babSolver, int(CbcModel *currentSolver, int whereFrom));
-int callCbc1(const std::string input2, CbcModel &babSolver, int(CbcModel *currentSolver, int whereFrom));
int CbcMain1(int argc, const char *argv[], CbcModel &babSolver, int(CbcModel *currentSolver, int whereFrom));
// For uniform setting of cut and heuristic options
void setCutAndHeuristicOptions(CbcModel &model);
--- a/Cbc/include/coin/OsiClpSolverInterface.hpp
+++ b/Cbc/include/coin/OsiClpSolverInterface.hpp
@@ -174,13 +174,9 @@
and can be queried by other methods.
*/
virtual void enableSimplexInterface(bool doingPrimal);
- /// Copy across enabled stuff from one solver to another
- void copyEnabledSuff(OsiClpSolverInterface &rhs);
/*! \brief Undo setting changes made by #enableSimplexInterface */
virtual void disableSimplexInterface();
- /// Copy across enabled stuff from one solver to another
- void copyEnabledStuff(ClpSimplex &rhs);
/** Perform a pivot by substituting a colIn for colOut in the basis.
The status of the leaving variable is given in statOut. Where
@@ -340,16 +336,6 @@
void stopFastDual();
/// Sets integer tolerance and increment
void setStuff(double tolerance, double increment);
- /// Return a conflict analysis cut from small model
- OsiRowCut *smallModelCut(const double *originalLower, const double *originalUpper,
- int numberRowsAtContinuous, const int *whichGenerator,
- int typeCut = 0);
- /** Return a conflict analysis cut from model
- If type is 0 then genuine cut, if 1 then only partially processed
- */
- OsiRowCut *modelCut(const double *originalLower, const double *originalUpper,
- int numberRowsAtContinuous, const int *whichGenerator,
- int typeCut = 0);
//@}
//---------------------------------------------------------------------------
@@ -972,7 +958,6 @@
/// This loads a model from a coinModel object - returns number of errors
virtual int loadFromCoinModel(CoinModel &modelObject, bool keepSolution = false);
- using OsiSolverInterface::readMps;
/** Read an mps file from the given filename (defaults to Osi reader) - returns
number of errors (see OsiMpsReader class) */
virtual int readMps(const char *filename,
......@@ -28,7 +28,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cbc4j.version>11</cbc4j.version>
<!-- Define the version of cbc dependency -->
<cbc.version>2.8.3</cbc.version>
<cbc.version>2.10.3</cbc.version>
<!-- Define location of the source -->
<cbc.url>http://www.coin-or.org/download/source/Cbc/Cbc-${cbc.version}.tgz</cbc.url>
<cbc.dir>${project.build.directory}/Cbc-${cbc.version}</cbc.dir>
......
// Copyright (C) 2005, International Business Machines
// Corporation and others. All Rights Reserved.
#if defined(_MSC_VER)
// Turn off compiler warning about long names
# pragma warning(disable:4786)
#endif
#include <cassert>
#include <iomanip>
#include <string>
using namespace std;
// For Branch and bound
#include "CbcModel.hpp"
#include "CbcStrategy.hpp"
#include "OsiClpSolverInterface.hpp"
#include "CoinTime.hpp"
#include "cbc4j.hpp"
#include "CoinPackedMatrix.hpp"
#include "CbcHeuristicFPump.hpp"
// Included for solver
#include "CbcOrClpParam.hpp"
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.
osi.addCol(numberElements,rows,elements,collb,colub,obj);
}
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.
osi.addRow(numberElements,columns,element,rowlb,rowub);
}
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();
}
void callCbc0 (CbcModel &m) {
CbcMain0(m);
std::cout.flush();
}
int callCbc1 (int argc, const char* argv[], CbcModel &m) {
int val = CbcMain1(argc, argv, m);
std::cout.flush();
return val;
}
void deleteCbcModel(CbcModel* c) {
delete c;
}
// Remove a set of columns (primal variables) from the problem.
void deleteCols(OsiClpSolverInterface& osi, const int num, const int* colIndices){
osi.deleteCols(num,colIndices);
}
void deleteOsiClpSolverInterface(OsiClpSolverInterface* solver) {
delete solver;
}
// Delete a set of rows (constraints) from the problem.
void deleteRows(OsiClpSolverInterface& osi, const int num, const int* rowIndices){
osi.deleteRows(num,rowIndices);
}
double getCbcColSolution(CbcModel& c, int colIndex){
return c.getCbcColSolution()[colIndex];
}
double getCbcRowLower(CbcModel& c, int rowIndex){
return c.getCbcRowLower()[rowIndex];
}
double getCbcRowUpper(CbcModel& c, int rowIndex){
return c.getCbcRowUpper()[rowIndex];
}
double getCoefficient(OsiClpSolverInterface &osi, int row, int col) {
return osi.getMatrixByCol()->getCoefficient(row, col);
}
double getColLower(CbcModel& c, int colIndex){
return c.getColLower()[colIndex];
}
// Get pointer to array[getNumCols(OsiClpSolverInterface& osi)] of column lower bounds.
double getColLower(OsiClpSolverInterface& osi, int colIndex){
return osi.getColLower()[colIndex];
}
// Return name of column if one exists or Cnnnnnnn maxLen is currently ignored and only there to match the signature from the base class!
std::string getColName(OsiClpSolverInterface& osi, int colIndex, unsigned maxLen){
return osi.getColName(colIndex,maxLen);
}
// Get pointer to array[getNumCols()] of primal solution vector.
double getColSolution(OsiClpSolverInterface& osi, int colIndex){
return osi.getColSolution()[colIndex];
}
double getColSolution(OsiSolverInterface& osi, int colIndex){
return osi.getColSolution()[colIndex];
}
double getColUpper(CbcModel& c, int colIndex){
return c.getColUpper()[colIndex];
}
// Get pointer to array[getNumCols(OsiClpSolverInterface& osi)] of column upper bounds.
double getColUpper(OsiClpSolverInterface& osi, int colIndex){
return osi.getColUpper()[colIndex];
}
double getInfinity(CbcModel& c){
return c.getInfinity();
}
// Get solver's value for infinity.
double getInfinity(OsiClpSolverInterface& osi){
return osi.getInfinity();
}
int getNumCols(CbcModel& c){
return c.getNumCols();
}
// Get number of columns.
int getNumCols(OsiClpSolverInterface& osi){
return osi.getNumCols();
}
int getNumRows(CbcModel& c){
return c.getNumRows();
}
// Get number of rows.
int getNumRows(OsiClpSolverInterface& osi){
return osi.getNumRows();
}
double getObjCoefficients(CbcModel& c, int colIndex){
return c.getObjCoefficients()[colIndex];
}
// Get pointer to array[getNumCols(OsiClpSolverInterface& osi)] of objective function coefficients.
double getObjCoefficients(OsiClpSolverInterface& osi, int colIndex){
return osi.getObjCoefficients()[colIndex];
}
double getObjSense(CbcModel& c){
return c.getObjSense();
}
// Get objective function sense (1 for min (default), -1 for max).
double getObjSense(OsiClpSolverInterface& osi){
return osi.getObjSense();
}
double getObjValue(CbcModel& c){
return c.getObjValue();
}
// Get objective function value.
double getObjValue(OsiClpSolverInterface& osi){
return osi.getObjValue();
}
double getObjValue(OsiSolverInterface& c) {
return c.getObjValue();
}
double getRowLower(CbcModel& c, int rowIndex){
return c.getRowLower()[rowIndex];
}
// Get pointer to array[getNumRows(OsiClpSolverInterface& osi)] of row lower bounds.
double getRowLower(OsiClpSolverInterface& osi, int rowIndex){
return osi.getRowLower()[rowIndex];
}
// Return name of row if one exists or Rnnnnnnn maxLen is currently ignored and only there to match the signature from the base class!
std::string getRowName(OsiClpSolverInterface& osi, int rowIndex, unsigned maxLen){
return osi.getRowName(rowIndex,maxLen);
}
double getRowUpper(CbcModel& c, int rowIndex){
return c.getRowUpper()[rowIndex];
}
// Get pointer to array[getNumRows(OsiClpSolverInterface& osi)] of row upper bounds.
double getRowUpper(OsiClpSolverInterface& osi, int rowIndex){
return osi.getRowUpper()[rowIndex];
}
void initialSolve(CbcModel& c) {
c.initialSolve();
}
void initialSolve(OsiClpSolverInterface& solver){
solver.initialSolve();
std::cout.flush();
}
bool isBinary(CbcModel& c, int colIndex){
return c.isBinary(colIndex);
}
// Return true if variable is binary.
bool isBinary(OsiClpSolverInterface& osi, int colIndex){
return osi.isBinary(colIndex);
}
bool isContinuous(CbcModel& c, int colIndex){
return c.isContinuous(colIndex);
}
// Return true if column is continuous.
bool isContinuous(OsiClpSolverInterface& osi, int colNumber){
return osi.isContinuous(colNumber);
}
bool isInteger(CbcModel& c, int colIndex){
return c.isInteger(colIndex);
}
// Return true if column is integer.
bool isInteger(OsiClpSolverInterface& osi, int colIndex){
return osi.isInteger(colIndex);
}
bool isProvenInfeasible(CbcModel& c){
return c.isProvenInfeasible();
}
// Create a new instance of CbcModel
CbcModel* newCbcModel(OsiClpSolverInterface& s){
return new CbcModel(s);
}
// Default Constructor.
bool isProvenOptimal(CbcModel& c){
return c.isProvenOptimal();
}
//Is optimality proven?
bool isProvenOptimal(OsiClpSolverInterface& osi){
return osi.isProvenOptimal();
}
void modifyCoefficient(OsiClpSolverInterface& osi, int row, int column, double newElement, bool keepZero){
osi.modifyCoefficient(row,column,newElement,keepZero);
}
OsiClpSolverInterface* newOsiClpSolverInterface(){
return new OsiClpSolverInterface();
}
// Read file in LP format (with names).
int readLp(OsiClpSolverInterface& osi, const char* filename, const double epsilon){
osi.readLp(filename,epsilon);
}
//Integrality related changing methods
void resolve(OsiSolverInterface& osi) {
osi.resolve();
}
// Returns solver - has current state.
OsiClpSolverInterface* solver(CbcModel& m) {
OsiSolverInterface* solver = m.solver();
return dynamic_cast<OsiClpSolverInterface*>(solver);
}
void setCoefficients(OsiClpSolverInterface &osi, int row, int numberElements, const int* cols, const double* coefs) {
int colCount = osi.getNumCols();
for(int col=0;col<colCount;col++) {
osi.modifyCoefficient(row, col, 0.0, false);
}
for(int col=0;col<numberElements;col++) {
osi.modifyCoefficient(row, cols[col], coefs[col], false);
}
}
// Set a single column lower and upper bound.
void setColBounds(OsiClpSolverInterface& osi, int elementIndex, double lower, double upper){
osi.setColBounds(elementIndex,lower,upper);
}
// Set a single column lower bound, Use -DBL_MAX for -infinity.
void setColLower(OsiClpSolverInterface& osi, int elementIndex, double elementValue){
osi.setColLower(elementIndex,elementValue);
}
// Set name of column.
void setColName(OsiClpSolverInterface& osi, int colIndex, std::string name){
osi.setColName(colIndex,name);
}
// Set a single column upper bound, Use DBL_MAX for infinity.
void setColUpper(OsiClpSolverInterface& osi, int elementIndex, double elementValue){
osi.setColUpper(elementIndex,elementValue);
}
// Set the index-th variable to be a continuous variable.
void setContinuous(OsiClpSolverInterface& osi, int index){
osi.setContinuous(index);
}
// Set the index-th variable to be an integer variable.
void setInteger(OsiClpSolverInterface& osi, int index){
osi.setInteger(index);
}
void setLogLevel(CbcModel& c, int n){
c.setLogLevel(n);
}
// Resolve an LP relaxation after problem modification.
void setLogLevel(OsiClpSolverInterface& s, int n) {
s.messageHandler()->setLogLevel(n);
}
// Get pointer to array[getNumCols()] of objective function coefficients.
const double* getObjCoefficients(OsiClpSolverInterface& osi) {
return osi.getObjCoefficients();
}
// Set an objective function setObjCoeff.
void setObjCoeff(OsiClpSolverInterface& osi, int elementIndex, double elementValue){
osi.setObjCoeff(elementIndex,elementValue);
}
// Sets the objective coefficient
void setObjCoefficients(OsiClpSolverInterface &osi, int numberElements, const int* cols, const double* coefs) {
int colCount = osi.getNumCols();
for(int col=0;col<colCount;col++) {
osi.setObjCoeff(col, 0);
}
for(int col=0;col<numberElements;col++) {
osi.setObjCoeff(cols[col], coefs[col]);
}
}
// Set the objective coefficients for all columns array [getNumCols()] is an array of values for the objective.
void setObjective(OsiClpSolverInterface& osi, const double* array){
osi.setObjective(array);
}
// Return the coefficient.
void setObjSense(CbcModel& c, double s){
c.setObjSense(s);
}
// Run the solver using CbcMain1
void setObjSense(OsiClpSolverInterface& osi, double s){
osi.setObjSense(s);
}
// Set a single row lower bound, Use -DBL_MAX for -infinity.
void setRowLower(OsiClpSolverInterface& osi, int elementIndex, double elementValue){
osi.setRowLower(elementIndex,elementValue);
}
// Set name of row.
void setRowName(OsiClpSolverInterface& osi, int rowIndex, std::string name){
osi.setRowName(rowIndex,name);
}
// Set a single row upper bound, Use DBL_MAX for infinity.
void setRowUpper(OsiClpSolverInterface& osi, int elementIndex, double elementValue){
osi.setRowUpper(elementIndex,elementValue);
}
int status(CbcModel& c) {
return c.status();
}
void writeLp(OsiClpSolverInterface& osi, const char* filename, const char* extension, double epsilon, int numberAcross, int decimals, double objSense, bool useRowNames){// Write the problem into an Lp file of the given filename.
osi.writeLp(filename,extension,epsilon,numberAcross,decimals,objSense,useRowNames);
}
#ifndef CBC4J_H
#define CBC4J_H
#include <cassert>
#include <iomanip>
#include <string>
using namespace std;
#include "CbcModel.hpp"
#include "CbcStrategy.hpp"
#include "OsiClpSolverInterface.hpp"
#include "CoinTime.hpp"
#include "CbcHeuristicFPump.hpp"
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);
void deleteCbcModel(CbcModel* c);
void deleteCols(OsiClpSolverInterface& osi, const int num, const int *colIndices);
void deleteRows(OsiClpSolverInterface& osi, const int num, const int *rowIndices);
void deleteOsiClpSolverInterface(OsiClpSolverInterface* solver);
double getCbcColSolution(CbcModel& c, int colIndex);
double getCbcRowLower(CbcModel& c, int rowIndex);
double getCbcRowUpper(CbcModel& c, int rowIndex);
double getCoefficient(OsiClpSolverInterface& osi, int row, int col);
double getColLower(CbcModel& c, int colIndex);
double getColLower(OsiClpSolverInterface& osi, int elementIndex);
std::string getColName(OsiClpSolverInterface& osi, int colIndex, unsigned maxLen=std::string::npos);
double getColSolution(OsiClpSolverInterface& osi, int colIndex);
double getColSolution(OsiSolverInterface& osi, int colIndex);
double getColUpper(CbcModel& c, int colIndex);
double getColUpper(OsiClpSolverInterface& osi, int elementIndex);
double getInfinity(CbcModel& c);
double getInfinity(OsiClpSolverInterface& osi);
double getObjCoefficients(CbcModel& c, int colIndex);
double getObjSense(CbcModel& c);
int getNumCols(CbcModel& c);
int getNumCols(OsiClpSolverInterface& osi);
int getNumRows(CbcModel& c);
int getNumRows(OsiClpSolverInterface& osi);
double getObjCoefficients(OsiClpSolverInterface& osi, int elementIndex);
const double* getObjCoefficients(OsiClpSolverInterface& osi);
double getObjValue(CbcModel& c);
double getObjValue(OsiClpSolverInterface& osi);
double getObjValue(OsiSolverInterface& c);
double getObjSense(OsiClpSolverInterface& osi);
double getRowLower(CbcModel& c, int rowIndex);
double getRowLower(OsiClpSolverInterface& osi, int rowIndex);
std::string getRowName(OsiClpSolverInterface& osi, int rowIndex, unsigned maxLen=std::string::npos);
double getRowUpper(CbcModel& c, int rowIndex);
double getRowUpper(OsiClpSolverInterface& osi, int rowIndex);
void initialSolve(CbcModel& c);
void initialSolve(OsiClpSolverInterface& solver);
bool isBinary(CbcModel& c, int colIndex);
bool isBinary(OsiClpSolverInterface& osi, int colIndex);
bool isContinuous(CbcModel& c, int colIndex);
bool isContinuous(OsiClpSolverInterface& osi, int colNumber);
bool isInteger(CbcModel& c, int colIndex);
bool isInteger(OsiClpSolverInterface& osi, int colIndex);
bool isProvenOptimal(CbcModel& c);
bool isProvenOptimal(OsiClpSolverInterface& osi);
bool isProvenInfeasible(CbcModel& c);
CbcModel* newCbcModel(OsiClpSolverInterface& s);
OsiClpSolverInterface* newOsiClpSolverInterface();
void modifyCoefficient(OsiClpSolverInterface& osi, int row, int column, double newElement, bool keepZero=false);
int readLp(OsiClpSolverInterface& osi, const char *filename, const double epsilon=1e-5);
void resolve(OsiSolverInterface& osi);
void setCoefficients(OsiClpSolverInterface& osi, int row, int numberElements, const int *cols, const double *coefs);
void setColBounds(OsiClpSolverInterface& osi, int elementIndex, double lower, double upper);
void setColLower(OsiClpSolverInterface& osi, int elementIndex, double elementValue);
void setColName(OsiClpSolverInterface& osi, int colIndex, std::string name);
void setColUpper(OsiClpSolverInterface& osi, int elementIndex, double elementValue);
void setContinuous(OsiClpSolverInterface& osi, int index);
void setInteger(OsiClpSolverInterface& osi, int index);
void setLogLevel(CbcModel& c, int n);
void setLogLevel(OsiClpSolverInterface& s, int n);
void setObjective(OsiClpSolverInterface& osi, const double *array);
void setObjCoeff(OsiClpSolverInterface& osi, int elementIndex, double elementValue);
void setObjCoefficients(OsiClpSolverInterface& osi, int numberElements, const int *rows, const double *coefs);
void setObjSense(CbcModel& c, double s);
void setObjSense(OsiClpSolverInterface& osi, double s);
void setRowLower(OsiClpSolverInterface& osi, int elementIndex, double elementValue);
void setRowName(OsiClpSolverInterface& osi, int rowIndex, std::string name);
void setRowUpper(OsiClpSolverInterface& osi, int elementIndex, double elementValue);
OsiClpSolverInterface* solver(CbcModel& m);
int status(CbcModel& c);
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);
#endif