Skip to content

Commit

Permalink
Rename the objectives in built-in env
Browse files Browse the repository at this point in the history
  • Loading branch information
zhe-slac committed Mar 4, 2025
1 parent f7587a3 commit 3acd6dc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/badger/built_in_plugins/environments/sphere_2d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ class Environment(environment.Environment):
"x0": [-1, 1],
"x1": [-1, 1],
}
observables = ["f1", "f2"]
observables = ["f", "g"]

_variables = {
"x0": 0.5,
"x1": 0.5,
}
_observations = {
"f1": 0.0,
"f2": 0.0,
"f": 0.0,
"g": 0.0,
}

def get_variables(self, variable_names):
Expand All @@ -28,11 +28,11 @@ def set_variables(self, variable_inputs: dict[str, float]):
self._variables[var] = x

# Filling up the observations
f1 = self._variables["x0"] ** 2 + self._variables["x1"] ** 2
f2 = (self._variables["x0"] - 0.5) ** 2 + self._variables["x1"] ** 2
f = self._variables["x0"] ** 2 + self._variables["x1"] ** 2
g = (self._variables["x0"] - 0.5) ** 2 + self._variables["x1"] ** 2

self._observations["f1"] = f1
self._observations["f2"] = f2
self._observations["f"] = f
self._observations["g"] = g

def get_observables(self, observable_names):
return {k: self._observations[k] for k in observable_names}

0 comments on commit 3acd6dc

Please sign in to comment.