Skip to content

Support 1D Search Spaces in CmaEsSampler#6228

Merged
c-bata merged 7 commits intooptuna:masterfrom
sawa3030:dev/allow-one-dim
Aug 7, 2025
Merged

Support 1D Search Spaces in CmaEsSampler#6228
c-bata merged 7 commits intooptuna:masterfrom
sawa3030:dev/allow-one-dim

Conversation

@sawa3030
Copy link
Copy Markdown
Collaborator

@sawa3030 sawa3030 commented Aug 1, 2025

Motivation

Thanks to CMA-ES PR #190, the CMA-ES library now supports 1-dimensional search spaces. This PR updates CmaEsSampler to allow the use of 1D search spaces accordingly.

Description of the changes

  • Removed the logic that falls back to the independent sampler for 1D search spaces.
  • Since SepCMA currently does not support 1D search spaces (see source), SepCMA will be bypassed when use_separable_cma=True and the search space is 1D.
  • Updated the cmaes version in pyproject.toml.

@sawa3030
Copy link
Copy Markdown
Collaborator Author

sawa3030 commented Aug 1, 2025

Other options of CmaEsSampler worked without errors even when using a 1D search space.

sigma0 = max(sigma0, _EPS)

if self._use_separable_cma:
if self._use_separable_cma and not is_single_dimension:
Copy link
Copy Markdown
Member

@y0z y0z Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful to issue a warning when attempting to use sepCMA in 1D, as it is meaningless.

@c-bata
Copy link
Copy Markdown
Member

c-bata commented Aug 1, 2025

@kAIto47802 Could you review this PR?

@c-bata c-bata added the feature Change that does not break compatibility, but affects the public interfaces. label Aug 1, 2025
@nabenabe0928 nabenabe0928 changed the title Support 1D Search Spaces in CmaEsSampler Support 1D Search Spaces in CmaEsSampler Aug 1, 2025
Copy link
Copy Markdown
Member

@y0z y0z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I also confirmed that this change works with_margin=True.

optuna.samplers.CmaEsSampler(seed=42, with_margin=True)

@nabenabe0928
Copy link
Copy Markdown
Contributor

Let me re-assign from @kAIto47802 to @y0z !

@nabenabe0928 nabenabe0928 added this to the v4.5.0 milestone Aug 5, 2025
Copy link
Copy Markdown
Member

@c-bata c-bata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your pull request. I left two suggestions.

self,
trans: _SearchSpaceTransform,
direction: StudyDirection,
is_single_dimension: bool,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about checking trans.bounds instead of adding a new argument here?

Copy link
Copy Markdown
Member

@c-bata c-bata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for the update.

@c-bata c-bata merged commit 0ee0642 into optuna:master Aug 7, 2025
24 checks passed
@sawa3030 sawa3030 deleted the dev/allow-one-dim branch November 14, 2025 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Change that does not break compatibility, but affects the public interfaces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants