Skip to content

Commit

Permalink
unlink fd everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEimer committed Sep 30, 2024
1 parent f3ee4ce commit aab0ce4
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 22 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,5 @@ jobs:
run: |
git submodule update --init --recursive
uv pip install -e ".[dev, docs, all, example]"
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.10.2'
- name: Build fast-downward
run: ./dacbench/envs/rl-plan/fast-downward/build.py
- name: Run tests with pytest
run: /home/runner/work/DACBench/DACBench/.venv/bin/python -m pytest tests
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,14 @@ source .venv/bin/activate
git submodule update --init --recursive
make install
```
This command installs the base version of DACBench including the three small surrogate benchmarks and the option to install the FastDownward benchmark.
This command installs the base version of DACBench including the three small surrogate benchmarks.
For any other benchmark, you may use a singularity container as provided by us (see next section) or install it as an additional dependency. As an example,
to install the SGDBenchmark, run:

```
uv pip install dacbench[sgd]
```

To use FastDownward, you first need to build the solver itself. We recommend using
cmake version 3.10.2. The command is:
```
./dacbench/envs/rl-plan/fast-downward/build.py
```

You can also install all dependencies like so:
```
make install-dev
Expand Down
4 changes: 2 additions & 2 deletions dacbench/benchmarks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import importlib
import warnings

from dacbench.benchmarks.fast_downward_benchmark import FastDownwardBenchmark
# from dacbench.benchmarks.fast_downward_benchmark import FastDownwardBenchmark
from dacbench.benchmarks.function_approximation_benchmark import (
FunctionApproximationBenchmark,
)
Expand All @@ -13,7 +13,7 @@
"LubyBenchmark",
"FunctionApproximationBenchmark",
"ToySGDBenchmark",
"FastDownwardBenchmark",
# "FastDownwardBenchmark",
]

modcma_spec = importlib.util.find_spec("modcma")
Expand Down
4 changes: 2 additions & 2 deletions dacbench/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import importlib
import warnings

from dacbench.envs.fast_downward import FastDownwardEnv
# from dacbench.envs.fast_downward import FastDownwardEnv
from dacbench.envs.function_approximation import (
FunctionApproximationEnv,
FunctionApproximationInstance,
Expand All @@ -17,7 +17,7 @@
"luby_gen",
"FunctionApproximationEnv",
"FunctionApproximationInstance",
"FastDownwardEnv",
# "FastDownwardEnv",
"ToySGDEnv",
"ToySGDInstance",
"TheoryEnv",
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Welcome to DACBench's documentation!
source/benchmark_docs/function_approximation
source/benchmark_docs/luby
source/benchmark_docs/toy_sgd
source/benchmark_docs/fastdownward
source/benchmark_docs/theory
source/benchmark_docs/cma
source/benchmark_docs/sgd
Expand Down
3 changes: 0 additions & 3 deletions docs/source/benchmarks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ They are both based on artificial functions and real algorithms:
Learning the Luby sequence.
- :doc:`ToySGD <benchmark_docs/toy_sgd>` (Artificial Benchmark):
Controlling the learning rate in gradient descent.
- Toy version of the :doc:`FastDownward benchmark <benchmark_docs/fastdownward>`:
Heuristic selection for the FastDownward Planner with ground truth.
- :doc:`Theory benchmark <benchmark_docs/theory>` with ground truth:
RLS algorithm on the LeadingOnes problem.

Expand All @@ -30,7 +28,6 @@ Beyond these smaller scale problems we know a lot about, DACBench also contains
interpretable algorithms with larger scopes. These are oftentimes noisier, harder to debug
and more costly to run and thus present a real challenge for DAC algorithms:

* :doc:`FastDownward benchmark <benchmark_docs/fastdownward>`: Heuristic selection for the FastDownward Planner on competition tasks.
* :doc:`CMA-ES <benchmark_docs/cma>`: Step-size adpation and algorithm component selection for CMA-ES.
* :doc:`SGD-DL <benchmark_docs/sgd>`: Learning rate adaption for neural networks.

Expand Down
75 changes: 75 additions & 0 deletions tests/benchmarks/test_fd_benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import json
import os
import unittest
import pytest

from dacbench.benchmarks import FastDownwardBenchmark
from dacbench.envs import FastDownwardEnv


@pytest.mark.skip(reason="FD issues locally and remote make testing hard")
class TestFDBenchmark(unittest.TestCase):
def test_get_env(self):
bench = FastDownwardBenchmark()
env = bench.get_environment()
self.assertTrue(issubclass(type(env), FastDownwardEnv))

bench.config.instance_set_path = "../instance_sets/fast_downward/childsnack"
bench.read_instance_set()
env = bench.get_environment()
self.assertTrue(issubclass(type(env), FastDownwardEnv))

# TODO: This test breaks remote testing, possibly due to too many open ports.
# Should be investigated
# def test_scenarios(self):
# scenarios = [
# "fd_barman.json",
# # "fd_blocksworld.json",
# # "fd_visitall.json",
# # "fd_childsnack.json",
# # "fd_sokoban.json",
# # "fd_rovers.json",
# ]
# for s in scenarios:
# path = os.path.join("dacbench/additional_configs/fast_downward/", s)
# bench = FastDownwardBenchmark(path)
# self.assertTrue(bench.config is not None)
# env = bench.get_environment()
# state, info = env.reset()
# self.assertTrue(state is not None)
# self.assertTrue(info is not None)
# state, _, _, _, _ = env.step(0)
# self.assertTrue(state is not None)

def test_save_conf(self):
bench = FastDownwardBenchmark()
del bench.config["config_space"]
bench.save_config("test_conf.json")
with open("test_conf.json", "r") as fp:
recovered = json.load(fp)
for k in bench.config.keys():
self.assertTrue(k in recovered.keys())
os.remove("test_conf.json")

def test_read_instances(self):
bench = FastDownwardBenchmark()
bench.read_instance_set()
self.assertTrue(len(bench.config.instance_set.keys()) == 30)
self.assertTrue(type(bench.config.instance_set[0]) == str)
self.assertTrue(os.path.isfile(bench.config.instance_set[0]))
path = bench.config.instance_set[0]
bench2 = FastDownwardBenchmark()
env = bench2.get_environment()
self.assertTrue(type(env.instance_set[0]) == str)
self.assertTrue(len(env.instance_set.keys()) == 30)
self.assertTrue(path == env.instance_set[0])

def test_benchmark_env(self):
bench = FastDownwardBenchmark()
env = bench.get_benchmark()
self.assertTrue(issubclass(type(env), FastDownwardEnv))

def test_from_to_json(self):
bench = FastDownwardBenchmark()
restored_bench = FastDownwardBenchmark.from_json(bench.to_json())
self.assertEqual(bench, restored_bench)
3 changes: 2 additions & 1 deletion tests/envs/test_fast_downward.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

import unittest
import pytest

from dacbench import AbstractEnv
from dacbench.benchmarks.fast_downward_benchmark import FastDownwardBenchmark


@pytest.mark.skip(reason="FD issues locally and remote make testing hard")
class TestFDEnv(unittest.TestCase):
def make_env(self):
bench = FastDownwardBenchmark()
Expand Down

0 comments on commit aab0ce4

Please sign in to comment.