Skip to content

Commit

Permalink
Fix flake8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nabenabe0928 committed Oct 27, 2023
1 parent f9272ee commit 0d8ab14
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions quadratic_simple_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
Optuna example that optimizes a simple quadratic function with constraints.
This setup is called `constrained optimization`.
Constrained optimization is useful when we would like to optimize some metrics under some constraints.
For example, we would like to maximize the accuracy of a deep neural networks while guaranteeing that
deep neural networks fit on your hardware, e.g. 8GB of memory consumption.
In this case, constrained optimization aims to yield an optimal solution that satisfied such constraints.
Note that Optuna cannot optimize an objective that will not return any results when some constraints violate.
For example, when we run a memory-intensive algorithm and user sets the memory constraint very close to the limit,
we may not get any results if the memory constraint is violated.
However, Optuna cannot handle such situations.
Constrained optimization is useful when we would like to optimize some metrics under
some constraints. For example, we would like to maximize the accuracy of a deep neural networks
while guaranteeing that deep neural networks fit on your hardware, e.g. 8GB of memory consumption.
In this case, constrained optimization aims to yield an optimal solution that satisfied
such constraints.
Note that Optuna cannot optimize an objective that will not return any results when some
constraints violate. For example, when we run a memory-intensive algorithm and user sets
the memory constraint very close to the limit, we may not get any results if the memory constraint
is violated. However, Optuna cannot handle such situations.
Please also check https://optuna.readthedocs.io/en/stable/faq.html#id16 as well.
"""
Expand All @@ -27,7 +28,8 @@ def objective(trial):

# Define a function that returns constraints.
# The constraints are to satisfy `c1 <= 0` and `c2 <= 0` simultaneously.
# If we would like to make the constraint like `c1 <= a`, we simply need to return `c1 - a` instead of `c1`.
# If we would like to make the constraint like `c1 <= a`,
# we simply need to return `c1 - a` instead of `c1`.
def constraints(trial):
params = trial.params
x, y = params["x"], params["y"]
Expand Down

0 comments on commit 0d8ab14

Please sign in to comment.