From b4bc3976eefc81411fc2e01e009f3df7933aba4a Mon Sep 17 00:00:00 2001 From: Sathvik Bhagavan Date: Thu, 14 Dec 2023 02:56:23 +0000 Subject: [PATCH] docs: fix improved branin benchmark and run this example while building --- docs/pages.jl | 2 +- docs/src/ImprovedBraninFunction.md | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/docs/pages.jl b/docs/pages.jl index f408f3b6..24d4d3a7 100644 --- a/docs/pages.jl +++ b/docs/pages.jl @@ -1,5 +1,5 @@ pages = ["index.md" - "Tutorials" => [ + "Tutorials" => [ "Basics" => "tutorials.md", "Radials" => "radials.md", "Kriging" => "kriging.md", diff --git a/docs/src/ImprovedBraninFunction.md b/docs/src/ImprovedBraninFunction.md index 98d3ca4c..002a5ef2 100644 --- a/docs/src/ImprovedBraninFunction.md +++ b/docs/src/ImprovedBraninFunction.md @@ -2,11 +2,12 @@ The Branin Function is commonly used as a test function for metamodelling in computer experiments, especially in the context of optimization. - # Modifications for Improved Branin Function: + To enhance the Branin function, changes were made to introduce irregularities, variability, and a dynamic aspect to its landscape. Here's an example: -```function improved_branin(x, time_step) +```@example improved_branin +function improved_branin(x, time_step) x1 = x[1] x2 = x[2] b = 5.1 / (4*pi^2) @@ -27,12 +28,21 @@ end This improved function now incorporates irregularities, variability, and a dynamic aspect. These changes aim to make the optimization landscape more challenging and realistic. # Using the Improved Branin Function: -After defining the improved Branin function, you can proceed to test different surrogates and visualize their performance using the updated function. Here's an example of using the improved function with the Radial Basis surrogate: -``` -# Assuming you've defined 'improved_branin' and imported necessary packages +After defining the improved Branin function, you can proceed to test different surrogates and visualize their performance using the updated function. Here's an example of using the improved function with the Radial Basis surrogate: -radial_surrogate = RadialBasis(xys, [improved_branin(xy, 0.1) for xy in xys], lower_bound, upper_bound) +```@example improved_branin +using Surrogates, Plots + +n_samples = 80 +lower_bound = [-5, 0] +upper_bound = [10, 15] +xys = sample(n_samples, lower_bound, upper_bound, SobolSample()) +zs = [improved_branin(xy, 0.1) for xy in xys] +radial_surrogate = RadialBasis(xys, zs, lower_bound, upper_bound) +x, y = -5.00:10.00, 0.00:15.00 +xs = [xy[1] for xy in xys] +ys = [xy[2] for xy in xys] p1 = surface(x, y, (x, y) -> radial_surrogate([x, y])) scatter!(xs, ys, marker_z=zs) p2 = contour(x, y, (x, y) -> radial_surrogate([x, y]))