Skip to content

Commit 8fa58f3

Browse files
authored
Merge pull request #1346 from JuliaRobotics/21Q3/enh/matating_cost
Mutating function in _solveLambdaNumeric cost
2 parents 9415fb6 + 3955af8 commit 8fa58f3

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ FunctionalStateMachine = "0.2.9"
5555
JLD2 = "0.3, 0.4"
5656
JSON2 = "0.3"
5757
KernelDensityEstimate = "0.5.6"
58-
Manifolds = "0.6"
59-
ManifoldsBase = "0.11, 0.12"
58+
Manifolds = "0.6.3"
59+
ManifoldsBase = "0.12.6"
6060
MetaGraphs = "0.6.4"
6161
NLSolversBase = "7.6"
6262
NLsolve = "3, 4"

src/NumericalCalculations.jl

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,27 @@ function _solveLambdaNumeric( fcttype::Union{F,<:Mixture{N_,F,S,T}},
9494
# norm(M, p, X) == distance(M, p, X)
9595
#TODO fix closure for performance
9696
fM = getManifold(fcttype)
97-
function cost(Xc)
98-
p = exp(M, ϵ, hat(M, ϵ, Xc))
97+
function cost(p, X, Xc)
98+
hat!(M, X, ϵ, Xc)
99+
exp!(M, p, ϵ, X)
99100
# X = objResX(p)
100101
# return norm(fM, p, X)^2 #TODO the manifold of p and X are not always the same
101102
#options getPointIdentity or leave it to factor
102103
residual = objResX(p)
103104
return sum(residual.^2)
104105
end
105106

106-
# separate statements to try improve type-stability
107-
r = if islen1
108-
Optim.optimize(cost, X0c, Optim.BFGS())
109-
else
110-
Optim.optimize(cost, X0c, Optim.NelderMead())
111-
end
112-
107+
# # separate statements to try improve type-stability
108+
# r = if islen1
109+
# Optim.optimize(cost, X0c, Optim.BFGS())
110+
# else
111+
# Optim.optimize(cost, X0c, Optim.NelderMead())
112+
# end
113+
alg = islen1 ? Optim.BFGS() : Optim.NelderMead()
114+
X0 = hat(M, ϵ, X0c)
115+
p0 = exp(M, ϵ, X0)
116+
r = Optim.optimize(Xc->cost(p0, X0, Xc), X0c, alg)
117+
113118
return exp(M, ϵ, hat(M, ϵ, r.minimizer))
114119

115120
end

0 commit comments

Comments
 (0)