Skip to content

Commit

Permalink
Merge be9078a into dbcd827
Browse files Browse the repository at this point in the history
  • Loading branch information
ludoro committed Jul 12, 2020
2 parents dbcd827 + be9078a commit 4ba334c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ makedocs(
"LinearSurrogate" => "LinearSurrogate.md",
"InverseDistance" => "InverseDistance.md"
]
"Benchmarks" => [
"Sphere function" => "sphere_function.md"
]
"Contributing" => "contributing.md"
]
)
Expand Down
4 changes: 3 additions & 1 deletion docs/src/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ You can also contact me on the Julia slack channel at @ludoro.
# List of contributors

- Ludovico Bessi (@ludoro)
- Chris Rackauckas
- Chris Rackauckas (@ChrisRackauckas)
- Rohit Singh Rathaur (@TeAmp0is0N)
- Andrea Cognolato (@mrandri19)
- Kanav Gupta (@kanav99)
55 changes: 55 additions & 0 deletions docs/src/sphere_function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Sphere function

The sphere function of dimension d is defined as:
$$ f(x) = \sum_{i=1}^d x_i $$
with lower bound -10 and upper bound 10.

Let's import Surrogates and Plots:
```@example sphere_function
using Surrogates
using Plots
default()
```

Define the objective function:
```@example sphere_function
function sphere_function(x)
return sum(x.^2)
end
```

The 1D case is just a simple parabola, let's plot it:
```@example sphere_function
n = 100
lb = -10
ub = 10
x = sample(n,lb,ub,SobolSample())
y = sphere_function.(x)
xs = lb:0.001:ub
plot(x, y, seriestype=:scatter, label="Sampled points", xlims=(lb, ub), ylims=(-2, 120))
plot!(xs,sphere_function.(xs), label="True function")
```

Fitting RadialSurrogate with different radial basis:
```@example sphere_function
rad_1d_linear = RadialBasis(x,y,lb,ub)
rad_1d_cubic = RadialBasis(x,y,lb,ub,rad = cubicRadial)
rad_1d_multiquadric = RadialBasis(x,y,lb,ub, rad = multiquadricRadial)
plot(x, y, seriestype=:scatter, label="Sampled points", xlims=(lb, ub), ylims=(-2, 120))
plot!(xs,sphere_function.(xs), label="True function")
plot!(xs, rad_1d_linear.(xs), label="Radial surrogate with linear")
plot!(xs, rad_1d_cubic.(xs), label="Radial surrogate with cubic")
plot!(xs, rad_1d_multiquadric.(xs), label="Radial surrogate with multiquadric")
```

Fitting Lobachesky Surrogate with different values of hyperparameters alpha:
```@example sphere_function
loba_1 = LobacheskySurrogate(x,y,lb,ub)
loba_2 = LobacheskySurrogate(x,y,lb,ub,alpha = 1.5, n = 6)
loba_3 = LobacheskySurrogate(x,y,lb,ub,alpha = 0.3, n = 6)
plot(x, y, seriestype=:scatter, label="Sampled points", xlims=(lb, ub), ylims=(-2, 120))
plot!(xs,sphere_function.(xs), label="True function")
plot!(xs, loba_1.(xs), label="Lobachesky surrogate 1")
plot!(xs, loba_2.(xs), label="Lobachesky surrogate 2")
plot!(xs, loba_3.(xs), label="Lobachesky surrogate 3")
```

0 comments on commit 4ba334c

Please sign in to comment.