@@ -87,15 +87,6 @@ function (hypoCalcFactor::CalcFactorNormSq)(::Type{ManoptCalcConv}, M::AbstractM
87
87
return hypoCalcFactor (CalcConv, p)
88
88
end
89
89
90
- # TODO untested and unused
91
- # for deconv with the measurement a tangent vector
92
- # function (hypoCalcFactor::CalcFactorNormSq)(M::AbstractManifold, Xc::AbstractVector)
93
- # # M = hypoCalcFactor.manifold # calc factor has factor manifold in not variable that is needed here
94
- # ϵ = getPointIdentity(M)
95
- # X = get_vector(M, ϵ, Xc, DefaultOrthogonalBasis())
96
- # return hypoCalcFactor(CalcDeconv, X)
97
- # end
98
-
99
90
function _solveLambdaNumeric (
100
91
fcttype:: Union{F, <:Mixture{N_, F, S, T}} ,
101
92
hypoCalcFactor,
@@ -109,7 +100,6 @@ function _solveLambdaNumeric(
109
100
# the variable is a manifold point, we are working on the tangent plane in optim for now.
110
101
#
111
102
# TODO this is not general to all manifolds, should work for lie groups.
112
- # ϵ = identity_element(M, u0)
113
103
ϵ = getPointIdentity (variableType)
114
104
115
105
X0c = zero (MVector{getDimension (M),Float64})
@@ -142,34 +132,43 @@ function _solveLambdaNumeric(
142
132
return exp (M, ϵ, hat (M, ϵ, r. minimizer))
143
133
end
144
134
135
+ # # deconvolution with calcfactor wip
136
+ struct CalcDeconv end
137
+
138
+ function (cf:: CalcFactorNormSq )(:: Type{CalcDeconv} , meas)
139
+ res = cf (meas, map (vvh -> _getindex_anyn (vvh, cf. _sampleIdx), cf. _legacyParams)... )
140
+ return sum (x-> x^ 2 , res)
141
+ end
142
+
143
+ # for deconv with the measurement a tangent vector, can dispatch for other measurement types.
144
+ function (hypoCalcFactor:: CalcFactorNormSq )(:: Type{CalcDeconv} , M:: AbstractManifold , Xc:: AbstractVector )
145
+ ϵ = getPointIdentity (M)
146
+ X = get_vector (M, ϵ, Xc, DefaultOrthogonalBasis ())
147
+ return hypoCalcFactor (CalcDeconv, X)
148
+ end
145
149
146
- # TODO Consolidate with _solveLambdaNumeric, see #1374
147
- # TODO _solveLambdaNumericMeas assumes a measurement is always a tangent vector, confirm.
150
+ # NOTE Optim.jl version that assumes measurement is on the tangent
151
+ # TODO test / dev for n-ary factor deconv
152
+ # TODO Consolidate with _solveLambdaNumeric, see #1374
148
153
function _solveLambdaNumericMeas (
149
154
fcttype:: Union{F, <:Mixture{N_, F, S, T}} ,
150
- objResX:: Function ,
151
- residual:: AbstractVector{<:Real} ,
155
+ hypoCalcFactor,
152
156
X0,# ::AbstractVector{<:Real},
153
- variableType:: InferenceVariable ,
154
157
islen1:: Bool = false ,
155
158
) where {N_, F <: AbstractManifoldMinimize , S, T}
156
159
#
157
- # Assume measurement is on the tangent
158
160
M = getManifold (fcttype)
159
- # the variable is a manifold point, we are working on the tangent plane in optim for now.
160
161
ϵ = getPointIdentity (M)
161
162
X0c = zeros (manifold_dimension (M))
162
163
X0c .= vee (M, ϵ, X0)
163
164
164
- function cost (Xc)
165
- X = hat (M, ϵ, Xc)
166
- residual = objResX (X)
167
- return sum (residual .^ 2 )
168
- end
169
-
170
165
alg = islen1 ? Optim. BFGS () : Optim. NelderMead ()
171
166
172
- r = Optim. optimize (cost, X0c, alg)
167
+ r = Optim. optimize (
168
+ x-> hypoCalcFactor (CalcDeconv, M, x),
169
+ X0c,
170
+ alg
171
+ )
173
172
if ! Optim. converged (r)
174
173
@debug " Optim did not converge:" r
175
174
end
374
373
#
375
374
376
375
struct CalcConv end
377
- struct CalcDeconv end
378
376
379
377
_getindex_anyn (vec, n) = begin
380
378
len = length (vec)
@@ -397,7 +395,7 @@ function (cf::CalcFactorNormSq)(::Type{CalcConv}, x)
397
395
return sum (x-> x^ 2 , res)
398
396
end
399
397
400
- function _buildHypoCalcFactor (ccwl:: CommonConvWrapper , smpid:: Integer , _slack)
398
+ function _buildHypoCalcFactor (ccwl:: CommonConvWrapper , smpid:: Integer , _slack= nothing )
401
399
# build a view to the decision variable memory
402
400
varValsHypo = ccwl. varValsAll[][ccwl. hyporecipe. activehypo]
403
401
# create calc factor selected hypo and samples
0 commit comments