Skip to content

Commit

Permalink
Add test script
Browse files Browse the repository at this point in the history
  • Loading branch information
fontanf committed Apr 4, 2024
1 parent 7d1dd0b commit c18d261
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 332 deletions.
31 changes: 0 additions & 31 deletions .ycm_extra_conf.py

This file was deleted.

10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ In the set packing problem solved, elements may be covered multiple times and th

## Usage (command line)

Download and uncompress the instances in the `data/` folder:

https://drive.google.com/file/d/1lhbfd_ayrIUEUgGJ33YH-9_QrCjwGO6Y/view?usp=sharing

Compile:
```shell
bazel build -- //...
Expand All @@ -45,6 +41,12 @@ bazel build --define coinor=true -- //...
bazel build --define gurobi=true -- //...
```

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

Run:

```shell
Expand Down
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cc_library(
git_repository(
name = "optimizationtools",
remote = "https://github.com/fontanf/optimizationtools.git",
commit = "49a279e7df70b21f8c62cb89ec58e363c053ead8",
commit = "48b4c00424ef2aee31e5d139c16c33d0f8deac7e",
)

local_repository(
Expand All @@ -45,7 +45,7 @@ local_repository(
git_repository(
name = "localsearchsolver",
remote = "https://github.com/fontanf/localsearchsolver.git",
commit = "43572d963b158adcaeeda5c64f253f4c5c394969",
commit = "b49b95480671a886afb8159f565c3673cce2dd03",
)

http_archive(
Expand Down
6 changes: 0 additions & 6 deletions data/BUILD

This file was deleted.

289 changes: 0 additions & 289 deletions data/data.csv

This file was deleted.

26 changes: 26 additions & 0 deletions scripts/download_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import argparse
import gdown
import os
import shutil
import pathlib


parser = argparse.ArgumentParser(description='')
parser.add_argument(
"-d", "--data",
type=str,
nargs='*',
help='')
args = parser.parse_args()

if args.data is None:
gdown.download(id="1STls7xEsIr3osMFbr1xJGQwztPA9ZAX5", output="data.7z")
os.system("7z x data.7z")
pathlib.Path("data.7z").unlink()
shutil.copytree("set_covering", "data", dirs_exist_ok=True)

if args.data is not None and "gecco2020" in args.data:
gdown.download(id="1PvdFc16nv0_MEs6kEDnFsy0mHRwOJ03X", output="data.7z")
os.system("7z x data.7z")
pathlib.Path("data.7z").unlink()
shutil.copytree("set_covering_gecco2020", "data", dirs_exist_ok=True)
58 changes: 58 additions & 0 deletions scripts/run_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import argparse
import sys
import os

parser = argparse.ArgumentParser(description='')
parser.add_argument('directory')
parser.add_argument(
"-t", "--tests",
type=str,
nargs='*',
help='')

args = parser.parse_args()


main = os.path.join(
"bazel-bin",
"setcoveringsolver",
"setcovering",
"main")


if args.tests is None or "greedy" in args.tests:
print("Greedy")
print("------")
print()

greedy_data = [
(os.path.join("beasley1987", "scpa1.txt"), "orlibrary"),
(os.path.join("beasley1987", "scpb2.txt"), "orlibrary"),
(os.path.join("beasley1987", "scpc3.txt"), "orlibrary"),
(os.path.join("beasley1987", "scpd4.txt"), "orlibrary"),
(os.path.join("beasley1987", "scpe5.txt"), "orlibrary") ]

for instance, instance_format in greedy_data:
instance_path = os.path.join(
"data",
instance)
json_output_path = os.path.join(
args.directory,
"greedy",
instance + ".json")
if not os.path.exists(os.path.dirname(json_output_path)):
os.makedirs(os.path.dirname(json_output_path))
command = (
main
+ " --verbosity-level 1"
+ " --input \"" + instance_path + "\""
+ " --format \"" + instance_format + "\""
+ " --algorithm greedy"
+ " --output \"" + json_output_path + "\"")
print(command)
status = os.system(command)
if status != 0:
sys.exit(1)
print()
print()
print()

0 comments on commit c18d261

Please sign in to comment.