Skip to content

Commit

Permalink
Merge pull request #3 from fontanf/feature/switch-to-cmake
Browse files Browse the repository at this point in the history
Feature/switch to cmake
  • Loading branch information
fontanf authored Apr 20, 2024
2 parents e073070 + 77f61d3 commit 0d5c23a
Show file tree
Hide file tree
Showing 87 changed files with 368 additions and 500 deletions.
6 changes: 0 additions & 6 deletions .bazelrc

This file was deleted.

41 changes: 31 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
os: [ubuntu-latest, macos-latest]
python-version: ["3.8"]

env:
STAR_OBSERVATION_SCHEDULING_DATA: ${{ github.workspace }}/data/star_observation_scheduling
FLEXIBLE_STAR_OBSERVATION_SCHEDULING_DATA: ${{ github.workspace }}/data/flexible_star_observation_scheduling

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -25,12 +29,20 @@ jobs:
run: |
python3 -m pip install gdown
python3 -u scripts/download_data.py
- name: Build Linux
run: bazel build -- //...
if: matrix.os != 'windows-latest'
- name: Build Windows
run: bazel build --cxxopt=/MT -- //...
if: matrix.os == 'windows-latest'
- name: 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"
if: matrix.os == 'macos-latest'
- name: Run tests
run: python3 -u scripts/run_tests.py test_results
- name: Checkout main branch
Expand All @@ -39,12 +51,21 @@ jobs:
git fetch --depth 1
git checkout main
- name: Build Linux
run: bazel build -- //...
run: bazel build -- //starobservationschedulingsolver/...
if: matrix.os != 'windows-latest'
- name: Build Windows
run: bazel build --cxxopt=/MT -- //...
run: bazel build --cxxopt=/MT -- //starobservationschedulingsolver/...
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-starobservationschedulingsolver/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
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.15.0)

project(StarObservationSchedulingSolver LANGUAGES CXX)

# 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)
194 changes: 0 additions & 194 deletions WORKSPACE

This file was deleted.

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

# Fetch fontanf/columngenerationsolver.
FetchContent_Declare(
columngenerationsolver
GIT_REPOSITORY https://github.com/fontanf/columngenerationsolver.git
GIT_TAG 32561f17c6fa7100b2dedb5d397dab1a03c9db2c)
#SOURCE_DIR "${PROJECT_SOURCE_DIR}/../columngenerationsolver/")
FetchContent_MakeAvailable(columngenerationsolver)
30 changes: 14 additions & 16 deletions scripts/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
args = parser.parse_args()


star_observation_scheduling_data = os.environ['STAR_OBSERVATION_SCHEDULING_DATA']
star_observation_scheduling_main = os.path.join(
"bazel-bin",
"starobservationschedulingsolver",
"star_observation_scheduling",
"main")
"install",
"bin",
"starobservationschedulingsolver_star_observation_scheduling")


if args.tests is None or "star-observation-scheduling-column-generation" in args.tests:
print("Star observation scheduling problem / column generation")
print("-------------------------------------------------------")
print()

star_observation_scheduling_column_generation_data = [
data = [
os.path.join("catusse2016", "ins_400_71_1"),
os.path.join("catusse2016", "ins_400_71_2"),
os.path.join("catusse2016", "ins_400_71_3"),
Expand All @@ -37,10 +37,9 @@
os.path.join("catusse2016", "ins_600_107_4"),
os.path.join("catusse2016", "ins_600_107_5"),
os.path.join("catusse2016", "real.txt")]
for instance in star_observation_scheduling_column_generation_data:
for instance in data:
instance_path = os.path.join(
"data",
"star_observation_scheduling",
star_observation_scheduling_data,
instance)
json_output_path = os.path.join(
args.directory,
Expand All @@ -63,19 +62,19 @@
print()


flexible_star_observation_scheduling_data = os.environ['FLEXIBLE_STAR_OBSERVATION_SCHEDULING_DATA']
flexible_star_observation_scheduling_main = os.path.join(
"bazel-bin",
"starobservationschedulingsolver",
"flexible_star_observation_scheduling",
"main")
"install",
"bin",
"starobservationschedulingsolver_flexible_star_observation_scheduling")


if args.tests is None or "flexible-star-observation-scheduling-column-generation" in args.tests:
print("Flexible star observation scheduling / column generation")
print("--------------------------------------------------------")
print()

flexible_star_observation_scheduling_column_generation_data = [
data = [
os.path.join("catusse2016_discrete_80", "ins_400_71_1"),
os.path.join("catusse2016_discrete_80", "ins_400_71_2"),
os.path.join("catusse2016_discrete_80", "ins_400_71_3"),
Expand All @@ -86,10 +85,9 @@
os.path.join("catusse2016_discrete_85", "ins_400_71_3"),
os.path.join("catusse2016_discrete_85", "ins_400_71_4"),
os.path.join("catusse2016_discrete_85", "ins_400_71_5")]
for instance in flexible_star_observation_scheduling_column_generation_data:
for instance in data:
instance_path = os.path.join(
"data",
"flexible_star_observation_scheduling",
flexible_star_observation_scheduling_data,
instance)
json_output_path = os.path.join(
args.directory,
Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
add_subdirectory(flexible_single_night_star_observation_scheduling)
add_subdirectory(flexible_star_observation_scheduling)
add_subdirectory(single_night_star_observation_scheduling)
add_subdirectory(star_observation_scheduling)
Loading

0 comments on commit 0d5c23a

Please sign in to comment.