Skip to content

Commit

Permalink
Switch to CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
fontanf committed Apr 27, 2024
1 parent 09acfad commit 9f8fe4b
Show file tree
Hide file tree
Showing 37 changed files with 173 additions and 454 deletions.
10 changes: 0 additions & 10 deletions .bazelrc

This file was deleted.

12 changes: 9 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8"]

env:
SET_COVERING_DATA: ${{ github.workspace }}/data/

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -25,7 +28,10 @@ jobs:
python3 -m pip install gdown
python3 scripts/download_data.py
- name: Build
run: bazel build -- //...
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel
cmake --install build --config Release --prefix install
- name: Run tests
run: python3 -u scripts/run_tests.py test_results
- name: Checkout main branch
Expand All @@ -34,8 +40,8 @@ jobs:
git fetch --depth 1
git checkout master
- name: Build
run: bazel build -- //...
run: bazel build -- //setcoveringsolver/...
- name: Run tests
run: python3 -u scripts/run_tests.py test_results_ref
- name: Process tests
run: python3 ./bazel-setcoveringsolver/external/optimizationtools/scripts/process_tests.py --ref test_results_ref --new test_results
run: python3 -u ./build/_deps/optimizationtools-src/scripts/process_tests.py --ref test_results_ref --new test_results
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.15.0)

project(SetCoveringSolver LANGUAGES CXX)

option(SETCOVERINGSOLVER_USE_CBC "Use CPLEX" ON)
option(SETCOVERINGSOLVER_USE_GUROBI "Use Gurobi" OFF)

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

# Enable output of compile commands during generation.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Set MSVC_RUNTIME_LIBRARY.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

# Add sub-directories.
add_subdirectory(extern)
add_subdirectory(src)
add_subdirectory(test)
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ In the set packing problem solved, elements may be covered multiple times and th

Compile:
```shell
bazel build -- //...

# To use algorithm "milp_cbc":
bazel build --define coinor=true -- //...

# To use algorithm "milp_gurobi":
bazel build --define gurobi=true -- //...
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel
cmake --install build --config Release --prefix install
```

Download data:
Expand All @@ -50,7 +46,7 @@ python3 scripts/download_data.py --data gecco2020
Run:

```shell
./bazel-bin/setcoveringsolver/main -v 1 -i data/wedelin1995/sasd9imp2.dat -f wedelin1995 -a milp-cbc
./install/bin/setcoveringsolver -v 1 -i data/wedelin1995/sasd9imp2.dat -f wedelin1995 -a milp-cbc
```
```
=====================================
Expand Down Expand Up @@ -130,7 +126,7 @@ Cost: 5262040
```

```shell
./bazel-bin/setcoveringsolver/main -v 1 -i data/beasley1990/scpnrh5.txt -f orlibrary -a large-neighborhood-search -t 0.3
./install/bin/setcoveringsolver -v 1 -i data/beasley1990/scpnrh5.txt -f orlibrary -a large-neighborhood-search -t 0.3
```
```
=====================================
Expand Down Expand Up @@ -212,7 +208,7 @@ Cost: 55
```

```shell
./bazel-bin/setcoveringsolver/main -v 1 -i data/faster1994/rail582.txt -f faster --unicost -a local-search-row-weighting-1 -c solution.txt -t 2
./install/bin/setcoveringsolver -v 1 -i data/faster1994/rail582.txt -f faster --unicost -a local-search-row-weighting-1 -c solution.txt -t 2
```
```
=====================================
Expand Down Expand Up @@ -312,7 +308,7 @@ Cost: 130
```

```shell
./bazel-bin/setcoveringsolver/main -v 1 -i data/gecco2020/AC_15_cover.txt -f gecco2020 --unicost -a local-search-row-weighting-2 -t 10 -c solution.txt
./install/bin/setcoveringsolver -v 1 -i data/gecco2020/AC_15_cover.txt -f gecco2020 --unicost -a local-search-row-weighting-2 -t 10 -c solution.txt
```
```
=====================================
Expand Down
237 changes: 0 additions & 237 deletions WORKSPACE

This file was deleted.

36 changes: 36 additions & 0 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Enable FetchContent.
include(FetchContent)

# Fetch boost.
set(BOOST_INCLUDE_LIBRARIES thread filesystem system program_options)
set(BOOST_ENABLE_CMAKE ON)
include(FetchContent)
FetchContent_Declare(
Boost
GIT_REPOSITORY https://github.com/boostorg/boost.git
GIT_TAG boost-1.84.0
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(Boost)

# Fetch fontanf/optimizationtools.
FetchContent_Declare(
optimizationtools
GIT_REPOSITORY https://github.com/fontanf/optimizationtools.git
GIT_TAG 33a3966ece149d390ec7ce08699669b5267e64aa)
#SOURCE_DIR "${PROJECT_SOURCE_DIR}/../optimizationtools/")
FetchContent_MakeAvailable(optimizationtools)

# Fetch fontanf/mathoptsolverscmake.
if(SETCOVERINGSOLVER_USE_CBC)
set(MATHOPTSOLVERSCMAKE_USE_CBC ON)
endif()
if(SETCOVERINGSOLVER_USE_GUROBI)
set(MATHOPTSOLVERSCMAKE_USE_GUROBI ON)
endif()
FetchContent_Declare(
mathoptsolverscmake
GIT_REPOSITORY https://github.com/fontanf/mathoptsolverscmake.git
GIT_TAG 56190725f424249a3acd8fce3ff50e08fe675cc6)
#SOURCE_DIR "${PROJECT_SOURCE_DIR}/../mathoptsolverscmake/")
FetchContent_MakeAvailable(mathoptsolverscmake)
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 9f8fe4b

Please sign in to comment.