diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9daca3c..594f636 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,13 +9,14 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [ubuntu-latest] python-version: ["3.8"] steps: - name: Checkout code - uses: nschloe/action-cached-lfs-checkout@v1 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -23,7 +24,7 @@ jobs: - name: Download data run: | python3 -m pip install gdown - python3 scripts/download_data.py + python3 -u scripts/download_data.py - name: Build Linux run: bazel build -- //... if: matrix.os != 'windows-latest' @@ -31,9 +32,12 @@ jobs: run: bazel build --cxxopt=/MT -- //... if: matrix.os == 'windows-latest' - name: Run tests - run: python3 scripts/run_tests.py test_results + run: python3 -u scripts/run_tests.py test_results - name: Checkout main branch - run: git checkout main + run: | + git remote set-branches origin '*' + git fetch --depth 1 + git checkout main - name: Build Linux run: bazel build -- //... if: matrix.os != 'windows-latest' @@ -41,6 +45,6 @@ jobs: run: bazel build --cxxopt=/MT -- //... if: matrix.os == 'windows-latest' - name: Run tests - run: python3 scripts/run_tests.py test_results_ref + run: python3 -u scripts/run_tests.py test_results_ref - name: Process tests - run: python3 ./bazel-starobservationschedulingsolver/external/optimizationtools/scripts/process_tests.py --ref test_results_ref --new test_results + run: python3 -u ./bazel-starobservationschedulingsolver/external/optimizationtools/scripts/process_tests.py --ref test_results_ref --new test_results diff --git a/README.md b/README.md index ad06469..68348f3 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,11 @@ Compile: bazel build -- //... ``` +Download data: +```shell +python3 scripts/download_data.py +``` + Examples: ```shell diff --git a/scripts/download_data.py b/scripts/download_data.py index 5110452..47f1de9 100644 --- a/scripts/download_data.py +++ b/scripts/download_data.py @@ -2,10 +2,12 @@ import os import pathlib -gdown.download(id="1RzBH4LWSqHGdE-0SIpZZCluV6MLZ6b4f") -os.system("7z x star_observation_scheduling.7z -odata") -pathlib.Path("star_observation_scheduling.7z").unlink() -gdown.download(id="1ag21EFO0VzZlUccjTSVJ9tlT0uh7DbkS") -os.system("7z x flexible_star_observation_scheduling.7z -odata") -pathlib.Path("flexible_star_observation_scheduling.7z").unlink() +def download(id): + gdown.download(id=id, output="data.7z") + os.system("7z x data.7z -odata") + pathlib.Path("data.7z").unlink() + + +download("1RzBH4LWSqHGdE-0SIpZZCluV6MLZ6b4f") +download("1ag21EFO0VzZlUccjTSVJ9tlT0uh7DbkS") diff --git a/scripts/run_tests.py b/scripts/run_tests.py index fc584bb..979e042 100644 --- a/scripts/run_tests.py +++ b/scripts/run_tests.py @@ -1,79 +1,112 @@ +import argparse import sys import os -test_results_directory = sys.argv[1] +parser = argparse.ArgumentParser(description='') +parser.add_argument('directory') +parser.add_argument( + "-t", "--tests", + type=str, + nargs='*', + help='') -starobservationscheduling_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"), - os.path.join("catusse2016", "ins_400_71_4"), - os.path.join("catusse2016", "ins_400_71_5"), - os.path.join("catusse2016", "ins_600_107_1"), - os.path.join("catusse2016", "ins_600_107_2"), - os.path.join("catusse2016", "ins_600_107_3"), - os.path.join("catusse2016", "ins_600_107_4"), - os.path.join("catusse2016", "ins_600_107_5"), - os.path.join("catusse2016", "real.txt")] -starobservationscheduling_main = os.path.join( +args = parser.parse_args() + + +star_observation_scheduling_main = os.path.join( "bazel-bin", "starobservationschedulingsolver", "star_observation_scheduling", "main") -for instance in starobservationscheduling_data: - instance_path = os.path.join( - "data", - "star_observation_scheduling", - instance) - json_output_path = os.path.join( - test_results_directory, - "star_observation_scheduling", - instance + ".json") - if not os.path.exists(os.path.dirname(json_output_path)): - os.makedirs(os.path.dirname(json_output_path)) - command = ( - starobservationscheduling_main - + " --verbosity-level 1" - + " --input \"" + instance_path + "\"" - + " --algorithm column-generation" - + " --output \"" + json_output_path + "\"") - print(command) - os.system(command) + + +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 = [ + os.path.join("catusse2016", "ins_400_71_1"), + os.path.join("catusse2016", "ins_400_71_2"), + os.path.join("catusse2016", "ins_400_71_3"), + os.path.join("catusse2016", "ins_400_71_4"), + os.path.join("catusse2016", "ins_400_71_5"), + os.path.join("catusse2016", "ins_600_107_1"), + os.path.join("catusse2016", "ins_600_107_2"), + os.path.join("catusse2016", "ins_600_107_3"), + 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: + instance_path = os.path.join( + "data", + "star_observation_scheduling", + instance) + json_output_path = os.path.join( + args.directory, + "star_observation_scheduling", + instance + ".json") + if not os.path.exists(os.path.dirname(json_output_path)): + os.makedirs(os.path.dirname(json_output_path)) + command = ( + star_observation_scheduling_main + + " --verbosity-level 1" + + " --input \"" + instance_path + "\"" + + " --algorithm column-generation" + + " --output \"" + json_output_path + "\"") + print(command) + status = os.system(command) + if status != 0: + sys.exit(1) + print() + print() print() -starobservationscheduling_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"), - os.path.join("catusse2016_discrete_80", "ins_400_71_4"), - os.path.join("catusse2016_discrete_80", "ins_400_71_5"), - os.path.join("catusse2016_discrete_85", "ins_400_71_1"), - os.path.join("catusse2016_discrete_85", "ins_400_71_2"), - 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")] + flexible_star_observation_scheduling_main = os.path.join( "bazel-bin", "starobservationschedulingsolver", "flexible_star_observation_scheduling", "main") -for instance in starobservationscheduling_data: - instance_path = os.path.join( - "data", - "flexible_star_observation_scheduling", - instance) - json_output_path = os.path.join( - test_results_directory, - "flexible_star_observation_scheduling", - instance) - if not os.path.exists(os.path.dirname(json_output_path)): - os.makedirs(os.path.dirname(json_output_path)) - command = ( - flexible_star_observation_scheduling_main - + " --verbosity-level 1" - + " --input \"" + instance_path + "\"" - + " --algorithm column-generation" - + " --output \"" + json_output_path + "\"") - print(command) - os.system(command) + + +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 = [ + 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"), + os.path.join("catusse2016_discrete_80", "ins_400_71_4"), + os.path.join("catusse2016_discrete_80", "ins_400_71_5"), + os.path.join("catusse2016_discrete_85", "ins_400_71_1"), + os.path.join("catusse2016_discrete_85", "ins_400_71_2"), + 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: + instance_path = os.path.join( + "data", + "flexible_star_observation_scheduling", + instance) + json_output_path = os.path.join( + args.directory, + "flexible_star_observation_scheduling", + instance) + if not os.path.exists(os.path.dirname(json_output_path)): + os.makedirs(os.path.dirname(json_output_path)) + command = ( + flexible_star_observation_scheduling_main + + " --verbosity-level 1" + + " --input \"" + instance_path + "\"" + + " --algorithm column-generation" + + " --output \"" + json_output_path + "\"") + print(command) + status = os.system(command) + if status != 0: + sys.exit(1) + print() + print() print()