Skip to content

Commit

Permalink
Merge pull request #1 from fontanf/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
fontanf authored Apr 19, 2024
2 parents 7459ddc + feae450 commit fdfc12a
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 75 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,42 @@ 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:
python-version: ${{ matrix.python-version }}
- 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'
- name: Build Windows
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'
- name: Build Windows
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Compile:
bazel build -- //...
```

Download data:
```shell
python3 scripts/download_data.py
```

Examples:

```shell
Expand Down
14 changes: 8 additions & 6 deletions scripts/download_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
159 changes: 96 additions & 63 deletions scripts/run_tests.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit fdfc12a

Please sign in to comment.