Metadata-Version: 2.4
Name: optuna-async-helper
Version: 0.7.1
Summary: A Helper Library for Optuna Async Optimization
Project-URL: repository, https://github.com/lucidfrontier45/optuna-async-helper
Author-email: 杜 世橋 Du Shiqiao <lucidfrontier.45@gmail.com>
License: MIT
License-File: LICENSE
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: joblib>=1.3.2
Requires-Dist: optuna>=4.0.0
Requires-Dist: pydantic>=2.6.1
Description-Content-Type: text/markdown

# Optuna Async Helper
A Helper Library for Optuna Async Optimization

# Install

```bash
pip install optuna-async-helper
```

# Usage

```python
import tempfile

from optuna_async_helper import (
    SearchSpace,
    SearchSpec,
    optimize,
    create_journal_storage,
    create_study,
)


def rosenbrock(x: float, y: float, z: float) -> float:
    return (z - x) ** 2 + 100 * (y - x**2) ** 2


def test_optimizer():
    search_space: SearchSpace = [
        SearchSpec(var_name="x", domain_type="float", low=-5, high=5),
        SearchSpec(var_name="y", domain_type="float", low=-5, high=5),
    ]
    z = 0.5
    initial_params = [
        {"x": 0, "y": 0},
        {"x": 1.0, "y": 0},
        {"x": 0, "y": 1.0},
    ]

    with tempfile.TemporaryDirectory() as tempdir:
        storage = create_journal_storage(f"{tempdir}/example.db")
        study = create_study(
            study_name="rosenbrock",
            storage=storage,
        )
        study = optimize(
            study,
            objective_func=rosenbrock,
            search_space=search_space,
            initial_params=initial_params,
            n_trials=10,
            batch_size=32,
            z=z,
        )

        assert study.best_value < 1.0
        assert abs(study.best_params["x"] - z) < 1.0
        assert abs(study.best_params["y"] - z) < 1.0
```

For more detail, please check `optimize` and `SearchSpec` definitions.

# Development

The project is managed by [uv](https://docs.astral.sh/uv/)