Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ test/*.json

# venvs
*.lock*
dist/*
uv.lock
*.egg
*.egg-info/
*.whl
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ clean: clean-doc clean-build clean-examples

# Build a distribution in ./dist
build:
$(PYTHON) setup.py sdist
uv build

doc:
$(MAKE) -C ${DOCDIR} docs
Expand All @@ -82,12 +82,12 @@ doc:
# Publish to testpypi
# Will echo the commands to actually publish to be run to publish to actual PyPi
# This is done to prevent accidental publishing but provide the same conveniences
publish: clean-build build
publish: clean build
$(PIP) install twine
$(PYTHON) -m twine upload --verbose --repository testpypi ${DIST}/*
@echo
@echo "Test with the following line:"
@echo "pip install --index-url https://test.pypi.org/simple/ dacbench"
@echo
@echo "Once you have decided it works, publish to actual pypi with"
@echo "python -m twine upload dist/*"
@echo "python -m twine upload dist/*"
2 changes: 1 addition & 1 deletion dacbench/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dacbench.abstract_benchmark import AbstractBenchmark
from dacbench.abstract_env import AbstractEnv, AbstractMADACEnv

__all__ = ["AbstractEnv", "AbstractMADACEnv", "AbstractBenchmark"]
__all__ = ["AbstractBenchmark", "AbstractEnv", "AbstractMADACEnv"]

from gymnasium.envs.registration import register

Expand Down
4 changes: 2 additions & 2 deletions dacbench/abstract_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ def reset_(
if scheme is None:
scheme = options.get("scheme", self.instance_updates)
if instance is None:
instance = options.get("instance", None)
instance = options.get("instance")
if instance_id is None:
instance_id = options.get("instance_id", None)
instance_id = options.get("instance_id")
self.use_next_instance(instance, instance_id, scheme=scheme)

def use_next_instance(self, instance=None, instance_id=None, scheme=None):
Expand Down
2 changes: 1 addition & 1 deletion dacbench/agents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from dacbench.agents.generic_agent import GenericAgent
from dacbench.agents.simple_agents import RandomAgent, StaticAgent

__all__ = ["StaticAgent", "RandomAgent", "GenericAgent", "DynamicRandomAgent"]
__all__ = ["DynamicRandomAgent", "GenericAgent", "RandomAgent", "StaticAgent"]
4 changes: 2 additions & 2 deletions dacbench/benchmarks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from dacbench.benchmarks.toysgd_benchmark import ToySGDBenchmark

__all__ = [
"LubyBenchmark",
"FunctionApproximationBenchmark",
"LubyBenchmark",
"ToySGDBenchmark",
# "FastDownwardBenchmark",
]
Expand All @@ -28,7 +28,7 @@
"please follow the installation guide."
)

sgd_spec = importlib.util.find_spec("torch")
sgd_spec = importlib.util.find_spec("torchvision")
found = sgd_spec is not None
if found:
from dacbench.benchmarks.sgd_benchmark import SGDBenchmark
Expand Down
25 changes: 24 additions & 1 deletion dacbench/benchmarks/function_approximation_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ def __init__(self, config_path=None, config=None):

for key in FUNCTION_APPROXIMATION_DEFAULTS:
if key not in self.config:
self.config[key] = FUNCTION_APPROXIMATION_DEFAULTS[key]
if key == "observation_space_args" and "config_space" in self.config:
obs_length = 1 + len(self.config["config_space"]) * 4
self.config[key] = [
np.array([-np.inf for _ in range(obs_length)]),
np.array([np.inf for _ in range(obs_length)]),
]
else:
self.config[key] = FUNCTION_APPROXIMATION_DEFAULTS[key]

def get_environment(self):
"""Return Function Approximation env with current configuration.
Expand Down Expand Up @@ -197,6 +204,10 @@ def get_benchmark(self, dimension=None, seed=0):
"Slope (dimension 1)",
"Action",
]
self.config.observation_space_args = [
np.array([-np.inf for _ in range(4)]),
np.array([np.inf for _ in range(4)]),
]
if dimension == 2:
self.config.instance_set_path = "sigmoid_2D3M_train.csv"
self.config.test_set_path = "sigmoid_2D3M_test.csv"
Expand All @@ -220,6 +231,10 @@ def get_benchmark(self, dimension=None, seed=0):
"Action dim 1",
"Action dim 2",
]
self.config.observation_space_args = [
np.array([-np.inf for _ in range(7)]),
np.array([np.inf for _ in range(7)]),
]
if dimension == 3:
self.config.instance_set_path = "sigmoid_3D3M_train.csv"
self.config.test_set_path = "sigmoid_3D3M_test.csv"
Expand Down Expand Up @@ -250,6 +265,10 @@ def get_benchmark(self, dimension=None, seed=0):
"Action 2",
"Action 3",
]
self.config.observation_space_args = [
np.array([-np.inf for _ in range(10)]),
np.array([np.inf for _ in range(10)]),
]
if dimension == 5:
self.config.instance_set_path = "sigmoid_5D3M_train.csv"
self.config.test_set_path = "sigmoid_5D3M_test.csv"
Expand Down Expand Up @@ -294,6 +313,10 @@ def get_benchmark(self, dimension=None, seed=0):
"Action 4",
"Action 5",
]
self.config.observation_space_args = [
np.array([-np.inf for _ in range(16)]),
np.array([np.inf for _ in range(16)]),
]
self.config.seed = seed
self.read_instance_set()
self.read_instance_set(test=True)
Expand Down
8 changes: 4 additions & 4 deletions dacbench/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
from dacbench.envs.toysgd import ToySGDEnv, ToySGDInstance

__all__ = [
"LubyEnv",
"LubyInstance",
"luby_gen",
"FunctionApproximationEnv",
"FunctionApproximationInstance",
"LubyEnv",
"LubyInstance",
"TheoryEnv",
# "FastDownwardEnv",
"ToySGDEnv",
"ToySGDInstance",
"TheoryEnv",
"luby_gen",
]

modcma_spec = importlib.util.find_spec("modcma")
Expand Down
7 changes: 2 additions & 5 deletions dacbench/envs/theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,8 @@ def crossover(
locs_x[locs_xprime] = False
obj = self.get_fitness_after_crossover(xprime, locs_x, locs_xprime)

if (
obj not in (self.fitness, xprime.fitness)
or (
not np.array_equal(xprime.data[locs_xprime], self.data[locs_xprime])
)
if obj not in (self.fitness, xprime.fitness) or (
(not np.array_equal(xprime.data[locs_xprime], self.data[locs_xprime]))
and (not np.array_equal(self.data[locs_x], xprime.data[locs_x]))
):
n_evals += 1
Expand Down
8 changes: 4 additions & 4 deletions dacbench/wrappers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"ActionFrequencyWrapper",
"EpisodeTimeWrapper",
"InstanceSamplingWrapper",
"MultiDiscreteActionWrapper",
"ObservationWrapper",
"PerformanceTrackingWrapper",
"PolicyProgressWrapper",
"PolicyProgressWrapper",
"RewardNoiseWrapper",
"StateTrackingWrapper",
"PerformanceTrackingWrapper",
"PolicyProgressWrapper",
"ObservationWrapper",
"MultiDiscreteActionWrapper",
]
13 changes: 7 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[build-system]
requires = ["setuptools>=70", "wheel"]
requires = ["setuptools>=75.1.0", "wheel", "setuptools_scm>3"]
build-backend = "setuptools.build_meta"

[project]
name = "DACBench"
version = "0.3.0"
version = "0.4.0"
description = "Dynamic Algorithm Configuration Benchmark"
readme = "README.md"
license = { file = "LICENSE" }
Expand All @@ -27,17 +27,18 @@ classifiers = [
]
requires-python = ">=3.10"
dependencies = [
"gymnasium==0.29.1",
"imageio==2.35.1",
"gymnasium<=0.29.1",
"imageio~=2.35.1",
"numpy==1.26.4",
"pandas==2.2.3",
"matplotlib==3.9.2",
"seaborn==0.13.2",
"configspace==1.2.0",
"configspace~=1.2.1",
"scikit-learn==1.5.2",
"scipy==1.14.1",
"jupyter==1.0.0",
"Pyro4==4.82"]
"Pyro4==4.82",
"ioh==0.3.17"]

[project.urls]
Homepage = "https://github.com/automl/DACBench"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_other_requirements():


setup(
version="0.2.1",
version="0.3.0",
packages=find_packages(
exclude=[
"tests",
Expand Down
Binary file added wheels/setuptools-75.1.0-py3-none-any.whl
Binary file not shown.
Binary file added wheels/wheel-0.44.0-py3-none-any.whl
Binary file not shown.