Created
May 14, 2025 02:32
-
-
Save c-bata/b643420299e84ad425a6c922618b68da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from concurrent.futures import ProcessPoolExecutor | |
import optuna | |
from optuna.storages import JournalStorage | |
from optuna.storages.journal import JournalFileBackend | |
storage = JournalStorage(JournalFileBackend("./optuna_journal_storage.log")) | |
def objective(trial: optuna.Trial) -> float: | |
x = trial.suggest_float("x", -10, 10) | |
return x ** 2 | |
if __name__ == "__main__": | |
study = optuna.create_study(storage=storage) | |
with ProcessPoolExecutor(max_workers=20) as pool: | |
for i in range(100): | |
pool.submit(study.optimize, objective, n_trials=10) | |
print(f"{len(study.trials)=}") | |
print(f"{len({trial.number for trial in study.trials})=}") | |
print(f"{len({trial._trial_id for trial in study.trials})=}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
log