Trying to test Surrogates.jl I have created this
using Surrogates
using Zygote
g = x -> x^2 + 5*x
x1 = sample(40,0,5,SobolSample())
y1 = g.(x1)
my_krig1 = Kriging(x1,y1,0,5;p=0.9)
d_my_krig1 = x -> my_krig1'(x)
d_g = x -> g'(x)
d_g(2.0) get me 9.0
d_my_krig1(2.0) give this error
MethodError: no method matching +(::NamedTuple{(:x, :y, :lb, :ub, :p, :theta, :mu, :b, :sigma, :inverse_of_R), Tuple{Vector{Float64}, Nothing, Nothing, Nothing, Float64, Float64, Nothing, Vector{Float64}, Nothing, Nothing}}, ::Base.RefValue{Any})
Closest candidates are:
+(::Any, ::Any, !Matched::Any, !Matched::Any...) at D:\Program Files\Julia-1.7.2\share\julia\base\operators.jl:655
+(!Matched::ChainRulesCore.AbstractThunk, ::Any) at D:\Program Files (x86)\Julia-1.7.2\.julia\packages\ChainRulesCore\ctmSK\src\tangent_arithmetic.jl:122
+(!Matched::ChainRulesCore.Tangent{P}, ::P) where P at D:\Program Files (x86)\Julia-1.7.2\.julia\packages\ChainRulesCore\ctmSK\src\tangent_arithmetic.jl:146
...
accum(::NamedTuple{(:x, :y, :lb, :ub, :p, :theta, :mu, :b, :sigma, :inverse_of_R), Tuple{Vector{Float64}, Nothing, Nothing, Nothing, Float64, Float64, Nothing, Vector{Float64}, Nothing, Nothing}}, ::Base.RefValue{Any})@lib.jl:17
accum(::NamedTuple{(:x, :y, :lb, :ub, :p, :theta, :mu, :b, :sigma, :inverse_of_R), Tuple{Vector{Float64}, Nothing, Nothing, Nothing, Float64, Float64, Nothing, Vector{Float64}, Nothing, Nothing}}, ::Base.RefValue{Any}, ::Nothing, ::Vararg{Nothing})@lib.jl:22
getindex@tuple.jl:29[inlined]
gradindex@reverse.jl:12[inlined]
Pullback@Kriging.jl:71[inlined]
(::typeof(∂(λ)))(::Float64)@interface2.jl:0
#60@interface.jl:45[inlined]
#64@interface.jl:104[inlined]
#5@Other: 1[inlined]
top-level scope@Local: 1[inlined]
I suppose there is some error in the parameters I passed to the function, but since this way seems working in the Surrogates tutorial I will be happy if someone can better explain me why this time is not working.