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 time complexity of the samplers comparison table #3593
Conversation
There was a problem hiding this 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 great work! Let me discuss each sampler.
RandomSampler
I think O(d) would be more reasonable. It samples values d
times in each trial.
GridSampler
It requires O(n) + O(number of grids) computation. O(number of grids) term is comparable when n
is large. Then, the total complexity is O(n).
O(dn) is correct. _same_search_space
is the bottleneck. @knshnb Thank you for pointing this out!
optuna/optuna/samplers/_grid.py
Lines 254 to 267 in e972dbb
def _same_search_space(self, search_space: Mapping[str, Sequence[GridValueType]]) -> bool: | |
if set(search_space.keys()) != set(self._search_space.keys()): | |
return False | |
for param_name in search_space.keys(): | |
if len(search_space[param_name]) != len(self._search_space[param_name]): | |
return False | |
for i, param_value in enumerate(search_space[param_name]): | |
if param_value != self._search_space[param_name][i]: | |
return False | |
return True |
I will check other samplers later.
Thank you for the PR! This will be helpful information for users. The dimension of the search spaceThis is not a strong opinion, but
might not be informative enough because the time complexity of The number of objectivesSeveral samplers have ✅ in the Multi-objective optimization column, but it seems only the I'm sorry that I'm not familiar with some samplers and I cannot give a concrete suggestion now. If you have any problems, let me discuss the detail of each sampler. |
@not522 @knshnb Thank you for your careful reviews. I basically follow you reviews. PTAL.
It is the user's responsibility to recognize that sample_independent is called for each parameter in the objective function, so that is where O(d) is taken for all samplers. |
Codecov Report
@@ Coverage Diff @@
## master #3593 +/- ##
==========================================
- Coverage 91.00% 90.83% -0.17%
==========================================
Files 160 161 +1
Lines 12307 12412 +105
==========================================
+ Hits 11200 11275 +75
- Misses 1107 1137 +30
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the useful discussions and great work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Motivation
This is a follow-up of #3571. This PR fixes the time complexity following private discussion with @knshnb and @not522.
Description of the changes