From 484861eb6619bbe399b397fc5c917310d8b84b0f Mon Sep 17 00:00:00 2001 From: kAIto47802 <115693559+kAIto47802@users.noreply.github.com> Date: Fri, 9 Aug 2024 16:35:00 +0900 Subject: [PATCH 1/4] Separate basic and faq --- .../{basic_and_faq_usages.yml => basic.yml} | 18 ++++----- .github/workflows/faq.yml | 38 +++++++++++++++++++ .../simple_pruning.py => basic/pruning.py | 0 .../quadratic_simple.py => basic/quadratic.py | 0 .../quadratic_constraint.py | 0 .../quadratic_multi_objective.py | 0 .../requirements.txt | 0 .../enqueue_trial.py | 0 .../max_trials_callback.py | 0 faq/requirements.txt | 3 ++ 10 files changed, 49 insertions(+), 10 deletions(-) rename .github/workflows/{basic_and_faq_usages.yml => basic.yml} (61%) create mode 100644 .github/workflows/faq.yml rename basic_and_faq_usages/simple_pruning.py => basic/pruning.py (100%) rename basic_and_faq_usages/quadratic_simple.py => basic/quadratic.py (100%) rename basic_and_faq_usages/quadratic_simple_constraint.py => basic/quadratic_constraint.py (100%) rename basic_and_faq_usages/quadratic_simple_multi_objective.py => basic/quadratic_multi_objective.py (100%) rename {basic_and_faq_usages => basic}/requirements.txt (100%) rename {basic_and_faq_usages => faq}/enqueue_trial.py (100%) rename {basic_and_faq_usages => faq}/max_trials_callback.py (100%) create mode 100644 faq/requirements.txt 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/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_and_faq_usages/requirements.txt b/basic/requirements.txt similarity index 100% rename from basic_and_faq_usages/requirements.txt rename to basic/requirements.txt 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/faq/requirements.txt b/faq/requirements.txt new file mode 100644 index 00000000..fd6f7d19 --- /dev/null +++ b/faq/requirements.txt @@ -0,0 +1,3 @@ +optuna +scikit-learn>=0.19.0 +pandas From 359aaf7ea9d74ee2056a9e387ca9467a9ac04e49 Mon Sep 17 00:00:00 2001 From: kAIto47802 <115693559+kAIto47802@users.noreply.github.com> Date: Fri, 9 Aug 2024 16:54:28 +0900 Subject: [PATCH 2/4] Update README and remove pandas in basic --- README.md | 12 ++++++------ basic/requirements.txt | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5ab94a45..8b7b2eeb 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](./basic/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](./basic/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/requirements.txt b/basic/requirements.txt index fd6f7d19..cd1f442a 100644 --- a/basic/requirements.txt +++ b/basic/requirements.txt @@ -1,3 +1,2 @@ optuna scikit-learn>=0.19.0 -pandas From be714022e3d424c463faa8d09280af67f0e10066 Mon Sep 17 00:00:00 2001 From: kAIto47802 <115693559+kAIto47802@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:29:20 +0900 Subject: [PATCH 3/4] Update README.md Co-authored-by: Shuhei Watanabe <47781922+nabenabe0928@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b7b2eeb..2052c947 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ 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/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/max_trials_callback.py), which is useful when you would like to define your own termination criterion other than `n_trials` or `timeout`. From f7e7bbfa9aa54c6946631866d13abe54fa0b4078 Mon Sep 17 00:00:00 2001 From: kAIto47802 <115693559+kAIto47802@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:29:30 +0900 Subject: [PATCH 4/4] Update README.md Co-authored-by: Shuhei Watanabe <47781922+nabenabe0928@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2052c947..7d90a4e8 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ if __name__ == "__main__": > > 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/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