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:

using Surrogates
using Plots
default()

Define the objective function:

function sphere_function(x)
    return sum(x.^2)
end
sphere_function (generic function with 1 method)

The 1D case is just a simple parabola, let's plot it:

n = 20
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), legend=:top)
plot!(xs,sphere_function.(xs), label="True function", legend=:top)

Fitting RadialSurrogate with different radial basis:

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), legend=:top)
plot!(xs,sphere_function.(xs), label="True function", legend=:top)
plot!(xs, rad_1d_linear.(xs), label="Radial surrogate with linear", legend=:top)
plot!(xs, rad_1d_cubic.(xs), label="Radial surrogate with cubic", legend=:top)
plot!(xs, rad_1d_multiquadric.(xs), label="Radial surrogate with multiquadric", legend=:top)