Skip to content

Commit 7df65e9

Browse files
committed
slight dependency updates + cleanup on FA
1 parent 5c41d26 commit 7df65e9

15 files changed

+50
-29
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ clean: clean-doc clean-build clean-examples
7171

7272
# Build a distribution in ./dist
7373
build:
74-
$(PYTHON) setup.py sdist
74+
uv build
7575

7676
doc:
7777
$(MAKE) -C ${DOCDIR} docs
@@ -82,12 +82,12 @@ doc:
8282
# Publish to testpypi
8383
# Will echo the commands to actually publish to be run to publish to actual PyPi
8484
# This is done to prevent accidental publishing but provide the same conveniences
85-
publish: clean-build build
85+
publish: clean build
8686
$(PIP) install twine
8787
$(PYTHON) -m twine upload --verbose --repository testpypi ${DIST}/*
8888
@echo
8989
@echo "Test with the following line:"
9090
@echo "pip install --index-url https://test.pypi.org/simple/ dacbench"
9191
@echo
9292
@echo "Once you have decided it works, publish to actual pypi with"
93-
@echo "python -m twine upload dist/*"
93+
@echo "python -m twine upload dist/*"

dacbench/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from dacbench.abstract_benchmark import AbstractBenchmark
77
from dacbench.abstract_env import AbstractEnv, AbstractMADACEnv
88

9-
__all__ = ["AbstractEnv", "AbstractMADACEnv", "AbstractBenchmark"]
9+
__all__ = ["AbstractBenchmark", "AbstractEnv", "AbstractMADACEnv"]
1010

1111
from gymnasium.envs.registration import register
1212

dacbench/abstract_env.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ def reset_(
190190
if scheme is None:
191191
scheme = options.get("scheme", self.instance_updates)
192192
if instance is None:
193-
instance = options.get("instance", None)
193+
instance = options.get("instance")
194194
if instance_id is None:
195-
instance_id = options.get("instance_id", None)
195+
instance_id = options.get("instance_id")
196196
self.use_next_instance(instance, instance_id, scheme=scheme)
197197

198198
def use_next_instance(self, instance=None, instance_id=None, scheme=None):

dacbench/agents/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from dacbench.agents.generic_agent import GenericAgent
33
from dacbench.agents.simple_agents import RandomAgent, StaticAgent
44

5-
__all__ = ["StaticAgent", "RandomAgent", "GenericAgent", "DynamicRandomAgent"]
5+
__all__ = ["DynamicRandomAgent", "GenericAgent", "RandomAgent", "StaticAgent"]

dacbench/benchmarks/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
from dacbench.benchmarks.toysgd_benchmark import ToySGDBenchmark
1111

1212
__all__ = [
13-
"LubyBenchmark",
1413
"FunctionApproximationBenchmark",
14+
"LubyBenchmark",
1515
"ToySGDBenchmark",
1616
# "FastDownwardBenchmark",
1717
]
@@ -28,7 +28,7 @@
2828
"please follow the installation guide."
2929
)
3030

31-
sgd_spec = importlib.util.find_spec("torch")
31+
sgd_spec = importlib.util.find_spec("torchvision")
3232
found = sgd_spec is not None
3333
if found:
3434
from dacbench.benchmarks.sgd_benchmark import SGDBenchmark

dacbench/benchmarks/function_approximation_benchmark.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,14 @@ def __init__(self, config_path=None, config=None):
8282

8383
for key in FUNCTION_APPROXIMATION_DEFAULTS:
8484
if key not in self.config:
85-
self.config[key] = FUNCTION_APPROXIMATION_DEFAULTS[key]
85+
if key == "observation_space_args" and "config_space" in self.config:
86+
obs_length = 1 + len(self.config["config_space"]) * 4
87+
self.config[key] = [
88+
np.array([-np.inf for _ in range(obs_length)]),
89+
np.array([np.inf for _ in range(obs_length)]),
90+
]
91+
else:
92+
self.config[key] = FUNCTION_APPROXIMATION_DEFAULTS[key]
8693

8794
def get_environment(self):
8895
"""Return Function Approximation env with current configuration.
@@ -197,6 +204,10 @@ def get_benchmark(self, dimension=None, seed=0):
197204
"Slope (dimension 1)",
198205
"Action",
199206
]
207+
self.config.observation_space_args = [
208+
np.array([-np.inf for _ in range(4)]),
209+
np.array([np.inf for _ in range(4)]),
210+
]
200211
if dimension == 2:
201212
self.config.instance_set_path = "sigmoid_2D3M_train.csv"
202213
self.config.test_set_path = "sigmoid_2D3M_test.csv"
@@ -220,6 +231,10 @@ def get_benchmark(self, dimension=None, seed=0):
220231
"Action dim 1",
221232
"Action dim 2",
222233
]
234+
self.config.observation_space_args = [
235+
np.array([-np.inf for _ in range(7)]),
236+
np.array([np.inf for _ in range(7)]),
237+
]
223238
if dimension == 3:
224239
self.config.instance_set_path = "sigmoid_3D3M_train.csv"
225240
self.config.test_set_path = "sigmoid_3D3M_test.csv"
@@ -250,6 +265,10 @@ def get_benchmark(self, dimension=None, seed=0):
250265
"Action 2",
251266
"Action 3",
252267
]
268+
self.config.observation_space_args = [
269+
np.array([-np.inf for _ in range(10)]),
270+
np.array([np.inf for _ in range(10)]),
271+
]
253272
if dimension == 5:
254273
self.config.instance_set_path = "sigmoid_5D3M_train.csv"
255274
self.config.test_set_path = "sigmoid_5D3M_test.csv"
@@ -294,6 +313,10 @@ def get_benchmark(self, dimension=None, seed=0):
294313
"Action 4",
295314
"Action 5",
296315
]
316+
self.config.observation_space_args = [
317+
np.array([-np.inf for _ in range(16)]),
318+
np.array([np.inf for _ in range(16)]),
319+
]
297320
self.config.seed = seed
298321
self.read_instance_set()
299322
self.read_instance_set(test=True)

dacbench/envs/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
from dacbench.envs.toysgd import ToySGDEnv, ToySGDInstance
1313

1414
__all__ = [
15-
"LubyEnv",
16-
"LubyInstance",
17-
"luby_gen",
1815
"FunctionApproximationEnv",
1916
"FunctionApproximationInstance",
17+
"LubyEnv",
18+
"LubyInstance",
19+
"TheoryEnv",
2020
# "FastDownwardEnv",
2121
"ToySGDEnv",
2222
"ToySGDInstance",
23-
"TheoryEnv",
23+
"luby_gen",
2424
]
2525

2626
modcma_spec = importlib.util.find_spec("modcma")

dacbench/envs/theory.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,8 @@ def crossover(
224224
locs_x[locs_xprime] = False
225225
obj = self.get_fitness_after_crossover(xprime, locs_x, locs_xprime)
226226

227-
if (
228-
obj not in (self.fitness, xprime.fitness)
229-
or (
230-
not np.array_equal(xprime.data[locs_xprime], self.data[locs_xprime])
231-
)
227+
if obj not in (self.fitness, xprime.fitness) or (
228+
(not np.array_equal(xprime.data[locs_xprime], self.data[locs_xprime]))
232229
and (not np.array_equal(self.data[locs_x], xprime.data[locs_x]))
233230
):
234231
n_evals += 1

dacbench/wrappers/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
"ActionFrequencyWrapper",
1313
"EpisodeTimeWrapper",
1414
"InstanceSamplingWrapper",
15+
"MultiDiscreteActionWrapper",
16+
"ObservationWrapper",
17+
"PerformanceTrackingWrapper",
18+
"PolicyProgressWrapper",
1519
"PolicyProgressWrapper",
1620
"RewardNoiseWrapper",
1721
"StateTrackingWrapper",
18-
"PerformanceTrackingWrapper",
19-
"PolicyProgressWrapper",
20-
"ObservationWrapper",
21-
"MultiDiscreteActionWrapper",
2222
]
3.27 MB
Binary file not shown.

0 commit comments

Comments
 (0)