Skip to content

Commit

Permalink
Update mathoptsolverscmake dependency
Browse files Browse the repository at this point in the history
* Update mathoptsolverscmake dependency

* Update build.yml

* Fix CMake files

* Fix CMake files
  • Loading branch information
fontanf authored Apr 27, 2024
1 parent 32561f1 commit d54fb37
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest, windows-latest, macos-13]
python-version: ["3.8"]

env:
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
cp -rf "${GITHUB_WORKSPACE}/build/_deps/mathoptsolverscmake-build/extern/CoinUtils-prefix/src/CoinUtils/lib/" "/Users/runner/work/CoinUtils/CoinUtils/dist/lib"
mkdir -p "/Users/runner/work/Clp/Clp/dist/lib"
cp -rf "${GITHUB_WORKSPACE}/build/_deps/mathoptsolverscmake-build/extern/Clp-prefix/src/Clp/lib/" "/Users/runner/work/Clp/Clp/dist/lib"
if: matrix.os == 'macos-latest'
if: matrix.os == 'macos-13'
- name: Run tests
run: python3 -u scripts/run_tests.py test_results
- name: Checkout main branch
Expand All @@ -66,7 +66,7 @@ jobs:
cp -rf "${GITHUB_WORKSPACE}/build/_deps/mathoptsolverscmake-build/extern/CoinUtils-prefix/src/CoinUtils/lib/" "/Users/runner/work/CoinUtils/CoinUtils/dist/lib"
mkdir -p "/Users/runner/work/Clp/Clp/dist/lib"
cp -rf "${GITHUB_WORKSPACE}/build/_deps/mathoptsolverscmake-build/extern/Clp-prefix/src/Clp/lib/" "/Users/runner/work/Clp/Clp/dist/lib"
if: matrix.os == 'macos-latest'
if: matrix.os == 'macos-13'
- name: Run tests
run: python3 -u scripts/run_tests.py test_results_ref
- name: Process tests
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.15.0)

project(ColumnGenerationSolver LANGUAGES CXX)

option(COLUMNGENERATIONSOLVER_USE_CLP "Use CLP" ON)
option(COLUMNGENERATIONSOLVER_USE_CPLEX "Use CPLEX" OFF)
option(COLUMNGENERATIONSOLVER_USE_XPRESS "Use Xpress" OFF)

# Require C++14.
set(CMAKE_CXX_STANDARD 14)

Expand Down
11 changes: 10 additions & 1 deletion extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,19 @@ FetchContent_Declare(
FetchContent_MakeAvailable(Boost)

# Fetch fontanf/mathoptsolverscmake.
if(COLUMNGENERATIONSOLVER_USE_CLP)
set(MATHOPTSOLVERSCMAKE_USE_CLP ON)
endif()
if(COLUMNGENERATIONSOLVER_USE_CPLEX)
set(MATHOPTSOLVERSCMAKE_USE_CPLEX ON)
endif()
if(COLUMNGENERATIONSOLVER_USE_XPRESS)
set(MATHOPTSOLVERSCMAKE_USE_XPRESS ON)
endif()
FetchContent_Declare(
mathoptsolverscmake
GIT_REPOSITORY https://github.com/fontanf/mathoptsolverscmake.git
GIT_TAG c5160bd6ad88a1ed136d49cee9265b209d6a2795)
GIT_TAG 56190725f424249a3acd8fce3ff50e08fe675cc6)
#SOURCE_DIR "${PROJECT_SOURCE_DIR}/../mathoptsolverscmake/")
FetchContent_MakeAvailable(mathoptsolverscmake)

Expand Down
6 changes: 6 additions & 0 deletions include/columngenerationsolver/linear_programming_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

#include "columngenerationsolver/commons.hpp"

#if CLP_FOUND
#include <coin/ClpModel.hpp>
#include <coin/CbcOrClpParam.hpp>
#include <coin/OsiClpSolverInterface.hpp>
#endif

#if CPLEX_FOUND
#include <ilcplex/ilocplex.h>
Expand Down Expand Up @@ -96,6 +98,8 @@ class ColumnGenerationSolver
virtual Value primal(ColIdx col) const = 0;
};

#if CLP_FOUND

class ColumnGenerationSolverClp: public ColumnGenerationSolver
{

Expand Down Expand Up @@ -158,6 +162,8 @@ class ColumnGenerationSolverClp: public ColumnGenerationSolver

};

#endif

#if CPLEX_FOUND

ILOSTLBEGIN
Expand Down
21 changes: 19 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,25 @@ target_include_directories(ColumnGenerationSolver_columngenerationsolver PUBLIC
${PROJECT_SOURCE_DIR}/include)
target_link_libraries(ColumnGenerationSolver_columngenerationsolver PUBLIC
OptimizationTools::containers
OptimizationTools::utils
MathOptSolversCMake::clp)
OptimizationTools::utils)
if(COLUMNGENERATIONSOLVER_USE_CLP)
target_compile_definitions(ColumnGenerationSolver_columngenerationsolver PUBLIC
CLP_FOUND=1)
target_link_libraries(ColumnGenerationSolver_columngenerationsolver PUBLIC
MathOptSolversCMake::clp)
endif()
if(COLUMNGENERATIONSOLVER_USE_XPRESS)
target_compile_definitions(ColumnGenerationSolver_columngenerationsolver PUBLIC
XPRESS_FOUND=1)
target_link_libraries(ColumnGenerationSolver_columngenerationsolver PUBLIC
MathOptSolversCMake::xpress)
endif()
if(COLUMNGENERATIONSOLVER_USE_CPLEX)
target_compile_definitions(ColumnGenerationSolver_columngenerationsolver PUBLIC
CPLEX_FOUND=1)
target_link_libraries(ColumnGenerationSolver_columngenerationsolver PUBLIC
MathOptSolversCMake::cplex)
endif()
add_library(ColumnGenerationSolver::columngenerationsolver ALIAS ColumnGenerationSolver_columngenerationsolver)
set_target_properties(ColumnGenerationSolver_columngenerationsolver PROPERTIES OUTPUT_NAME "columngenerationsolver")
install(TARGETS ColumnGenerationSolver_columngenerationsolver)
Expand Down

0 comments on commit d54fb37

Please sign in to comment.