Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Unify implementation of fast non-dominated sort #5160
Unify implementation of fast non-dominated sort #5160
Changes from 38 commits
b3fc441
63a9488
0e70a1f
319bce0
90fc55e
01cb145
9d358b4
43a9ae3
373903c
516e0ab
04385eb
a613050
a4cd1cd
b88d010
881009f
1bac8bd
a174c04
950fcc0
f5ae9d8
bd54538
a081ef0
cc46d17
a38e76e
51f4458
b484b28
8fcd160
13aa189
afac585
9876648
60ea231
a5c55e4
c6a96d7
37b043d
dfbb3dd
6593e16
70d5802
378c390
b6343d1
4bfe871
5c25571
e4f193e
3c6547b
7ae7855
a490277
542f011
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Can we use
loss_values
to be clear to us in the future that each objective is better when it is lower in this array?Please check out other functions as well.
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.
Sounds reasonable, but the objective values are not necessarily 'loss' value. Therefore the change might be confusing.
@HideakiImamura Do you have any opinion?
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.
I think
objective_values
is appropriate here.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.
Just to give @HideakiImamura the context:
loss_vals
(or another name islvals
) is often used inTPESampler
when lower values are better (please check here and here)So the problem here is that I would need to take a look at the source of the function calls whether
objective_values
is always better when each objective is lower.loss does not necessarily mean the machine-learning loss functions, but just loss, which we already have a universal consensus such that lower loss is better even in normal conversations.
I do not mind using
objective_values
, but I strongly encourage you to specify whether each objective is better when it is lower.Again, the reason is simple because I would need to refer to the function call origin to see if
objective_values
is always better when it is lower.Check warning on line 132 in optuna/samplers/nsgaii/_elite_population_selection_strategy.py
Codecov / codecov/patch
optuna/samplers/nsgaii/_elite_population_selection_strategy.py#L132
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.
For simplicity, I removed
penalty
andn_below
, but this implementation maintains the same results as your program yet much quicker.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.
The unit is milliseconds.
n_trials=1000, n_objectives=2
n_trials=10000, n_objectives=2
n_trials=1000, n_objectives=3
n_trials=10000, n_objectives=3
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.
I think your implementation of dominance with
penalty
includes the unnecessary consideration ofpenalty
for feasible cases.Namely, we do not consider the penalty amount once each trial satisfies the penalty, but yours are considering the penalty amount even for feasible cases.
Please check the following definition by Deb et al. [1]:
Plus, the implementation below is much quicker.
[1] K. Deb et al. A Fast and Elitist Multiobjective Genetic Algorithm: NSGA-II
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.
Thanks for the suggestion. I just move what's implemented in
_tpe/sampler.py
and no need to stick to the first implementation. I'll consider how to reconcile current_get_pareto_front_trials_by_trials
function with your suggestion.In my understanding, the penalty is set to 0 when the trial is feasible, thus having no influence on the result. Anyway, I'll use the faster implementation in the suggestion.
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.
This is Just a memo for future discussion, please ignore it for now.
When using
dominates
, the runtime will be much much longer compared to the vectorization version, but it still runs quicker than creating the dominance matrix.This implementation is much slower because:
trials[j]
cannot dominatetrials[i]
forCheck warning on line 88 in optuna/study/_multi_objective.py
Codecov / codecov/patch
optuna/study/_multi_objective.py#L88
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.
As we can already bound
max(nondomination_rank)
byn_below
andnondomination_rank
ofn_below + 1
will not be used, so what about usingn_below + 1
?Another reason why we should probably avoid
-1
is that it might cause unexpected bugs in the future when some developers usenondomination_rank
being always better when it is lower.Plus, this implementation requires an ad-hoc handling of
nondomination_rank=-1
in each place where the function is used.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.
If we define
nondomination_rank
as:bottom_rank
becomesbottom_rank = np.max(ranks)
.Note that if
np.max(bottom_rank) = n_below + 1
, the processes hereafter simply define eachnondomination_rank
asn_below + <positive_integer>
, so they will be ignored.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.
I totally agree what you say but it makes this PR even larger. Can I split the task as a follow-up and resolve your comment in another PR?
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.
The suggestion is a little bit complicated, so I remarked the comment on #5089