|
11 | 11 | "cell_type": "markdown", |
12 | 12 | "metadata": {}, |
13 | 13 | "source": [ |
14 | | - "In some situations, certain regions of the solution domain mat be infeasible or not allowed. In addition, you may not know wheter a specific parameter combinations fall into these regions until you have evaluated the constraint function at these points. In other words, checking for feasibility is as expensive, or close to as expensive as evaluating the objective function. This notebook demonstrates how you can handle these situations by modelling the constraints as a Gaussian process. This approach is based on a paper by [Gardner et. al., 2014](https://www.researchgate.net/publication/271195338_Bayesian_Optimization_with_Inequality_Constraints).\n", |
| 14 | + "In some situations, certain regions of the solution domain may be infeasible or not allowed. In addition, you may not know whether specific parameter combinations fall into these regions until you have evaluated the constraint function at these points. In other words, checking for feasibility is as expensive, or close to as expensive as evaluating the objective function. This notebook demonstrates how you can handle these situations by modelling the constraints as a Gaussian process. This approach is based on a paper by [Gardner et. al., 2014](https://www.researchgate.net/publication/271195338_Bayesian_Optimization_with_Inequality_Constraints).\n", |
15 | 15 | "\n", |
16 | | - "Note that if the constrained regions are known/if the constraint function is cheap to evaluate then other approaches are preferable due to the computational complexity of modelling using Gaussian processes.\n", |
| 16 | + "Note that if the constrained regions are known/if the constraint function is cheap to evaluate, then other approaches are preferable due to the computational complexity of modelling using Gaussian processes.\n", |
17 | 17 | "In this case, at the time of writing the best approach is to return a low number to the optimizer when it tries to evaluate these regions" |
18 | 18 | ] |
19 | 19 | }, |
|
39 | 39 | "cell_type": "markdown", |
40 | 40 | "metadata": {}, |
41 | 41 | "source": [ |
42 | | - "We illustrate the use of advanced constrained bayesian optimization for on the examples Gardner et al. used in their paper.\n", |
| 42 | + "We illustrate the use of advanced constrained bayesian optimization on the examples Gardner et al. used in their paper.\n", |
43 | 43 | "\n", |
44 | 44 | "Define the target function ($f$ or `target_function`) we want to optimize along with a constraint function ($c$ or `constraint_function`) and constraint limit ($c^{lim}$ or `constraint_limit`). The mathematical problem we are trying to solve is\n", |
45 | 45 | "$$\n", |
46 | | - " \\max f(x, y) \\\\\n", |
47 | | - " \\text{subj. to} \\: \\: c(x, y) < c^{lim}\n", |
| 46 | + " \\max f(x, y)\n", |
| 47 | + "$$\n", |
| 48 | + "$$\n", |
| 49 | + " \\text{subj. to} \\: \\: c(x, y) \\leq c^{lim}\n", |
48 | 50 | "$$\n", |
49 | 51 | "Note that the constraint function should have the same parameter names as the target function (i.e. in this case `x` and `y`)." |
50 | 52 | ] |
|
110 | 112 | "cell_type": "markdown", |
111 | 113 | "metadata": {}, |
112 | 114 | "source": [ |
113 | | - "Run the optimization as usual -- the optimizer automatically estimates the probability for the constraint to be fulfilled and modifies the acquisition function accordingly." |
| 115 | + "Run the optimization as usual -- the optimizer automatically estimates the probability for the constraint to be fulfilled and modifies the acquisition function accordingly. This means, that the optimizer avoids sampling points that are likely unfeasible." |
114 | 116 | ] |
115 | 117 | }, |
116 | 118 | { |
|
129 | 131 | "cell_type": "markdown", |
130 | 132 | "metadata": {}, |
131 | 133 | "source": [ |
132 | | - "The best combination of parameters and target value and constraint function value found can be accessed via the property `bo.max`." |
| 134 | + "The best combination of parameters, target value and constraint function value found by the optimizer can be accessed via the property `optimizer.max`." |
133 | 135 | ] |
134 | 136 | }, |
135 | 137 | { |
|
241 | 243 | "source": [ |
242 | 244 | "We will now visualize the constrained optimization.\n", |
243 | 245 | "\n", |
244 | | - "In the following figure you will see two rows of plots with 3 quadratic plots each. The top row contains - in order -- a contour visualization of the target function, constraint function and the target function masked such that only areas where the constraint is fulfilled are visible. Additionally we have visualized the points sampled by the optimizer -- the optimal point is plotted in green, allowed (but non-optimal) points in white, and disallowed points in red. The bottom row shows -- in order -- the approximation of the target function using the gaussian regressors, the approximation of the constraint function and a visualization of the acquisition function, i.e. the function that guides the next point to sample." |
| 246 | + "In the following figure you will see two rows of plots with 3 quadratic plots each. The top row contains - in order -- contour visualizations of the target function, constraint function and the target function (masked such that only areas where the constraint is fulfilled are plotted). Additionally we have visualized the points sampled by the optimizer -- the optimal point is plotted in green, allowed (but non-optimal) points in white, and disallowed points in red. The bottom row shows -- in order -- the approximation of the target function using the gaussian regressors, the approximation of the constraint function and a visualization of the acquisition function, i.e. the function that guides the next point to sample." |
245 | 247 | ] |
246 | 248 | }, |
247 | 249 | { |
|
350 | 352 | "cell_type": "markdown", |
351 | 353 | "metadata": {}, |
352 | 354 | "source": [ |
353 | | - "Occasionally, one might need to fulfill multiple constraints. In this case, simply employ a multi-dimensional surrogate constraint function, i.e. a function returning an array of shape `(n,)` for in case of `n` constraints. Similarly, the `constraint_limit` should be an array of shape `(n,)`. The problem we are solving is\n", |
| 355 | + "Occasionally, one might need to fulfill multiple constraints. In this case, simply employ a multi-dimensional surrogate constraint function, i.e., in case of `n` constraints, a function returning an array of shape `(n,)`. Similarly, the `constraint_limit` should be an array of shape `(n,)`. The problem we are solving is\n", |
| 356 | + "$$\n", |
| 357 | + " \\max f(x, y)\n", |
| 358 | + "$$\n", |
| 359 | + "$$\n", |
| 360 | + " \\text{subj. to} \\: \\: c_1(x, y) < c_1^{lim}\n", |
| 361 | + "$$\n", |
| 362 | + "$$\n", |
| 363 | + " \\text{subj. to} \\: \\: c_2(x, y) < c_2^{lim}\n", |
| 364 | + "$$\n", |
| 365 | + "$$\n", |
| 366 | + " \\dots\n", |
| 367 | + "$$\n", |
354 | 368 | "$$\n", |
355 | | - " \\max f(x, y) \\\\\n", |
356 | | - " \\text{subj. to} \\: \\: c_1(x, y) < c_1^{lim} \\\\\n", |
357 | | - " \\text{subj. to} \\: \\: c_2(x, y) < c_2^{lim} \\\\\n", |
358 | | - " \\dots \\\\\n", |
359 | 369 | " \\text{subj. to} \\: \\: c_n(x, y) < c_n^{lim}\n", |
360 | 370 | "$$ " |
361 | 371 | ] |
|
0 commit comments