Add the test to check the study with dynamic search space

This commit is contained in:
porink0424
2024-06-21 18:37:28 +09:00
parent e215b1bf10
commit 747098b689
2 changed files with 14 additions and 2 deletions
+2 -2
View File
@@ -44,9 +44,9 @@ def create_optuna_storage(storage: BaseStorage) -> None:
def objective_single_dynamic(trial: optuna.Trial) -> float:
category = trial.suggest_categorical("category", ["foo", "bar"])
if category == "foo":
return (trial.suggest_float("x1", 0, 10) - 2) ** 2
return (trial.suggest_float("x", 0, 10) - 2) ** 2
else:
return -((trial.suggest_float("x2", -10, 0) + 5) ** 2)
return -((trial.suggest_float("x", -10, 0) + 5) ** 2)
study.optimize(objective_single_dynamic, n_trials=50)
+12
View File
@@ -16,6 +16,18 @@ describe("Test Journal File Storage", async () => {
studySummaries.map((_summary, index) => storage.getStudy(index))
)
it("Check the study with dynamic search space", () => {
const study = studies.find((s) => s.name === "single-objective-dynamic")
assert.deepStrictEqual(
study.union_search_space.map((item) => item.name).sort(),
["x", "x", "category"].sort()
)
assert.deepStrictEqual(
study.intersection_search_space.map((item) => item.name).sort(),
["category"].sort()
)
})
it("Check the study including Infinities", () => {
const study = studies.find((s) => s.name === "single-inf")
study.trials.forEach((trial, index) => {