diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9af52e4..499fe0d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,12 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] python-version: ["3.8"] + env: + TRAVELLING_THIEF_DATA: ${{ github.workspace }}/data/travelling_thief + TRAVELLING_WHILE_PACKING_DATA: ${{ github.workspace }}/data/travelling_while_packing + PACKING_WHILE_TRAVELLING_DATA: ${{ github.workspace }}/data/packing_while_travelling + THIEF_ORIENTEERING_DATA: ${{ github.workspace }}/data/thief_orienteering + steps: - name: Checkout code uses: actions/checkout@v4 @@ -25,7 +31,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 @@ -34,8 +43,8 @@ jobs: git fetch --depth 1 git checkout master - name: Build - run: bazel build -- //... + run: bazel build -- //travellingthiefsolver/... - name: Run tests run: python3 -u scripts/run_tests.py test_results_ref - name: Process tests - run: python3 ./bazel-travellingthiefsolver/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 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..2242360 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.15.0) + +project(TravellingThiefSolver LANGUAGES CXX) + +# Require C++14. +set(CMAKE_CXX_STANDARD 14) + +# Enable output of compile commands during generation. +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# Add sub-directories. +add_subdirectory(extern) +add_subdirectory(src) +add_subdirectory(test) diff --git a/README.md b/README.md index d542180..97c09da 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,9 @@ Authors: Compile: ```shell -bazel build -- //... +cmake -S . -B build -DCMAKE_BUILD_TYPE=Release +cmake --build build --config Release --parallel +cmake --install build --config Release --prefix install ``` Download data: @@ -72,7 +74,7 @@ python3 scripts/download_data.py Examples: ```shell -./bazel-bin/travellingthiefsolver/travelling_thief/main -v 1 -i "data/travelling_thief/gecco2023/fnl4461_n4460_bounded-strongly-corr_01.ttp" -a "iterative-tsp-pwt-ttp" -t 600 +./install/bin/travellingthiefsolver_travelling_thief --verbosity-level 1 --input "data/travelling_thief/gecco2023/fnl4461_n4460_bounded-strongly-corr_01.ttp" --algorithm "iterative-tsp-pwt-ttp" --time-limit 600 ``` ``` ===================================== diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt new file mode 100644 index 0000000..753ab91 --- /dev/null +++ b/extern/CMakeLists.txt @@ -0,0 +1,26 @@ +# Enable FetchContent. +include(FetchContent) + +# Fetch fontanf/knapsacksolver. +FetchContent_Declare( + knapsacksolver + GIT_REPOSITORY https://github.com/fontanf/knapsacksolver.git + GIT_TAG abbe052b56c6e985112cda23abda26f1eb0e43ce) + #SOURCE_DIR "${PROJECT_SOURCE_DIR}/../knapsacksolver/") +FetchContent_MakeAvailable(knapsacksolver) + +# Fetch fontanf/treesearchsolver. +FetchContent_Declare( + treesearchsolver + GIT_REPOSITORY https://github.com/fontanf/treesearchsolver.git + GIT_TAG dca5b35d5cb6de3443b9ab08175f931b2df29b6b) + #SOURCE_DIR "${PROJECT_SOURCE_DIR}/../treesearchsolver/") +FetchContent_MakeAvailable(treesearchsolver) + +# Fetch fontanf/localsearchsolver. +FetchContent_Declare( + localsearchsolver + GIT_REPOSITORY https://github.com/fontanf/localsearchsolver.git + GIT_TAG ecb15ef667d107f25ea51d056368f9c4e15545e2) + #SOURCE_DIR "${PROJECT_SOURCE_DIR}/../localsearchsolver/") +FetchContent_MakeAvailable(localsearchsolver) diff --git a/travellingthiefsolver/packing_while_travelling/algorithm.hpp b/include/travellingthiefsolver/packing_while_travelling/algorithm.hpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/algorithm.hpp rename to include/travellingthiefsolver/packing_while_travelling/algorithm.hpp diff --git a/travellingthiefsolver/packing_while_travelling/algorithm_formatter.hpp b/include/travellingthiefsolver/packing_while_travelling/algorithm_formatter.hpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/algorithm_formatter.hpp rename to include/travellingthiefsolver/packing_while_travelling/algorithm_formatter.hpp diff --git a/travellingthiefsolver/packing_while_travelling/algorithms/dynamic_programming.hpp b/include/travellingthiefsolver/packing_while_travelling/algorithms/dynamic_programming.hpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/algorithms/dynamic_programming.hpp rename to include/travellingthiefsolver/packing_while_travelling/algorithms/dynamic_programming.hpp diff --git a/travellingthiefsolver/packing_while_travelling/algorithms/efficient_local_search.hpp b/include/travellingthiefsolver/packing_while_travelling/algorithms/efficient_local_search.hpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/algorithms/efficient_local_search.hpp rename to include/travellingthiefsolver/packing_while_travelling/algorithms/efficient_local_search.hpp diff --git a/travellingthiefsolver/packing_while_travelling/algorithms/greedy.hpp b/include/travellingthiefsolver/packing_while_travelling/algorithms/greedy.hpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/algorithms/greedy.hpp rename to include/travellingthiefsolver/packing_while_travelling/algorithms/greedy.hpp diff --git a/travellingthiefsolver/packing_while_travelling/algorithms/large_neighborhood_search.hpp b/include/travellingthiefsolver/packing_while_travelling/algorithms/large_neighborhood_search.hpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/algorithms/large_neighborhood_search.hpp rename to include/travellingthiefsolver/packing_while_travelling/algorithms/large_neighborhood_search.hpp diff --git a/travellingthiefsolver/packing_while_travelling/algorithms/sequential_value_correction.hpp b/include/travellingthiefsolver/packing_while_travelling/algorithms/sequential_value_correction.hpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/algorithms/sequential_value_correction.hpp rename to include/travellingthiefsolver/packing_while_travelling/algorithms/sequential_value_correction.hpp diff --git a/travellingthiefsolver/packing_while_travelling/instance.hpp b/include/travellingthiefsolver/packing_while_travelling/instance.hpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/instance.hpp rename to include/travellingthiefsolver/packing_while_travelling/instance.hpp diff --git a/travellingthiefsolver/packing_while_travelling/instance_builder.hpp b/include/travellingthiefsolver/packing_while_travelling/instance_builder.hpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/instance_builder.hpp rename to include/travellingthiefsolver/packing_while_travelling/instance_builder.hpp diff --git a/travellingthiefsolver/packing_while_travelling/reduction.hpp b/include/travellingthiefsolver/packing_while_travelling/reduction.hpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/reduction.hpp rename to include/travellingthiefsolver/packing_while_travelling/reduction.hpp diff --git a/travellingthiefsolver/packing_while_travelling/solution.hpp b/include/travellingthiefsolver/packing_while_travelling/solution.hpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/solution.hpp rename to include/travellingthiefsolver/packing_while_travelling/solution.hpp diff --git a/travellingthiefsolver/packing_while_travelling/solution_builder.hpp b/include/travellingthiefsolver/packing_while_travelling/solution_builder.hpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/solution_builder.hpp rename to include/travellingthiefsolver/packing_while_travelling/solution_builder.hpp diff --git a/travellingthiefsolver/packing_while_travelling/utils.hpp b/include/travellingthiefsolver/packing_while_travelling/utils.hpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/utils.hpp rename to include/travellingthiefsolver/packing_while_travelling/utils.hpp diff --git a/travellingthiefsolver/thief_orienteering/algorithm_formatter.hpp b/include/travellingthiefsolver/thief_orienteering/algorithm_formatter.hpp similarity index 100% rename from travellingthiefsolver/thief_orienteering/algorithm_formatter.hpp rename to include/travellingthiefsolver/thief_orienteering/algorithm_formatter.hpp diff --git a/travellingthiefsolver/thief_orienteering/algorithms/local_search.hpp b/include/travellingthiefsolver/thief_orienteering/algorithms/local_search.hpp similarity index 100% rename from travellingthiefsolver/thief_orienteering/algorithms/local_search.hpp rename to include/travellingthiefsolver/thief_orienteering/algorithms/local_search.hpp diff --git a/travellingthiefsolver/thief_orienteering/algorithms/tree_search.hpp b/include/travellingthiefsolver/thief_orienteering/algorithms/tree_search.hpp similarity index 100% rename from travellingthiefsolver/thief_orienteering/algorithms/tree_search.hpp rename to include/travellingthiefsolver/thief_orienteering/algorithms/tree_search.hpp diff --git a/travellingthiefsolver/thief_orienteering/instance.hpp b/include/travellingthiefsolver/thief_orienteering/instance.hpp similarity index 100% rename from travellingthiefsolver/thief_orienteering/instance.hpp rename to include/travellingthiefsolver/thief_orienteering/instance.hpp diff --git a/travellingthiefsolver/thief_orienteering/instance_builder.hpp b/include/travellingthiefsolver/thief_orienteering/instance_builder.hpp similarity index 100% rename from travellingthiefsolver/thief_orienteering/instance_builder.hpp rename to include/travellingthiefsolver/thief_orienteering/instance_builder.hpp diff --git a/travellingthiefsolver/thief_orienteering/solution.hpp b/include/travellingthiefsolver/thief_orienteering/solution.hpp similarity index 100% rename from travellingthiefsolver/thief_orienteering/solution.hpp rename to include/travellingthiefsolver/thief_orienteering/solution.hpp diff --git a/travellingthiefsolver/travelling_thief/algorithm_formatter.hpp b/include/travellingthiefsolver/travelling_thief/algorithm_formatter.hpp similarity index 100% rename from travellingthiefsolver/travelling_thief/algorithm_formatter.hpp rename to include/travellingthiefsolver/travelling_thief/algorithm_formatter.hpp diff --git a/travellingthiefsolver/travelling_thief/algorithms/efficient_local_search.hpp b/include/travellingthiefsolver/travelling_thief/algorithms/efficient_local_search.hpp similarity index 100% rename from travellingthiefsolver/travelling_thief/algorithms/efficient_local_search.hpp rename to include/travellingthiefsolver/travelling_thief/algorithms/efficient_local_search.hpp diff --git a/travellingthiefsolver/travelling_thief/algorithms/iterative_tsp_pwt.hpp b/include/travellingthiefsolver/travelling_thief/algorithms/iterative_tsp_pwt.hpp similarity index 100% rename from travellingthiefsolver/travelling_thief/algorithms/iterative_tsp_pwt.hpp rename to include/travellingthiefsolver/travelling_thief/algorithms/iterative_tsp_pwt.hpp diff --git a/travellingthiefsolver/travelling_thief/algorithms/iterative_tsp_pwt_ttp.hpp b/include/travellingthiefsolver/travelling_thief/algorithms/iterative_tsp_pwt_ttp.hpp similarity index 100% rename from travellingthiefsolver/travelling_thief/algorithms/iterative_tsp_pwt_ttp.hpp rename to include/travellingthiefsolver/travelling_thief/algorithms/iterative_tsp_pwt_ttp.hpp diff --git a/travellingthiefsolver/travelling_thief/algorithms/large_neighborhood_search.hpp b/include/travellingthiefsolver/travelling_thief/algorithms/large_neighborhood_search.hpp similarity index 100% rename from travellingthiefsolver/travelling_thief/algorithms/large_neighborhood_search.hpp rename to include/travellingthiefsolver/travelling_thief/algorithms/large_neighborhood_search.hpp diff --git a/travellingthiefsolver/travelling_thief/algorithms/local_search.hpp b/include/travellingthiefsolver/travelling_thief/algorithms/local_search.hpp similarity index 100% rename from travellingthiefsolver/travelling_thief/algorithms/local_search.hpp rename to include/travellingthiefsolver/travelling_thief/algorithms/local_search.hpp diff --git a/travellingthiefsolver/travelling_thief/algorithms/tree_search.hpp b/include/travellingthiefsolver/travelling_thief/algorithms/tree_search.hpp similarity index 100% rename from travellingthiefsolver/travelling_thief/algorithms/tree_search.hpp rename to include/travellingthiefsolver/travelling_thief/algorithms/tree_search.hpp diff --git a/travellingthiefsolver/travelling_thief/instance.hpp b/include/travellingthiefsolver/travelling_thief/instance.hpp similarity index 100% rename from travellingthiefsolver/travelling_thief/instance.hpp rename to include/travellingthiefsolver/travelling_thief/instance.hpp diff --git a/travellingthiefsolver/travelling_thief/instance_builder.hpp b/include/travellingthiefsolver/travelling_thief/instance_builder.hpp similarity index 100% rename from travellingthiefsolver/travelling_thief/instance_builder.hpp rename to include/travellingthiefsolver/travelling_thief/instance_builder.hpp diff --git a/travellingthiefsolver/travelling_thief/solution.hpp b/include/travellingthiefsolver/travelling_thief/solution.hpp similarity index 100% rename from travellingthiefsolver/travelling_thief/solution.hpp rename to include/travellingthiefsolver/travelling_thief/solution.hpp diff --git a/travellingthiefsolver/travelling_thief/utils.hpp b/include/travellingthiefsolver/travelling_thief/utils.hpp similarity index 100% rename from travellingthiefsolver/travelling_thief/utils.hpp rename to include/travellingthiefsolver/travelling_thief/utils.hpp diff --git a/travellingthiefsolver/travelling_while_packing/algorithm_formatter.hpp b/include/travellingthiefsolver/travelling_while_packing/algorithm_formatter.hpp similarity index 100% rename from travellingthiefsolver/travelling_while_packing/algorithm_formatter.hpp rename to include/travellingthiefsolver/travelling_while_packing/algorithm_formatter.hpp diff --git a/travellingthiefsolver/travelling_while_packing/algorithms/local_search.hpp b/include/travellingthiefsolver/travelling_while_packing/algorithms/local_search.hpp similarity index 100% rename from travellingthiefsolver/travelling_while_packing/algorithms/local_search.hpp rename to include/travellingthiefsolver/travelling_while_packing/algorithms/local_search.hpp diff --git a/travellingthiefsolver/travelling_while_packing/instance.hpp b/include/travellingthiefsolver/travelling_while_packing/instance.hpp similarity index 100% rename from travellingthiefsolver/travelling_while_packing/instance.hpp rename to include/travellingthiefsolver/travelling_while_packing/instance.hpp diff --git a/travellingthiefsolver/travelling_while_packing/instance_builder.hpp b/include/travellingthiefsolver/travelling_while_packing/instance_builder.hpp similarity index 100% rename from travellingthiefsolver/travelling_while_packing/instance_builder.hpp rename to include/travellingthiefsolver/travelling_while_packing/instance_builder.hpp diff --git a/travellingthiefsolver/travelling_while_packing/solution.hpp b/include/travellingthiefsolver/travelling_while_packing/solution.hpp similarity index 100% rename from travellingthiefsolver/travelling_while_packing/solution.hpp rename to include/travellingthiefsolver/travelling_while_packing/solution.hpp diff --git a/scripts/download_data.py b/scripts/download_data.py index 00f5073..0280b2c 100644 --- a/scripts/download_data.py +++ b/scripts/download_data.py @@ -4,9 +4,16 @@ def download(id): - gdown.download(id=id, output="data.7z") - os.system("7z x data.7z -odata") - pathlib.Path("data.7z").unlink() + for _ in range(3): + try: + gdown.download(id=id, output="data.7z") + os.system("7z x data.7z -odata") + pathlib.Path("data.7z").unlink() + except: + time.sleep(10) + continue + return + sys.exit(1) download("1RmT19FCH3gnxTi8GRCrI_UUJGSMPUXTT") diff --git a/scripts/run_tests.py b/scripts/run_tests.py index 01176b8..a92c728 100644 --- a/scripts/run_tests.py +++ b/scripts/run_tests.py @@ -14,11 +14,11 @@ +travelling_thief_data = os.environ['TRAVELLING_THIEF_DATA'] travelling_thief_main = os.path.join( - "bazel-bin", - "travellingthiefsolver", - "travelling_thief", - "main") + "install", + "bin", + "travellingthiefsolver_travelling_thief") if args.tests is None or "travelling-thief-local-search" in args.tests: @@ -26,7 +26,7 @@ print("---------------------------------------") print() - travelling_thief_local_search_data = [ + data = [ os.path.join("polyakovskiy2014", "berlin52-ttp", "berlin52_n51_bounded-strongly-corr_01.ttp"), os.path.join("polyakovskiy2014", "berlin52-ttp", "berlin52_n51_uncorr_01.ttp"), os.path.join("polyakovskiy2014", "berlin52-ttp", "berlin52_n51_uncorr-similar-weights_01.ttp"), @@ -36,10 +36,9 @@ os.path.join("polyakovskiy2014", "berlin52-ttp", "berlin52_n255_bounded-strongly-corr_01.ttp"), os.path.join("polyakovskiy2014", "berlin52-ttp", "berlin52_n255_uncorr_01.ttp"), os.path.join("polyakovskiy2014", "berlin52-ttp", "berlin52_n255_uncorr-similar-weights_01.ttp")] - for instance in travelling_thief_local_search_data: + for instance in data: instance_path = os.path.join( - "data", - "travelling_thief", + travelling_thief_data, instance) json_output_path = os.path.join( args.directory, @@ -67,7 +66,7 @@ print("--------------------------------------") print() - travelling_thief_tree_search_data = [ + data = [ os.path.join("wu2017", "eil51_n14_m13_multiple-strongly-corr_01.ttp"), os.path.join("wu2017", "eil51_n14_m13_uncorr_01.ttp"), os.path.join("wu2017", "eil51_n14_m13_uncorr-similar-weights_01.ttp"), @@ -77,10 +76,9 @@ os.path.join("wu2017", "eil51_n05_m40_multiple-strongly-corr_01.ttp"), os.path.join("wu2017", "eil51_n05_m40_uncorr_01.ttp"), os.path.join("wu2017", "eil51_n05_m40_uncorr-similar-weights_01.ttp")] - for instance in travelling_thief_tree_search_data: + for instance in data: instance_path = os.path.join( - "data", - "travelling_thief", + travelling_thief_data, instance) json_output_path = os.path.join( args.directory, @@ -102,11 +100,11 @@ print() +thief_orienteering_data = os.environ['THIEF_ORIENTEERING_DATA'] thief_orienteering_main = os.path.join( - "bazel-bin", - "travellingthiefsolver", - "thief_orienteering", - "main") + "install", + "bin", + "travellingthiefsolver_thief_orienteering") if args.tests is None or "thief-orienteering-local-search" in args.tests: @@ -114,7 +112,7 @@ print("---------------------------------") print() - thief_orienteering_local_search_data = [ + data = [ os.path.join("santos2018", "eil51-thop", "eil51_01_bsc_01_01.thop"), os.path.join("santos2018", "eil51-thop", "eil51_01_unc_05_01.thop"), os.path.join("santos2018", "eil51-thop", "eil51_01_usw_10_01.thop"), @@ -124,10 +122,9 @@ os.path.join("santos2018", "eil51-thop", "eil51_05_bsc_10_01.thop"), os.path.join("santos2018", "eil51-thop", "eil51_05_unc_01_01.thop"), os.path.join("santos2018", "eil51-thop", "eil51_05_usw_05_01.thop")] - for instance in thief_orienteering_local_search_data: + for instance in data: instance_path = os.path.join( - "data", - "thief_orienteering", + thief_orienteering_data, instance) json_output_path = os.path.join( args.directory, diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..cd3045a --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(packing_while_travelling) +add_subdirectory(thief_orienteering) +add_subdirectory(travelling_thief) +add_subdirectory(travelling_while_packing) diff --git a/src/packing_while_travelling/CMakeLists.txt b/src/packing_while_travelling/CMakeLists.txt new file mode 100644 index 0000000..eeac796 --- /dev/null +++ b/src/packing_while_travelling/CMakeLists.txt @@ -0,0 +1,31 @@ +add_library(TravellingThiefSolver_packing_while_travelling) +target_sources(TravellingThiefSolver_packing_while_travelling PRIVATE + instance.cpp + instance_builder.cpp + solution.cpp + solution_builder.cpp + utils.cpp + reduction.cpp + algorithm.cpp + algorithm_formatter.cpp) +target_include_directories(TravellingThiefSolver_packing_while_travelling PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_packing_while_travelling PUBLIC + OptimizationTools::containers + OptimizationTools::utils) +add_library(TravellingThiefSolver::knapsack ALIAS TravellingThiefSolver_packing_while_travelling) + +add_subdirectory(algorithms) + +add_executable(TravellingThiefSolver_packing_while_travelling_main) +target_sources(TravellingThiefSolver_packing_while_travelling_main PRIVATE + main.cpp) +target_link_libraries(TravellingThiefSolver_packing_while_travelling_main PUBLIC + TravellingThiefSolver_packing_while_travelling_greedy + TravellingThiefSolver_packing_while_travelling_sequential_value_correction + TravellingThiefSolver_packing_while_travelling_dynamic_programming + TravellingThiefSolver_packing_while_travelling_efficient_local_search + TravellingThiefSolver_packing_while_travelling_large_neighborhood_search + Boost::program_options) +set_target_properties(TravellingThiefSolver_packing_while_travelling_main PROPERTIES OUTPUT_NAME "travellingthiefsolver_packing_while_travelling") +install(TARGETS TravellingThiefSolver_packing_while_travelling_main) diff --git a/travellingthiefsolver/packing_while_travelling/algorithm.cpp b/src/packing_while_travelling/algorithm.cpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/algorithm.cpp rename to src/packing_while_travelling/algorithm.cpp diff --git a/travellingthiefsolver/packing_while_travelling/algorithm_formatter.cpp b/src/packing_while_travelling/algorithm_formatter.cpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/algorithm_formatter.cpp rename to src/packing_while_travelling/algorithm_formatter.cpp diff --git a/src/packing_while_travelling/algorithms/CMakeLists.txt b/src/packing_while_travelling/algorithms/CMakeLists.txt new file mode 100644 index 0000000..d203252 --- /dev/null +++ b/src/packing_while_travelling/algorithms/CMakeLists.txt @@ -0,0 +1,48 @@ +add_library(TravellingThiefSolver_packing_while_travelling_greedy) +target_sources(TravellingThiefSolver_packing_while_travelling_greedy PRIVATE + greedy.cpp) +target_include_directories(TravellingThiefSolver_packing_while_travelling_greedy PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_packing_while_travelling_greedy PUBLIC + TravellingThiefSolver_packing_while_travelling) +add_library(TravellingThiefSolver::knapsack::greedy ALIAS TravellingThiefSolver_packing_while_travelling_greedy) + +add_library(TravellingThiefSolver_packing_while_travelling_sequential_value_correction) +target_sources(TravellingThiefSolver_packing_while_travelling_sequential_value_correction PRIVATE + sequential_value_correction.cpp) +target_include_directories(TravellingThiefSolver_packing_while_travelling_sequential_value_correction PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_packing_while_travelling_sequential_value_correction PUBLIC + TravellingThiefSolver_packing_while_travelling + KnapsackSolver::knapsack::dynamic_programming_primal_dual) +add_library(TravellingThiefSolver::knapsack::sequential_value_correction ALIAS TravellingThiefSolver_packing_while_travelling_sequential_value_correction) + +add_library(TravellingThiefSolver_packing_while_travelling_dynamic_programming) +target_sources(TravellingThiefSolver_packing_while_travelling_dynamic_programming PRIVATE + dynamic_programming.cpp) +target_include_directories(TravellingThiefSolver_packing_while_travelling_dynamic_programming PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_packing_while_travelling_dynamic_programming PUBLIC + TravellingThiefSolver_packing_while_travelling) +add_library(TravellingThiefSolver::knapsack::dynamic_programming ALIAS TravellingThiefSolver_packing_while_travelling_dynamic_programming) + +add_library(TravellingThiefSolver_packing_while_travelling_efficient_local_search) +target_sources(TravellingThiefSolver_packing_while_travelling_efficient_local_search PRIVATE + efficient_local_search.cpp) +target_include_directories(TravellingThiefSolver_packing_while_travelling_efficient_local_search PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_packing_while_travelling_efficient_local_search PUBLIC + TravellingThiefSolver_packing_while_travelling + TravellingThiefSolver_packing_while_travelling_sequential_value_correction) +add_library(TravellingThiefSolver::knapsack::efficient_local_search ALIAS TravellingThiefSolver_packing_while_travelling_efficient_local_search) + +add_library(TravellingThiefSolver_packing_while_travelling_large_neighborhood_search) +target_sources(TravellingThiefSolver_packing_while_travelling_large_neighborhood_search PRIVATE + large_neighborhood_search.cpp) +target_include_directories(TravellingThiefSolver_packing_while_travelling_large_neighborhood_search PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_packing_while_travelling_large_neighborhood_search PUBLIC + TravellingThiefSolver_packing_while_travelling + TravellingThiefSolver_packing_while_travelling_greedy + TravellingThiefSolver_packing_while_travelling_sequential_value_correction) +add_library(TravellingThiefSolver::knapsack::large_neighborhood_search ALIAS TravellingThiefSolver_packing_while_travelling_large_neighborhood_search) diff --git a/travellingthiefsolver/packing_while_travelling/algorithms/dynamic_programming.cpp b/src/packing_while_travelling/algorithms/dynamic_programming.cpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/algorithms/dynamic_programming.cpp rename to src/packing_while_travelling/algorithms/dynamic_programming.cpp diff --git a/travellingthiefsolver/packing_while_travelling/algorithms/efficient_local_search.cpp b/src/packing_while_travelling/algorithms/efficient_local_search.cpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/algorithms/efficient_local_search.cpp rename to src/packing_while_travelling/algorithms/efficient_local_search.cpp diff --git a/travellingthiefsolver/packing_while_travelling/algorithms/greedy.cpp b/src/packing_while_travelling/algorithms/greedy.cpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/algorithms/greedy.cpp rename to src/packing_while_travelling/algorithms/greedy.cpp diff --git a/travellingthiefsolver/packing_while_travelling/algorithms/large_neighborhood_search.cpp b/src/packing_while_travelling/algorithms/large_neighborhood_search.cpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/algorithms/large_neighborhood_search.cpp rename to src/packing_while_travelling/algorithms/large_neighborhood_search.cpp diff --git a/travellingthiefsolver/packing_while_travelling/algorithms/sequential_value_correction.cpp b/src/packing_while_travelling/algorithms/sequential_value_correction.cpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/algorithms/sequential_value_correction.cpp rename to src/packing_while_travelling/algorithms/sequential_value_correction.cpp diff --git a/travellingthiefsolver/packing_while_travelling/instance.cpp b/src/packing_while_travelling/instance.cpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/instance.cpp rename to src/packing_while_travelling/instance.cpp diff --git a/travellingthiefsolver/packing_while_travelling/instance_builder.cpp b/src/packing_while_travelling/instance_builder.cpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/instance_builder.cpp rename to src/packing_while_travelling/instance_builder.cpp diff --git a/travellingthiefsolver/packing_while_travelling/main.cpp b/src/packing_while_travelling/main.cpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/main.cpp rename to src/packing_while_travelling/main.cpp diff --git a/travellingthiefsolver/packing_while_travelling/reduction.cpp b/src/packing_while_travelling/reduction.cpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/reduction.cpp rename to src/packing_while_travelling/reduction.cpp diff --git a/travellingthiefsolver/packing_while_travelling/solution.cpp b/src/packing_while_travelling/solution.cpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/solution.cpp rename to src/packing_while_travelling/solution.cpp diff --git a/travellingthiefsolver/packing_while_travelling/solution_builder.cpp b/src/packing_while_travelling/solution_builder.cpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/solution_builder.cpp rename to src/packing_while_travelling/solution_builder.cpp diff --git a/travellingthiefsolver/packing_while_travelling/utils.cpp b/src/packing_while_travelling/utils.cpp similarity index 100% rename from travellingthiefsolver/packing_while_travelling/utils.cpp rename to src/packing_while_travelling/utils.cpp diff --git a/src/thief_orienteering/CMakeLists.txt b/src/thief_orienteering/CMakeLists.txt new file mode 100644 index 0000000..3cde27f --- /dev/null +++ b/src/thief_orienteering/CMakeLists.txt @@ -0,0 +1,33 @@ +add_library(TravellingThiefSolver_thief_orienteering) +target_sources(TravellingThiefSolver_thief_orienteering PRIVATE + instance.cpp + instance_builder.cpp + solution.cpp + algorithm_formatter.cpp) +target_include_directories(TravellingThiefSolver_thief_orienteering PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_thief_orienteering PUBLIC + OptimizationTools::utils + TravelingSalesmanSolver::distances) +add_library(TravellingThiefSolver::knapsack ALIAS TravellingThiefSolver_thief_orienteering) + +add_subdirectory(algorithms) + +add_executable(TravellingThiefSolver_thief_orienteering_main) +target_sources(TravellingThiefSolver_thief_orienteering_main PRIVATE + main.cpp) +target_link_libraries(TravellingThiefSolver_thief_orienteering_main PUBLIC + TravellingThiefSolver_thief_orienteering_tree_search + TravellingThiefSolver_thief_orienteering_local_search + Boost::program_options) +set_target_properties(TravellingThiefSolver_thief_orienteering_main PROPERTIES OUTPUT_NAME "travellingthiefsolver_thief_orienteering") +install(TARGETS TravellingThiefSolver_thief_orienteering_main) + +add_executable(TravellingThiefSolver_thief_orienteering_checker) +target_sources(TravellingThiefSolver_thief_orienteering_checker PRIVATE + checker.cpp) +target_link_libraries(TravellingThiefSolver_thief_orienteering_checker PUBLIC + TravellingThiefSolver_thief_orienteering + Boost::program_options) +set_target_properties(TravellingThiefSolver_thief_orienteering_checker PROPERTIES OUTPUT_NAME "travellingthiefsolver_thief_orienteering_checker") +install(TARGETS TravellingThiefSolver_thief_orienteering_checker) diff --git a/travellingthiefsolver/thief_orienteering/algorithm_formatter.cpp b/src/thief_orienteering/algorithm_formatter.cpp similarity index 100% rename from travellingthiefsolver/thief_orienteering/algorithm_formatter.cpp rename to src/thief_orienteering/algorithm_formatter.cpp diff --git a/src/thief_orienteering/algorithms/CMakeLists.txt b/src/thief_orienteering/algorithms/CMakeLists.txt new file mode 100644 index 0000000..63de1b9 --- /dev/null +++ b/src/thief_orienteering/algorithms/CMakeLists.txt @@ -0,0 +1,19 @@ +add_library(TravellingThiefSolver_thief_orienteering_tree_search) +target_sources(TravellingThiefSolver_thief_orienteering_tree_search PRIVATE + tree_search.cpp) +target_include_directories(TravellingThiefSolver_thief_orienteering_tree_search PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_thief_orienteering_tree_search PUBLIC + TravellingThiefSolver_thief_orienteering + TreeSearchSolver::treesearchsolver) +add_library(TravellingThiefSolver::thief_orienteering::tree_search ALIAS TravellingThiefSolver_thief_orienteering_tree_search) + +add_library(TravellingThiefSolver_thief_orienteering_local_search) +target_sources(TravellingThiefSolver_thief_orienteering_local_search PRIVATE + local_search.cpp) +target_include_directories(TravellingThiefSolver_thief_orienteering_local_search PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_thief_orienteering_local_search PUBLIC + TravellingThiefSolver_thief_orienteering + LocalSearchSolver::localsearchsolver) +add_library(TravellingThiefSolver::thief_orienteering::local_search ALIAS TravellingThiefSolver_thief_orienteering_local_search) diff --git a/travellingthiefsolver/thief_orienteering/algorithms/local_search.cpp b/src/thief_orienteering/algorithms/local_search.cpp similarity index 100% rename from travellingthiefsolver/thief_orienteering/algorithms/local_search.cpp rename to src/thief_orienteering/algorithms/local_search.cpp diff --git a/travellingthiefsolver/thief_orienteering/algorithms/tree_search.cpp b/src/thief_orienteering/algorithms/tree_search.cpp similarity index 100% rename from travellingthiefsolver/thief_orienteering/algorithms/tree_search.cpp rename to src/thief_orienteering/algorithms/tree_search.cpp diff --git a/travellingthiefsolver/thief_orienteering/checker.cpp b/src/thief_orienteering/checker.cpp similarity index 100% rename from travellingthiefsolver/thief_orienteering/checker.cpp rename to src/thief_orienteering/checker.cpp diff --git a/travellingthiefsolver/thief_orienteering/instance.cpp b/src/thief_orienteering/instance.cpp similarity index 100% rename from travellingthiefsolver/thief_orienteering/instance.cpp rename to src/thief_orienteering/instance.cpp diff --git a/travellingthiefsolver/thief_orienteering/instance_builder.cpp b/src/thief_orienteering/instance_builder.cpp similarity index 100% rename from travellingthiefsolver/thief_orienteering/instance_builder.cpp rename to src/thief_orienteering/instance_builder.cpp diff --git a/travellingthiefsolver/thief_orienteering/main.cpp b/src/thief_orienteering/main.cpp similarity index 100% rename from travellingthiefsolver/thief_orienteering/main.cpp rename to src/thief_orienteering/main.cpp diff --git a/travellingthiefsolver/thief_orienteering/solution.cpp b/src/thief_orienteering/solution.cpp similarity index 100% rename from travellingthiefsolver/thief_orienteering/solution.cpp rename to src/thief_orienteering/solution.cpp diff --git a/src/travelling_thief/CMakeLists.txt b/src/travelling_thief/CMakeLists.txt new file mode 100644 index 0000000..2d5e6a0 --- /dev/null +++ b/src/travelling_thief/CMakeLists.txt @@ -0,0 +1,49 @@ +add_library(TravellingThiefSolver_travelling_thief) +target_sources(TravellingThiefSolver_travelling_thief PRIVATE + instance.cpp + instance_builder.cpp + solution.cpp + utils.cpp + algorithm_formatter.cpp) +target_include_directories(TravellingThiefSolver_travelling_thief PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_travelling_thief PUBLIC + TravellingThiefSolver_packing_while_travelling + TravellingThiefSolver_travelling_while_packing + TravelingSalesmanSolver::distances + TravelingSalesmanSolver::lkh + OptimizationTools::utils) +add_library(TravellingThiefSolver::knapsack ALIAS TravellingThiefSolver_travelling_thief) + +add_subdirectory(algorithms) + +add_executable(TravellingThiefSolver_travelling_thief_main) +target_sources(TravellingThiefSolver_travelling_thief_main PRIVATE + main.cpp) +target_link_libraries(TravellingThiefSolver_travelling_thief_main PUBLIC + TravellingThiefSolver_travelling_thief_tree_search + TravellingThiefSolver_travelling_thief_local_search + TravellingThiefSolver_travelling_thief_efficient_local_search + TravellingThiefSolver_travelling_thief_iterative_tsp_pwt + TravellingThiefSolver_travelling_thief_iterative_tsp_pwt_ttp + Boost::program_options) +set_target_properties(TravellingThiefSolver_travelling_thief_main PROPERTIES OUTPUT_NAME "travellingthiefsolver_travelling_thief") +install(TARGETS TravellingThiefSolver_travelling_thief_main) + +add_executable(TravellingThiefSolver_travelling_thief_checker) +target_sources(TravellingThiefSolver_travelling_thief_checker PRIVATE + checker.cpp) +target_link_libraries(TravellingThiefSolver_travelling_thief_checker PUBLIC + TravellingThiefSolver_travelling_thief + Boost::program_options) +set_target_properties(TravellingThiefSolver_travelling_thief_checker PROPERTIES OUTPUT_NAME "travellingthiefsolver_travelling_thief_checker") +install(TARGETS TravellingThiefSolver_travelling_thief_checker) + +add_executable(TravellingThiefSolver_travelling_thief_solution2instances) +target_sources(TravellingThiefSolver_travelling_thief_solution2instances PRIVATE + solution2instances.cpp) +target_link_libraries(TravellingThiefSolver_travelling_thief_solution2instances PUBLIC + TravellingThiefSolver_travelling_thief + Boost::program_options) +set_target_properties(TravellingThiefSolver_travelling_thief_solution2instances PROPERTIES OUTPUT_NAME "travellingthiefsolver_travelling_thief_solution2instances") +install(TARGETS TravellingThiefSolver_travelling_thief_solution2instances) diff --git a/travellingthiefsolver/travelling_thief/algorithm_formatter.cpp b/src/travelling_thief/algorithm_formatter.cpp similarity index 100% rename from travellingthiefsolver/travelling_thief/algorithm_formatter.cpp rename to src/travelling_thief/algorithm_formatter.cpp diff --git a/src/travelling_thief/algorithms/CMakeLists.txt b/src/travelling_thief/algorithms/CMakeLists.txt new file mode 100644 index 0000000..eaa8d14 --- /dev/null +++ b/src/travelling_thief/algorithms/CMakeLists.txt @@ -0,0 +1,57 @@ +add_library(TravellingThiefSolver_travelling_thief_tree_search) +target_sources(TravellingThiefSolver_travelling_thief_tree_search PRIVATE + tree_search.cpp) +target_include_directories(TravellingThiefSolver_travelling_thief_tree_search PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_travelling_thief_tree_search PUBLIC + TravellingThiefSolver_travelling_thief + TreeSearchSolver::treesearchsolver) +add_library(TravellingThiefSolver::travelling_thief::tree_search ALIAS TravellingThiefSolver_travelling_thief_tree_search) + +add_library(TravellingThiefSolver_travelling_thief_local_search) +target_sources(TravellingThiefSolver_travelling_thief_local_search PRIVATE + local_search.cpp) +target_include_directories(TravellingThiefSolver_travelling_thief_local_search PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_travelling_thief_local_search PUBLIC + TravellingThiefSolver_travelling_thief + TravellingThiefSolver_packing_while_travelling + LocalSearchSolver::localsearchsolver) +add_library(TravellingThiefSolver::travelling_thief::local_search ALIAS TravellingThiefSolver_travelling_thief_local_search) + +add_library(TravellingThiefSolver_travelling_thief_efficient_local_search) +target_sources(TravellingThiefSolver_travelling_thief_efficient_local_search PRIVATE + efficient_local_search.cpp) +target_include_directories(TravellingThiefSolver_travelling_thief_efficient_local_search PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_travelling_thief_efficient_local_search PUBLIC + TravellingThiefSolver_travelling_thief + TravellingThiefSolver_packing_while_travelling + TravellingThiefSolver_packing_while_travelling_sequential_value_correction + TravellingThiefSolver_packing_while_travelling_efficient_local_search + TravelingSalesmanSolver::lkh + LocalSearchSolver::localsearchsolver) +add_library(TravellingThiefSolver::travelling_thief::efficient_local_search ALIAS TravellingThiefSolver_travelling_thief_efficient_local_search) + +add_library(TravellingThiefSolver_travelling_thief_iterative_tsp_pwt) +target_sources(TravellingThiefSolver_travelling_thief_iterative_tsp_pwt PRIVATE + iterative_tsp_pwt.cpp) +target_include_directories(TravellingThiefSolver_travelling_thief_iterative_tsp_pwt PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_travelling_thief_iterative_tsp_pwt PUBLIC + TravellingThiefSolver_travelling_thief + TravellingThiefSolver_packing_while_travelling_sequential_value_correction + TravellingThiefSolver_packing_while_travelling_efficient_local_search) +add_library(TravellingThiefSolver::travelling_thief::iterative_tsp_pwt ALIAS TravellingThiefSolver_travelling_thief_iterative_tsp_pwt) + +add_library(TravellingThiefSolver_travelling_thief_iterative_tsp_pwt_ttp) +target_sources(TravellingThiefSolver_travelling_thief_iterative_tsp_pwt_ttp PRIVATE + iterative_tsp_pwt_ttp.cpp) +target_include_directories(TravellingThiefSolver_travelling_thief_iterative_tsp_pwt_ttp PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_travelling_thief_iterative_tsp_pwt_ttp PUBLIC + TravellingThiefSolver_travelling_thief + TravellingThiefSolver_travelling_thief_efficient_local_search + TravellingThiefSolver_packing_while_travelling_sequential_value_correction + TravellingThiefSolver_packing_while_travelling_efficient_local_search) +add_library(TravellingThiefSolver::travelling_thief::iterative_tsp_pwt_ttp ALIAS TravellingThiefSolver_travelling_thief_iterative_tsp_pwt_ttp) diff --git a/travellingthiefsolver/travelling_thief/algorithms/efficient_local_search.cpp b/src/travelling_thief/algorithms/efficient_local_search.cpp similarity index 100% rename from travellingthiefsolver/travelling_thief/algorithms/efficient_local_search.cpp rename to src/travelling_thief/algorithms/efficient_local_search.cpp diff --git a/travellingthiefsolver/travelling_thief/algorithms/iterative_tsp_pwt.cpp b/src/travelling_thief/algorithms/iterative_tsp_pwt.cpp similarity index 100% rename from travellingthiefsolver/travelling_thief/algorithms/iterative_tsp_pwt.cpp rename to src/travelling_thief/algorithms/iterative_tsp_pwt.cpp diff --git a/travellingthiefsolver/travelling_thief/algorithms/iterative_tsp_pwt_ttp.cpp b/src/travelling_thief/algorithms/iterative_tsp_pwt_ttp.cpp similarity index 100% rename from travellingthiefsolver/travelling_thief/algorithms/iterative_tsp_pwt_ttp.cpp rename to src/travelling_thief/algorithms/iterative_tsp_pwt_ttp.cpp diff --git a/travellingthiefsolver/travelling_thief/algorithms/large_neighborhood_search.cpp b/src/travelling_thief/algorithms/large_neighborhood_search.cpp similarity index 100% rename from travellingthiefsolver/travelling_thief/algorithms/large_neighborhood_search.cpp rename to src/travelling_thief/algorithms/large_neighborhood_search.cpp diff --git a/travellingthiefsolver/travelling_thief/algorithms/local_search.cpp b/src/travelling_thief/algorithms/local_search.cpp similarity index 100% rename from travellingthiefsolver/travelling_thief/algorithms/local_search.cpp rename to src/travelling_thief/algorithms/local_search.cpp diff --git a/travellingthiefsolver/travelling_thief/algorithms/tree_search.cpp b/src/travelling_thief/algorithms/tree_search.cpp similarity index 100% rename from travellingthiefsolver/travelling_thief/algorithms/tree_search.cpp rename to src/travelling_thief/algorithms/tree_search.cpp diff --git a/travellingthiefsolver/travelling_thief/checker.cpp b/src/travelling_thief/checker.cpp similarity index 100% rename from travellingthiefsolver/travelling_thief/checker.cpp rename to src/travelling_thief/checker.cpp diff --git a/travellingthiefsolver/travelling_thief/instance.cpp b/src/travelling_thief/instance.cpp similarity index 100% rename from travellingthiefsolver/travelling_thief/instance.cpp rename to src/travelling_thief/instance.cpp diff --git a/travellingthiefsolver/travelling_thief/instance_builder.cpp b/src/travelling_thief/instance_builder.cpp similarity index 100% rename from travellingthiefsolver/travelling_thief/instance_builder.cpp rename to src/travelling_thief/instance_builder.cpp diff --git a/travellingthiefsolver/travelling_thief/main.cpp b/src/travelling_thief/main.cpp similarity index 100% rename from travellingthiefsolver/travelling_thief/main.cpp rename to src/travelling_thief/main.cpp diff --git a/travellingthiefsolver/travelling_thief/solution.cpp b/src/travelling_thief/solution.cpp similarity index 100% rename from travellingthiefsolver/travelling_thief/solution.cpp rename to src/travelling_thief/solution.cpp diff --git a/travellingthiefsolver/travelling_thief/solution2instances.cpp b/src/travelling_thief/solution2instances.cpp similarity index 100% rename from travellingthiefsolver/travelling_thief/solution2instances.cpp rename to src/travelling_thief/solution2instances.cpp diff --git a/travellingthiefsolver/travelling_thief/utils.cpp b/src/travelling_thief/utils.cpp similarity index 100% rename from travellingthiefsolver/travelling_thief/utils.cpp rename to src/travelling_thief/utils.cpp diff --git a/src/travelling_while_packing/CMakeLists.txt b/src/travelling_while_packing/CMakeLists.txt new file mode 100644 index 0000000..736c2c8 --- /dev/null +++ b/src/travelling_while_packing/CMakeLists.txt @@ -0,0 +1,23 @@ +add_library(TravellingThiefSolver_travelling_while_packing) +target_sources(TravellingThiefSolver_travelling_while_packing PRIVATE + instance.cpp + instance_builder.cpp + solution.cpp + algorithm_formatter.cpp) +target_include_directories(TravellingThiefSolver_travelling_while_packing PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_travelling_while_packing PUBLIC + OptimizationTools::containers + TravelingSalesmanSolver::distances) +add_library(TravellingThiefSolver::knapsack ALIAS TravellingThiefSolver_travelling_while_packing) + +add_subdirectory(algorithms) + +add_executable(TravellingThiefSolver_travelling_while_packing_main) +target_sources(TravellingThiefSolver_travelling_while_packing_main PRIVATE + main.cpp) +target_link_libraries(TravellingThiefSolver_travelling_while_packing_main PUBLIC + TravellingThiefSolver_travelling_while_packing_local_search + Boost::program_options) +set_target_properties(TravellingThiefSolver_travelling_while_packing_main PROPERTIES OUTPUT_NAME "travellingthiefsolver_travelling_while_packing") +install(TARGETS TravellingThiefSolver_travelling_while_packing_main) diff --git a/travellingthiefsolver/travelling_while_packing/algorithm_formatter.cpp b/src/travelling_while_packing/algorithm_formatter.cpp similarity index 100% rename from travellingthiefsolver/travelling_while_packing/algorithm_formatter.cpp rename to src/travelling_while_packing/algorithm_formatter.cpp diff --git a/src/travelling_while_packing/algorithms/CMakeLists.txt b/src/travelling_while_packing/algorithms/CMakeLists.txt new file mode 100644 index 0000000..c0f07b8 --- /dev/null +++ b/src/travelling_while_packing/algorithms/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(TravellingThiefSolver_travelling_while_packing_local_search) +target_sources(TravellingThiefSolver_travelling_while_packing_local_search PRIVATE + local_search.cpp) +target_include_directories(TravellingThiefSolver_travelling_while_packing_local_search PUBLIC + ${PROJECT_SOURCE_DIR}/include) +target_link_libraries(TravellingThiefSolver_travelling_while_packing_local_search PUBLIC + TravellingThiefSolver_travelling_while_packing + LocalSearchSolver::localsearchsolver) +add_library(TravellingThiefSolver::travelling_while_packing::local_search ALIAS TravellingThiefSolver_travelling_while_packing_local_search) diff --git a/travellingthiefsolver/travelling_while_packing/algorithms/local_search.cpp b/src/travelling_while_packing/algorithms/local_search.cpp similarity index 100% rename from travellingthiefsolver/travelling_while_packing/algorithms/local_search.cpp rename to src/travelling_while_packing/algorithms/local_search.cpp diff --git a/travellingthiefsolver/travelling_while_packing/instance.cpp b/src/travelling_while_packing/instance.cpp similarity index 100% rename from travellingthiefsolver/travelling_while_packing/instance.cpp rename to src/travelling_while_packing/instance.cpp diff --git a/travellingthiefsolver/travelling_while_packing/instance_builder.cpp b/src/travelling_while_packing/instance_builder.cpp similarity index 100% rename from travellingthiefsolver/travelling_while_packing/instance_builder.cpp rename to src/travelling_while_packing/instance_builder.cpp diff --git a/travellingthiefsolver/travelling_while_packing/main.cpp b/src/travelling_while_packing/main.cpp similarity index 100% rename from travellingthiefsolver/travelling_while_packing/main.cpp rename to src/travelling_while_packing/main.cpp diff --git a/travellingthiefsolver/travelling_while_packing/solution.cpp b/src/travelling_while_packing/solution.cpp similarity index 100% rename from travellingthiefsolver/travelling_while_packing/solution.cpp rename to src/travelling_while_packing/solution.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..d5ae73a --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,8 @@ +enable_testing() + +include(GoogleTest) + +add_subdirectory(packing_while_travelling) +add_subdirectory(thief_orienteering) +add_subdirectory(travelling_thief) +add_subdirectory(travelling_while_packing) diff --git a/test/packing_while_travelling/CMakeLists.txt b/test/packing_while_travelling/CMakeLists.txt new file mode 100644 index 0000000..24c12bf --- /dev/null +++ b/test/packing_while_travelling/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(algorithms) diff --git a/travellingthiefsolver/BUILD b/test/packing_while_travelling/algorithms/CMakeLists.txt similarity index 100% rename from travellingthiefsolver/BUILD rename to test/packing_while_travelling/algorithms/CMakeLists.txt diff --git a/test/thief_orienteering/CMakeLists.txt b/test/thief_orienteering/CMakeLists.txt new file mode 100644 index 0000000..24c12bf --- /dev/null +++ b/test/thief_orienteering/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(algorithms) diff --git a/test/thief_orienteering/algorithms/CMakeLists.txt b/test/thief_orienteering/algorithms/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/travelling_thief/CMakeLists.txt b/test/travelling_thief/CMakeLists.txt new file mode 100644 index 0000000..24c12bf --- /dev/null +++ b/test/travelling_thief/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(algorithms) diff --git a/test/travelling_thief/algorithms/CMakeLists.txt b/test/travelling_thief/algorithms/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/travelling_while_packing/CMakeLists.txt b/test/travelling_while_packing/CMakeLists.txt new file mode 100644 index 0000000..24c12bf --- /dev/null +++ b/test/travelling_while_packing/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(algorithms) diff --git a/test/travelling_while_packing/algorithms/CMakeLists.txt b/test/travelling_while_packing/algorithms/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/travellingthiefsolver/packing_while_travelling/BUILD b/travellingthiefsolver/packing_while_travelling/BUILD deleted file mode 100644 index 2bac6db..0000000 --- a/travellingthiefsolver/packing_while_travelling/BUILD +++ /dev/null @@ -1,47 +0,0 @@ -load("//travellingthiefsolver:variables.bzl", "STDCPP") - -cc_library( - name = "packing_while_travelling", - hdrs = [ - "instance.hpp", - "instance_builder.hpp", - "solution.hpp", - "solution_builder.hpp", - "utils.hpp", - "reduction.hpp", - "algorithm.hpp", - "algorithm_formatter.hpp", - ], - srcs = [ - "instance.cpp", - "instance_builder.cpp", - "solution.cpp", - "solution_builder.cpp", - "utils.cpp", - "reduction.cpp", - "algorithm.cpp", - "algorithm_formatter.cpp", - ], - deps = [ - "@optimizationtools//optimizationtools/utils:utils", - "@optimizationtools//optimizationtools/containers:containers", - ], - visibility = ["//visibility:public"], -) - -cc_binary( - name = "main", - srcs = ["main.cpp"], - deps = [ - "//travellingthiefsolver/packing_while_travelling/algorithms:greedy", - "//travellingthiefsolver/packing_while_travelling/algorithms:sequential_value_correction", - "//travellingthiefsolver/packing_while_travelling/algorithms:dynamic_programming", - "//travellingthiefsolver/packing_while_travelling/algorithms:efficient_local_search", - "//travellingthiefsolver/packing_while_travelling/algorithms:large_neighborhood_search", - "@boost//:program_options", - ], - linkopts = select({ - "@bazel_tools//src/conditions:windows": [], - "//conditions:default": ["-lpthread"], - }), -) diff --git a/travellingthiefsolver/packing_while_travelling/algorithms/BUILD b/travellingthiefsolver/packing_while_travelling/algorithms/BUILD deleted file mode 100644 index 8a799a8..0000000 --- a/travellingthiefsolver/packing_while_travelling/algorithms/BUILD +++ /dev/null @@ -1,52 +0,0 @@ -cc_library( - name = "greedy", - hdrs = ["greedy.hpp"], - srcs = ["greedy.cpp"], - deps = ["//travellingthiefsolver/packing_while_travelling:packing_while_travelling"], - visibility = ["//visibility:public"], -) - -cc_library( - name = "sequential_value_correction", - hdrs = ["sequential_value_correction.hpp"], - srcs = ["sequential_value_correction.cpp"], - deps = [ - "//travellingthiefsolver/packing_while_travelling:packing_while_travelling", - "@knapsacksolver//knapsacksolver/knapsack/algorithms:dynamic_programming_primal_dual", - ], - visibility = ["//visibility:public"], -) - -cc_library( - name = "dynamic_programming", - hdrs = ["dynamic_programming.hpp"], - srcs = ["dynamic_programming.cpp"], - deps = [ - "//travellingthiefsolver/packing_while_travelling:packing_while_travelling", - ], - visibility = ["//visibility:public"], -) - -cc_library( - name = "efficient_local_search", - hdrs = ["efficient_local_search.hpp"], - srcs = ["efficient_local_search.cpp"], - deps = [ - ":sequential_value_correction", - "//travellingthiefsolver/packing_while_travelling:packing_while_travelling", - ], - visibility = ["//visibility:public"], -) - -cc_library( - name = "large_neighborhood_search", - hdrs = ["large_neighborhood_search.hpp"], - srcs = ["large_neighborhood_search.cpp"], - deps = [ - ":sequential_value_correction", - "//travellingthiefsolver/packing_while_travelling/algorithms:greedy", - "//travellingthiefsolver/packing_while_travelling:packing_while_travelling", - "@knapsacksolver//knapsacksolver/knapsack/algorithms:dynamic_programming_primal_dual", - ], - visibility = ["//visibility:public"], -) diff --git a/travellingthiefsolver/thief_orienteering/BUILD b/travellingthiefsolver/thief_orienteering/BUILD deleted file mode 100644 index 425cac4..0000000 --- a/travellingthiefsolver/thief_orienteering/BUILD +++ /dev/null @@ -1,50 +0,0 @@ -load("//travellingthiefsolver:variables.bzl", "STDCPP") - -cc_library( - name = "thief_orienteering", - hdrs = [ - "instance.hpp", - "instance_builder.hpp", - "solution.hpp", - "algorithm_formatter.hpp", - ], - srcs = [ - "instance.cpp", - "instance_builder.cpp", - "solution.cpp", - "algorithm_formatter.cpp", - ], - deps = [ - "//travellingthiefsolver/packing_while_travelling:packing_while_travelling", - "//travellingthiefsolver/travelling_while_packing:travelling_while_packing", - "@optimizationtools//optimizationtools/utils:utils", - "@optimizationtools//optimizationtools/containers:containers", - "@travelingsalesmansolver//travelingsalesmansolver/distances:distances", - "@travelingsalesmansolver//travelingsalesmansolver:travelingsalesmansolver", - "@travelingsalesmansolver//travelingsalesmansolver/algorithms:lkh", - ], - visibility = ["//visibility:public"], -) - -cc_binary( - name = "main", - srcs = ["main.cpp"], - deps = [ - "//travellingthiefsolver/thief_orienteering/algorithms:tree_search", - "//travellingthiefsolver/thief_orienteering/algorithms:local_search", - "@boost//:program_options", - ], - linkopts = select({ - "@bazel_tools//src/conditions:windows": [], - "//conditions:default": ["-lpthread"], - }), -) - -cc_binary( - name = "checker", - srcs = ["checker.cpp"], - deps = [ - ":thief_orienteering", - "@boost//:program_options", - ], -) diff --git a/travellingthiefsolver/thief_orienteering/algorithms/BUILD b/travellingthiefsolver/thief_orienteering/algorithms/BUILD deleted file mode 100644 index 520332a..0000000 --- a/travellingthiefsolver/thief_orienteering/algorithms/BUILD +++ /dev/null @@ -1,21 +0,0 @@ -cc_library( - name = "tree_search", - hdrs = ["tree_search.hpp"], - srcs = ["tree_search.cpp"], - deps = [ - "//travellingthiefsolver/thief_orienteering:thief_orienteering", - "@treesearchsolver//treesearchsolver:treesearchsolver", - ], - visibility = ["//visibility:public"], -) - -cc_library( - name = "local_search", - hdrs = ["local_search.hpp"], - srcs = ["local_search.cpp"], - deps = [ - "//travellingthiefsolver/thief_orienteering:thief_orienteering", - "@localsearchsolver//localsearchsolver:localsearchsolver", - ], - visibility = ["//visibility:public"], -) diff --git a/travellingthiefsolver/travelling_thief/BUILD b/travellingthiefsolver/travelling_thief/BUILD deleted file mode 100644 index b583b26..0000000 --- a/travellingthiefsolver/travelling_thief/BUILD +++ /dev/null @@ -1,69 +0,0 @@ -load("//travellingthiefsolver:variables.bzl", "STDCPP") - -cc_library( - name = "travelling_thief", - hdrs = [ - "instance.hpp", - "instance_builder.hpp", - "solution.hpp", - "utils.hpp", - "algorithm_formatter.hpp", - ], - srcs = [ - "instance.cpp", - "instance_builder.cpp", - "solution.cpp", - "utils.cpp", - "algorithm_formatter.cpp", - ], - deps = [ - "//travellingthiefsolver/packing_while_travelling:packing_while_travelling", - "//travellingthiefsolver/travelling_while_packing:travelling_while_packing", - "@optimizationtools//optimizationtools/utils:utils", - "@optimizationtools//optimizationtools/containers:containers", - "@travelingsalesmansolver//travelingsalesmansolver/distances:distances", - "@travelingsalesmansolver//travelingsalesmansolver:travelingsalesmansolver", - "@travelingsalesmansolver//travelingsalesmansolver/algorithms:lkh", - ], - visibility = ["//visibility:public"], -) - -cc_binary( - name = "main", - srcs = ["main.cpp"], - deps = [ - "//travellingthiefsolver/travelling_thief/algorithms:tree_search", - "//travellingthiefsolver/travelling_thief/algorithms:local_search", - "//travellingthiefsolver/travelling_thief/algorithms:efficient_local_search", - "//travellingthiefsolver/travelling_thief/algorithms:iterative_tsp_pwt", - "//travellingthiefsolver/travelling_thief/algorithms:iterative_tsp_pwt_ttp", - "@boost//:program_options", - ], - linkopts = select({ - "@bazel_tools//src/conditions:windows": [], - "//conditions:default": ["-lpthread"], - }), -) - -cc_binary( - name = "checker", - srcs = ["checker.cpp"], - deps = [ - ":travelling_thief", - "@boost//:program_options", - ], -) - -cc_binary( - name = "solution2instances", - srcs = ["solution2instances.cpp"], - deps = [ - ":travelling_thief", - "@boost//:program_options", - ], - linkopts = select({ - "@bazel_tools//src/conditions:windows": [], - "//conditions:default": ["-lpthread"], - }), -) - diff --git a/travellingthiefsolver/travelling_thief/algorithms/BUILD b/travellingthiefsolver/travelling_thief/algorithms/BUILD deleted file mode 100644 index 57f39c2..0000000 --- a/travellingthiefsolver/travelling_thief/algorithms/BUILD +++ /dev/null @@ -1,62 +0,0 @@ -cc_library( - name = "tree_search", - hdrs = ["tree_search.hpp"], - srcs = ["tree_search.cpp"], - deps = [ - "//travellingthiefsolver/travelling_thief:travelling_thief", - "@treesearchsolver//treesearchsolver:treesearchsolver", - ], - visibility = ["//visibility:public"], -) - -cc_library( - name = "local_search", - hdrs = ["local_search.hpp"], - srcs = ["local_search.cpp"], - deps = [ - "//travellingthiefsolver/travelling_thief:travelling_thief", - "//travellingthiefsolver/packing_while_travelling:packing_while_travelling", - "@localsearchsolver//localsearchsolver:localsearchsolver", - ], - visibility = ["//visibility:public"], -) - -cc_library( - name = "efficient_local_search", - hdrs = ["efficient_local_search.hpp"], - srcs = ["efficient_local_search.cpp"], - deps = [ - "//travellingthiefsolver/travelling_thief:travelling_thief", - "//travellingthiefsolver/packing_while_travelling:packing_while_travelling", - "//travellingthiefsolver/packing_while_travelling/algorithms:sequential_value_correction", - "//travellingthiefsolver/packing_while_travelling/algorithms:efficient_local_search", - "@travelingsalesmansolver//travelingsalesmansolver/algorithms:lkh", - "@localsearchsolver//localsearchsolver:localsearchsolver", - ], - visibility = ["//visibility:public"], -) - -cc_library( - name = "iterative_tsp_pwt", - hdrs = ["iterative_tsp_pwt.hpp"], - srcs = ["iterative_tsp_pwt.cpp"], - deps = [ - "//travellingthiefsolver/travelling_thief:travelling_thief", - "//travellingthiefsolver/packing_while_travelling/algorithms:sequential_value_correction", - "//travellingthiefsolver/packing_while_travelling/algorithms:efficient_local_search", - ], - visibility = ["//visibility:public"], -) - -cc_library( - name = "iterative_tsp_pwt_ttp", - hdrs = ["iterative_tsp_pwt_ttp.hpp"], - srcs = ["iterative_tsp_pwt_ttp.cpp"], - deps = [ - "//travellingthiefsolver/travelling_thief:travelling_thief", - ":efficient_local_search", - "//travellingthiefsolver/packing_while_travelling/algorithms:sequential_value_correction", - "//travellingthiefsolver/packing_while_travelling/algorithms:efficient_local_search", - ], - visibility = ["//visibility:public"], -) diff --git a/travellingthiefsolver/travelling_while_packing/BUILD b/travellingthiefsolver/travelling_while_packing/BUILD deleted file mode 100644 index 8eb8afe..0000000 --- a/travellingthiefsolver/travelling_while_packing/BUILD +++ /dev/null @@ -1,35 +0,0 @@ -load("//travellingthiefsolver:variables.bzl", "STDCPP") - -cc_library( - name = "travelling_while_packing", - hdrs = [ - "instance.hpp", - "instance_builder.hpp", - "solution.hpp", - "algorithm_formatter.hpp", - ], - srcs = [ - "instance.cpp", - "instance_builder.cpp", - "solution.cpp", - "algorithm_formatter.cpp", - ], - deps = [ - "@optimizationtools//optimizationtools/containers:containers", - "@travelingsalesmansolver//travelingsalesmansolver/distances:distances", - ], - visibility = ["//visibility:public"], -) - -cc_binary( - name = "main", - srcs = ["main.cpp"], - deps = [ - "//travellingthiefsolver/travelling_while_packing/algorithms:local_search", - "@boost//:program_options", - ], - linkopts = select({ - "@bazel_tools//src/conditions:windows": [], - "//conditions:default": ["-lpthread"], - }), -) diff --git a/travellingthiefsolver/travelling_while_packing/algorithms/BUILD b/travellingthiefsolver/travelling_while_packing/algorithms/BUILD deleted file mode 100644 index 26ed701..0000000 --- a/travellingthiefsolver/travelling_while_packing/algorithms/BUILD +++ /dev/null @@ -1,10 +0,0 @@ -cc_library( - name = "local_search", - hdrs = ["local_search.hpp"], - srcs = ["local_search.cpp"], - deps = [ - "//travellingthiefsolver/travelling_while_packing:travelling_while_packing", - "@localsearchsolver//localsearchsolver:localsearchsolver", - ], - visibility = ["//visibility:public"], -) diff --git a/travellingthiefsolver/variables.bzl b/travellingthiefsolver/variables.bzl deleted file mode 100644 index 18388a7..0000000 --- a/travellingthiefsolver/variables.bzl +++ /dev/null @@ -1,4 +0,0 @@ -STDCPP = select({ - "@bazel_tools//src/conditions:windows": ['/std:c++latest'], - "//conditions:default": ["-std=c++14"],}) -