Skip to content

Commit

Permalink
Lobachesky AD compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
ludoro committed Sep 12, 2019
1 parent 1ad1181 commit e2eeadb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
8 changes: 2 additions & 6 deletions src/Lobachesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,8 @@ function LobacheskySurrogate(x,y,alpha,n::Int,lb,ub)
end

function (loba::LobacheskySurrogate)(val)
val = collect(val)
res = zero(eltype(loba.y[1]))
for j = 1:length(loba.x)
res = res + loba.coeff[j]*phi_njND(val,loba.x[j],loba.alpha,loba.n)
end
return res
p = [phi_njND(val,loba.x[j],loba.alpha,loba.n) for j=1:length(loba.x)]
return loba.coeff'*p
end

function add_point!(loba::LobacheskySurrogate,x_new,y_new)
Expand Down
3 changes: 1 addition & 2 deletions test/AD_compatibility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,12 @@ g = x -> Tracker.gradient(my_inverse,x)
g([2.0,5.0])

#Lobachesky
#=
alpha = [1.4,1.4]
n = 4
my_loba_ND = LobacheskySurrogate(x,y,alpha,n,lb,ub)
g = x -> Tracker.gradient(my_loba_ND,x)
g([2.0,5.0])
=#


#Neural Surrogate Need ForwardDiff2

Expand Down
2 changes: 1 addition & 1 deletion test/lobachesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ n = 8
x = sample(3200,lb,ub,SobolSample())
y = obj.(x)
my_loba_ND = LobacheskySurrogate(x,y,alpha,n,lb,ub)

pred = my_loba_ND((1.0,2.0))
#ND

int_ND = lobachesky_integral(my_loba_ND,lb,ub)
Expand Down

0 comments on commit e2eeadb

Please sign in to comment.