Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the "center" of CMAES to be 1-dimensional #111

Merged
merged 1 commit into from
Aug 2, 2024
Merged
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
8 changes: 7 additions & 1 deletion src/evotorch/algorithms/cmaes.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,13 @@ def __init__(
center_init = center_init.values.clone()

# Store the center
self.m = self._problem.make_tensor(center_init)
self.m = self._problem.make_tensor(center_init).squeeze()
valid_shaped_m = (self.m.ndim == 1) and (len(self.m) == self._problem.solution_length)
if not valid_shaped_m:
raise ValueError(
f"The initial center point was expected as a vector of length {self._problem.solution_length}."
" However, the provided `center_init` has (or implies) a different shape."
)

# Store the initial step size
self.sigma = self._problem.make_tensor(stdev_init)
Expand Down
Loading