Skip to content

Commit

Permalink
Update src/prune.jl
Browse files Browse the repository at this point in the history
Co-authored-by: Tyler Becker <52610169+WhiffleFish@users.noreply.github.com>
  • Loading branch information
dylan-asmar and WhiffleFish authored Jul 10, 2024
1 parent 03a751e commit 4794b0e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/prune.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,18 @@ function prune!(tree::SARSOPTree)
end
end

@inline function intersection_distance(α1, α2, b)
diff = α1 - α2
dot_b = dot(diff, b)
dot_diff = dot(diff, diff)
d = dot_b / sqrt(dot_diff)
return d
function intersection_distance(α1, α2, b)
dot_sum = 0.0
I,B = b.nzind, b.nzval
for _i eachindex(I)
i = I[_i]
dot_sum += (α1[i] - α2[i])*B[_i]
end
s = 0.0
for i eachindex(α1, α2)
s += (α1[i] - α2[i])^2
end
return dot_sum / sqrt(s)
end

function prune_alpha!(tree::SARSOPTree, δ, eps=0.0)
Expand Down

0 comments on commit 4794b0e

Please sign in to comment.