-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
Description
(Less of a bug and more of an oversight on my part)
Describe the bug
When using ScreenLogger, no information about the constrained optimization is printed.
To Reproduce
import numpy as np
from bayes_opt import BayesianOptimization
from scipy.optimize import NonlinearConstraint
def target_function(x, y):
return np.cos(2*x)*np.cos(y) + np.sin(x)
def constraint_function(x, y):
return np.cos(x) * np.cos(y) - np.sin(x) * np.sin(y)
constraint_limit = 0.5
constraint = NonlinearConstraint(constraint_function, -np.inf, constraint_limit)
# Bounded region of parameter space
pbounds = {'x': (0, 6), 'y': (0, 6)}
optimizer = BayesianOptimization(
f=target_function,
constraint=constraint,
pbounds=pbounds,
random_state=1,
)
optimizer.maximize(
init_points=2,
n_iter=10,
)Expected behavior
I'm somewhat torn on what information should be output. I see a few options:
- Just the value(s) of the constraint function(s) at the specific point
- Just the
"allowed"-ness of the point - Both the specific values and the
"allowed"-ness - Colour disallowed points red and/or allowed points green
- Just the value(s) of the constraint function(s) at the specific point, colour coded green/red for allowed/disallowed
Personally I'm leaning towards the second option to reduce clutter, but I'm open to other opinions. It would look something like this:
| iter | target | allowed | x | y |
-------------------------------------------------------------
| 1 | 0.4872 | False | 2.502 | 4.322 |
| 2 | -0.2401 | True | 0.0006862 | 1.814 |
| 3 | 0.7821 | False | 2.304 | 4.326 |
| 4 | 1.249 | False | 1.899 | 4.321 |
| 5 | 0.7351 | False | 1.351 | 4.982 |
| 6 | 1.814 | True | 1.534 | 3.757 |
| 7 | 1.793 | False | 1.854 | 2.982 |
| 8 | 0.02935 | False | 2.834 | 1.913 |
| 9 | 1.496 | False | 1.108 | 3.106 |
| 10 | 0.5423 | True | 5.99 | 0.06449 |
| 11 | 0.4597 | True | 5.985 | 5.858 |
| 12 | -1.095 | True | 5.986 | 2.891 |
=============================================================
Reactions are currently unavailable