diff --git a/.github/workflows/basic_and_faq_usages.yml b/.github/workflows/basic.yml similarity index 61% rename from .github/workflows/basic_and_faq_usages.yml rename to .github/workflows/basic.yml index dac697cb..c4d9ba7f 100644 --- a/.github/workflows/basic_and_faq_usages.yml +++ b/.github/workflows/basic.yml @@ -1,12 +1,12 @@ -name: basic_and_faq_usages +name: basic on: schedule: - cron: '0 15 * * *' pull_request: paths: - - 'basic_and_faq_usages/**' - - '.github/workflows/basic_and_faq_usages.yml' + - 'basic/**' + - '.github/workflows/basic.yml' jobs: examples: @@ -29,14 +29,12 @@ jobs: pip install git+https://github.com/optuna/optuna.git python -c 'import optuna' - pip install -r basic_and_faq_usages/requirements.txt + pip install -r basic/requirements.txt - name: Run examples run: | - python basic_and_faq_usages/max_trials_callback.py - python basic_and_faq_usages/enqueue_trial.py - python basic_and_faq_usages/quadratic_simple.py - python basic_and_faq_usages/simple_pruning.py - python basic_and_faq_usages/quadratic_simple_constraint.py - python basic_and_faq_usages/quadratic_simple_multi_objective.py + python basic/quadratic.py + python basic/pruning.py + python basic/quadratic_constraint.py + python basic/quadratic_multi_objective.py env: OMP_NUM_THREADS: 1 diff --git a/.github/workflows/faq.yml b/.github/workflows/faq.yml new file mode 100644 index 00000000..6805767d --- /dev/null +++ b/.github/workflows/faq.yml @@ -0,0 +1,38 @@ +name: faq + +on: + schedule: + - cron: '0 15 * * *' + pull_request: + paths: + - 'faq/**' + - '.github/workflows/faq.yml' + +jobs: + examples: + if: (github.event_name == 'schedule' && github.repository == 'optuna/optuna-examples') || (github.event_name != 'schedule') + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + + steps: + - uses: actions/checkout@v4 + - name: setup-python${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install (Python) + run: | + python -m pip install --upgrade pip + pip install --progress-bar off -U setuptools + pip install git+https://github.com/optuna/optuna.git + python -c 'import optuna' + + pip install -r faq/requirements.txt + - name: Run examples + run: | + python faq/max_trials_callback.py + python faq/enqueue_trial.py + env: + OMP_NUM_THREADS: 1 diff --git a/README.md b/README.md index 5ab94a45..7d90a4e8 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,9 @@ if __name__ == "__main__": > In this example repository, you can also find the examples for the following scenarios: > 1. [Objective function with additional arguments](./sklearn/sklearn_additional_args.py), which is useful when you would like to pass arguments besides `trial` to your objective function. > -> 2. [Manually provide trials with sampler](./basic_and_faq_usages/enqueue_trial.py), which is useful when you would like to force certain parameters to be sampled. +> 2. [Manually provide trials with sampler](./faq/enqueue_trial.py), which is useful when you would like to force certain parameters to be sampled. > -> 3. [Callback to control the termination criterion of study](./basic_and_faq_usages/max_trials_callback.py), which is useful when you would like to define your own termination criterion other than `n_trials` or `timeout`. +> 3. [Callback to control the termination criterion of study](./faq/max_trials_callback.py), which is useful when you would like to define your own termination criterion other than `n_trials` or `timeout`. ## Examples for Diverse Problem Setups @@ -43,9 +43,9 @@ Here are the URLs to the example codeblocks to the corresponding setups.
Simple Black-box Optimization -* [Quadratic Function](./basic_and_faq_usages/quadratic_simple.py) -* [Quadratic Multi-Objective Function](./basic_and_faq_usages/quadratic_simple_multi_objective.py) -* [Quadratic Function with Constraints](./basic_and_faq_usages/quadratic_simple_constraint.py) +* [Quadratic Function](./basic/quadratic.py) +* [Quadratic Multi-Objective Function](./basic/quadratic_multi_objective.py) +* [Quadratic Function with Constraints](./basic/quadratic_constraint.py)
@@ -93,7 +93,7 @@ If you are looking for an example of reinforcement learning, please take a look The following example demonstrates how to implement pruning logic with Optuna. -* [Simple pruning (scikit-learn)](./basic_and_faq_usages/simple_pruning.py) +* [Simple pruning (scikit-learn)](./basic/pruning.py) In addition, integration modules are available for the following libraries, providing simpler interfaces to utilize pruning. diff --git a/basic_and_faq_usages/simple_pruning.py b/basic/pruning.py similarity index 100% rename from basic_and_faq_usages/simple_pruning.py rename to basic/pruning.py diff --git a/basic_and_faq_usages/quadratic_simple.py b/basic/quadratic.py similarity index 100% rename from basic_and_faq_usages/quadratic_simple.py rename to basic/quadratic.py diff --git a/basic_and_faq_usages/quadratic_simple_constraint.py b/basic/quadratic_constraint.py similarity index 100% rename from basic_and_faq_usages/quadratic_simple_constraint.py rename to basic/quadratic_constraint.py diff --git a/basic_and_faq_usages/quadratic_simple_multi_objective.py b/basic/quadratic_multi_objective.py similarity index 100% rename from basic_and_faq_usages/quadratic_simple_multi_objective.py rename to basic/quadratic_multi_objective.py diff --git a/basic/requirements.txt b/basic/requirements.txt new file mode 100644 index 00000000..cd1f442a --- /dev/null +++ b/basic/requirements.txt @@ -0,0 +1,2 @@ +optuna +scikit-learn>=0.19.0 diff --git a/basic_and_faq_usages/enqueue_trial.py b/faq/enqueue_trial.py similarity index 100% rename from basic_and_faq_usages/enqueue_trial.py rename to faq/enqueue_trial.py diff --git a/basic_and_faq_usages/max_trials_callback.py b/faq/max_trials_callback.py similarity index 100% rename from basic_and_faq_usages/max_trials_callback.py rename to faq/max_trials_callback.py diff --git a/basic_and_faq_usages/requirements.txt b/faq/requirements.txt similarity index 100% rename from basic_and_faq_usages/requirements.txt rename to faq/requirements.txt