mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-12 12:40:33 +08:00
Add the test to check the study with dynamic search space
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user