# 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)

rad_1d_linear = RadialBasis(x,y,lb,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)
plot!(xs, rad_1d_multiquadric.(xs), label="Radial surrogate with multiquadric", legend=:top)
loba_1 = LobachevskySurrogate(x,y,lb,ub)
plot!(xs, loba_3.(xs), label="Lobachevsky surrogate 3", legend=:top)