-
-
Notifications
You must be signed in to change notification settings - Fork 971
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
Add WFG benchmark test #3349
Add WFG benchmark test #3349
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3349 +/- ##
==========================================
- Coverage 91.84% 91.55% -0.30%
==========================================
Files 156 158 +2
Lines 12292 12226 -66
==========================================
- Hits 11290 11193 -97
- Misses 1002 1033 +31
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
@kei-mo, thanks for the last discussion and swift PR. 🙇 @sile, not sure how busy you are but would you be able to review this change later on, as the author of Kurobako? |
I'm willing to review this PR. However, it would take some time because I'm a bit busy for a while. If you want to merge this PR within a few days or weeks, please re-assign to another person instead of me 🙏 |
I see, thanks for the quick response. @nzw0301 do you happen to be available? |
@hvy , I've updated the PR description. I'm currently working on transferring @HideakiImamura san's WFG code to kurobako problem. I think this would take some time (maybe a week). |
@HideakiImamura , if you have the script for running the WFG code, it would be very helpful. Could you share if you don't mind? |
@kei-mo Thanks for the update! This is the usage of the WFG. Please take a look. from WFGtestSuite import wfg
import numpy as np
import math
class WFG:
def __init__(self, problem_name, n_var, n_obj=2, k=2):
if problem_name == "wfg1":
self.wfg = wfg.WFG1(n_arguments=n_var, n_objectives=n_obj, k=k)
elif problem_name == "wfg2":
self.wfg = wfg.WFG2(n_arguments=n_var, n_objectives=n_obj, k=k)
elif problem_name == "wfg3":
self.wfg = wfg.WFG3(n_arguments=n_var, n_objectives=n_obj, k=k)
elif problem_name == "wfg4":
self.wfg = wfg.WFG4(n_arguments=n_var, n_objectives=n_obj, k=k)
elif problem_name == "wfg5":
self.wfg = wfg.WFG5(n_arguments=n_var, n_objectives=n_obj, k=k)
elif problem_name == "wfg6":
self.wfg = wfg.WFG6(n_arguments=n_var, n_objectives=n_obj, k=k)
elif problem_name == "wfg7":
self.wfg = wfg.WFG7(n_arguments=n_var, n_objectives=n_obj, k=k)
elif problem_name == "wfg8":
self.wfg = wfg.WFG8(n_arguments=n_var, n_objectives=n_obj, k=k)
elif problem_name == "wfg9":
self.wfg = wfg.WFG9(n_arguments=n_var, n_objectives=n_obj, k=k)
else:
raise ValueError("not found", problem_name)
self._low = 0
self._high = 2
self.n_var = n_var
def objective(self, trial):
x = np.array(
[
trial.suggest_float(f"x{i}", self._low, self._high * i)
for i in range(1, self.n_var + 1)
]
)
v = self.wfg(x)
if math.isnan(v[0]) or math.isinf(v[0]):
raise ValueError
if math.isnan(v[1]) or math.isinf(v[1]):
raise ValueError
return v[0], v[1]
objective_name = HOGE # Set wfg1 ~ wfg9
dim = FUGA # I think `dim` cam be 2, 3, 5, and 10.
if objective_name == "wfg2" or objective_name == "wfg3":
if dim == 2 or dim == 3:
raise ("error: dim:2,dim:3, wfg2, wfg3")
elif dim == 5:
wfg = WFG(objective_name, dim, k=1)
else:
wfg = WFG(objective_name, dim, k=2)
elif objective_name == "wfg7":
wfg = WFG(objective_name, dim, k=1)
elif objective_name == "wfg8":
if dim == 3:
wfg = WFG(objective_name, dim, k=2)
else:
wfg = WFG(objective_name, dim, k=1)
elif objective_name == "wfg9":
wfg = WFG(objective_name, dim, k=1)
else:
if dim == 2:
wfg = WFG(objective_name, dim, k=1)
else:
wfg = WFG(objective_name, dim, k=2) |
By the way, you can pass the CI job |
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 PR! I have several early comments. Please take a look.
At first, how about renaming the WFGtestSuite
directory to wfg
? It it simple and easy to understand.
from . import shape_functions | ||
from . import transformation_functions |
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.
Please use the absolute import.
from . import shape_functions | |
from . import transformation_functions | |
from benchmarks.problems.wfg import shape_functions | |
from benchmarks.problems.wfg import transformation_functions |
@@ -0,0 +1,46 @@ | |||
from kurobako import problem |
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 we can remove this file from this PR.
benchmarks/problems/wfg_problem.py
Outdated
@@ -0,0 +1,86 @@ | |||
import math |
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.
Cannot we directly use wfg.py
or fix it to use with kurobako? I think the codes of this file are redundant.
This pull request has not seen any recent activity. |
This pull request has not seen any recent activity. |
@HideakiImamura |
…ehiron/optuna into add_wfg_benchmark
Here's what I got by running TPE on the WFG benchmarks.
-> 0.2.1 python benchmarks/run_mo_kurobako.py \
--path-to-kurobako <path-to-kurobako> \
--name "performance-benchmarks" \
--n-runs 1 \
--n-jobs 4 \
--sampler-list "RandomSampler TPESampler " \
--sampler-kwargs-list "{} {}" \
--seed 0 \
--data-dir "." \
--out-dir "out" |
This pull request has not seen any recent activity. |
The benchmark result basically looks good to me. It might be good to increate the number of trials like 300. |
@kei-mo Since this PR has a very large number of lines and is expected to take some time to review, why not hold a mob review once to get an overview in real time? |
@HideakiImamura Sounds good to me! |
@kei-mo Thanks! Please check discord to to a mob-review. |
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, LGTM. I have two memos.
benchmarks/run_mo_kurobako.py
Outdated
if n_wfg == 8: | ||
n_dim = 3 | ||
k = 2 | ||
elif n_wfg in (7, 8, 9): | ||
n_dim = 2 | ||
k = 1 | ||
else: | ||
n_dim = 10 | ||
k = 2 |
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.
memo: investigate the appropriate setups
"WFG1": {"xmin": 2.7, "xmax": 3.05, "ymin": 4.7, "ymax": 5.05}, | ||
"WFG2": {"xmin": 2.0, "xmax": 2.8, "ymin": 3.0, "ymax": 4.8}, | ||
"WFG3": {"xmin": 2.0, "xmax": 2.8, "ymin": 3.0, "ymax": 4.8}, | ||
"WFG4": {"xmin": 2.0, "xmax": 3.0, "ymin": 0.0, "ymax": 3.6}, | ||
"WFG5": {"xmin": 2.0, "xmax": 3.0, "ymin": 2.5, "ymax": 5.0}, | ||
"WFG6": {"xmin": 2.0, "xmax": 3.0, "ymin": 3.4, "ymax": 5.0}, | ||
"WFG7": {"xmin": 2.0, "xmax": 3.0, "ymin": 4.0, "ymax": 5.0}, | ||
"WFG8": {"xmin": 2.0, "xmax": 3.0, "ymin": 3.4, "ymax": 5.0}, | ||
"WFG9": {"xmin": 2.0, "xmax": 3.0, "ymin": 0.0, "ymax": 5.0}, |
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.
memo: These range may change depending on above n_dim
.
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 couldn't review the detail of the implementations of WFG functions. But the overall code looks good to me 👍
Motivation
Based on private discussion with @HideakiImamura and @hvy , we're going to add WFG multi-objective optimization benchmark test to
benchmarks/run_mo_kurobako.py
Description of the changes
benchmarks/run_mo_kurobako.py
.