Skip to content

Commit

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

* Update build.yml

* Update build.yml

* Try fixing macos build

* Try fixing MacOS pipeline

* Update build.yml
  • Loading branch information
fontanf authored Apr 21, 2024
1 parent 790759c commit fe39808
Show file tree
Hide file tree
Showing 145 changed files with 3,321 additions and 881 deletions.
7 changes: 0 additions & 7 deletions .bazelrc

This file was deleted.

44 changes: 29 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,29 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Build Linux
run: bazel build --define clp=true -- //...
if: matrix.os != 'windows-latest'
- name: Build Windows
run: bazel build --define clp=true --cxxopt=/MT -- //...
if: matrix.os == 'windows-latest'
- name: Copy CLP libraries (Darwin)
- name: Build
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel
cmake --install build --config Release --prefix install
if: matrix.os != 'macos-latest'
- name: Build (MacOS)
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DPackingSolver_BUILD_TEST=OFF
cmake --build build --config Release --parallel
mkdir -p "/Users/runner/work/Osi/Osi/dist/lib"
cp -rf "${GITHUB_WORKSPACE}/bazel-packingsolver/external/osi_darwin/lib/" "/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}/bazel-packingsolver/external/coinutils_darwin/lib/" "/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}/bazel-packingsolver/external/clp_darwin/lib/" "/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"
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DPackingSolver_BUILD_TEST=ON
cmake --build build --config Release --parallel
cmake --install build --config Release --prefix install
if: matrix.os == 'macos-latest'
- name: Run unit tests
run: bazel test --define clp=true -- //...
if: matrix.os != 'windows-latest'
working-directory: build/test
run: ctest --parallel
- name: Run tests
run: python3 -u scripts/run_tests.py test_results
- name: Checkout main branch
Expand All @@ -47,12 +52,21 @@ jobs:
git fetch --depth 1
git checkout master
- name: Build Linux
run: bazel build --define clp=true -- //...
run: bazel build --define clp=true -- //packingsolver/...
if: matrix.os != 'windows-latest'
- name: Build Windows
run: bazel build --define clp=true --cxxopt=/MT -- //...
run: bazel build --define clp=true --cxxopt=/MT -- //packingsolver/...
if: matrix.os == 'windows-latest'
- name: Copy CLP libraries (Darwin)
run: |
mkdir -p "/Users/runner/work/Osi/Osi/dist/lib"
cp -rf "${GITHUB_WORKSPACE}/bazel-packingsolver/external/osi_darwin/lib/" "/Users/runner/work/Osi/Osi/dist/lib"
mkdir -p "/Users/runner/work/CoinUtils/CoinUtils/dist/lib"
cp -rf "${GITHUB_WORKSPACE}/bazel-packingsolver/external/coinutils_darwin/lib/" "/Users/runner/work/CoinUtils/CoinUtils/dist/lib"
mkdir -p "/Users/runner/work/Clp/Clp/dist/lib"
cp -rf "${GITHUB_WORKSPACE}/bazel-packingsolver/external/clp_darwin/lib/" "/Users/runner/work/Clp/Clp/dist/lib"
if: matrix.os == 'macos-latest'
- name: Run tests
run: python3 -u scripts/run_tests.py test_results_ref
- name: Process tests
run: python3 -u ./bazel-packingsolver/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
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.15.0)

project(PackingSolver LANGUAGES CXX)

option(PackingSolver_BUILD_TEST "Build the unit tests" ON)
option(PackingSolver_USE_KNITRO "Use Knitro" 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)
if(PackingSolver_BUILD_TEST)
add_subdirectory(test)
endif()
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,19 @@ Features:

Compile:
```shell
bazel build -- //...
# Or, to enable the column generation algorithm on Linux:
bazel build --define clp=true -- //...
# Or, to enable the column generation algorithm on Windows:
bazel build --define clp=true --cxxopt=/MT -- //...
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel
cmake --install build --config Release --prefix install
```

Execute:
```shell
./bazel-bin/packingsolver/rectangleguillotine/main --verbosity-level 1 --objective knapsack --predefined 3NHO --items data/rectangle/alvarez2002/ATP35_items.csv --bins data/rectangle/alvarez2002/ATP35_bins.csv --certificate ATP35_solution.csv --output ATP35_output.json --time-limit 1
./install/bin/packingsolver_rectangleguillotine --verbosity-level 1 --objective knapsack --predefined 3NHO --items data/rectangle/alvarez2002/ATP35_items.csv --bins data/rectangle/alvarez2002/ATP35_bins.csv --certificate ATP35_solution.csv --output ATP35_output.json --time-limit 1
```

Or in short:
```shell
./bazel-bin/packingsolver/rectangleguillotine/main -v 1 -f KP -p 3NHO -i data/rectangle/alvarez2002/ATP35 -c ATP35_solution.csv -o ATP35_output.json -t 1
./install/bin/packingsolver_rectangleguillotine -v 1 -f KP -p 3NHO -i data/rectangle/alvarez2002/ATP35 -c ATP35_solution.csv -o ATP35_output.json -t 1
```
```
===================================
Expand Down
Loading

0 comments on commit fe39808

Please sign in to comment.