Skip to content

Commit

Permalink
Feature/switch to cmake (#6)
Browse files Browse the repository at this point in the history
* Switch to CMake

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml
  • Loading branch information
fontanf authored Apr 27, 2024
1 parent 1086eea commit 4f8ae02
Show file tree
Hide file tree
Showing 37 changed files with 189 additions and 455 deletions.
10 changes: 0 additions & 10 deletions .bazelrc

This file was deleted.

29 changes: 25 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ jobs:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest, windows-latest, macos-13]
python-version: ["3.8"]

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

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -24,8 +28,25 @@ jobs:
run: |
python3 -m pip install gdown
python3 scripts/download_data.py
- name: Install nauty
run: sudo apt-get install -y libnauty2-dev
if: matrix.os == 'ubuntu-latest'
- 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: Copy CLP libraries (Darwin)
run: |
mkdir -p "/Users/runner/work/Osi/Osi/dist/lib"
cp -rf "${GITHUB_WORKSPACE}/build/_deps/mathoptsolverscmake-build/extern/Osi-prefix/src/Osi/lib/" "/Users/runner/work/Osi/Osi/dist/lib"
mkdir -p "/Users/runner/work/CoinUtils/CoinUtils/dist/lib"
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"
mkdir -p "/Users/runner/work/Cbc/Cbc/dist/lib"
cp -rf "${GITHUB_WORKSPACE}/build/_deps/mathoptsolverscmake-build/extern/Cbc-prefix/src/Cbc/lib/" "/Users/runner/work/Cbc/Cbc/dist/lib"
if: matrix.os == 'macos-13'
- name: Run tests
run: python3 -u scripts/run_tests.py test_results
- name: Checkout main branch
Expand All @@ -34,8 +55,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.

Loading

0 comments on commit 4f8ae02

Please sign in to comment.