diff --git a/.gitignore b/.gitignore index c29207a11..96be72089 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,8 @@ test/*.json # venvs *.lock* +dist/* +uv.lock +*.egg +*.egg-info/ +*.whl diff --git a/Makefile b/Makefile index febe16f2f..8f7b7a034 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -82,7 +82,7 @@ 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 @@ -90,4 +90,4 @@ publish: clean-build build @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/*" \ No newline at end of file diff --git a/dacbench/__init__.py b/dacbench/__init__.py index 8e2224921..613596d5f 100644 --- a/dacbench/__init__.py +++ b/dacbench/__init__.py @@ -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 diff --git a/dacbench/abstract_env.py b/dacbench/abstract_env.py index 123e0dc79..bb2110abe 100644 --- a/dacbench/abstract_env.py +++ b/dacbench/abstract_env.py @@ -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): diff --git a/dacbench/agents/__init__.py b/dacbench/agents/__init__.py index 8211fc619..0ac4c2dd1 100644 --- a/dacbench/agents/__init__.py +++ b/dacbench/agents/__init__.py @@ -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"] diff --git a/dacbench/benchmarks/__init__.py b/dacbench/benchmarks/__init__.py index dd55503ae..726dc1740 100644 --- a/dacbench/benchmarks/__init__.py +++ b/dacbench/benchmarks/__init__.py @@ -10,8 +10,8 @@ from dacbench.benchmarks.toysgd_benchmark import ToySGDBenchmark __all__ = [ - "LubyBenchmark", "FunctionApproximationBenchmark", + "LubyBenchmark", "ToySGDBenchmark", # "FastDownwardBenchmark", ] @@ -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 diff --git a/dacbench/benchmarks/function_approximation_benchmark.py b/dacbench/benchmarks/function_approximation_benchmark.py index b6c383eeb..7733acab3 100644 --- a/dacbench/benchmarks/function_approximation_benchmark.py +++ b/dacbench/benchmarks/function_approximation_benchmark.py @@ -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. @@ -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" @@ -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" @@ -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" @@ -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) diff --git a/dacbench/envs/__init__.py b/dacbench/envs/__init__.py index f9f508d57..334f777b5 100644 --- a/dacbench/envs/__init__.py +++ b/dacbench/envs/__init__.py @@ -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") diff --git a/dacbench/envs/theory.py b/dacbench/envs/theory.py index b5e872f00..a9e6e8ccc 100644 --- a/dacbench/envs/theory.py +++ b/dacbench/envs/theory.py @@ -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 diff --git a/dacbench/wrappers/__init__.py b/dacbench/wrappers/__init__.py index dd13698a0..0c3c78439 100644 --- a/dacbench/wrappers/__init__.py +++ b/dacbench/wrappers/__init__.py @@ -12,11 +12,11 @@ "ActionFrequencyWrapper", "EpisodeTimeWrapper", "InstanceSamplingWrapper", + "MultiDiscreteActionWrapper", + "ObservationWrapper", + "PerformanceTrackingWrapper", + "PolicyProgressWrapper", "PolicyProgressWrapper", "RewardNoiseWrapper", "StateTrackingWrapper", - "PerformanceTrackingWrapper", - "PolicyProgressWrapper", - "ObservationWrapper", - "MultiDiscreteActionWrapper", ] diff --git a/pyproject.toml b/pyproject.toml index 80dd25cf6..9c2b8ce73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" } @@ -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" diff --git a/setup.py b/setup.py index 74046109e..ca8aab328 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ def get_other_requirements(): setup( - version="0.2.1", + version="0.3.0", packages=find_packages( exclude=[ "tests", diff --git a/wheels/setuptools-75.1.0-py3-none-any.whl b/wheels/setuptools-75.1.0-py3-none-any.whl new file mode 100644 index 000000000..b7f887bd4 Binary files /dev/null and b/wheels/setuptools-75.1.0-py3-none-any.whl differ diff --git a/wheels/wheel-0.44.0-py3-none-any.whl b/wheels/wheel-0.44.0-py3-none-any.whl new file mode 100644 index 000000000..96431aa48 Binary files /dev/null and b/wheels/wheel-0.44.0-py3-none-any.whl differ