-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathParametricManopt.jl
More file actions
674 lines (546 loc) · 18.1 KB
/
ParametricManopt.jl
File metadata and controls
674 lines (546 loc) · 18.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
using Manopt
using FiniteDiff
using SparseDiffTools
using SparseArrays
# using ForwardDiff
# using Zygote
##
function getVarIntLabelMap(
vartypeslist::OrderedDict{DataType, Vector{Symbol}}
)
varlist_tuple = (values(vartypeslist)...,)
varlabelsAP = ArrayPartition{Symbol, typeof(varlist_tuple)}(varlist_tuple)
varIntLabel = OrderedDict(zip(varlabelsAP, collect(1:length(varlabelsAP))))
return varIntLabel, varlabelsAP
end
function CalcFactorResidual(
fg,
fct::DFGFactor,
varIntLabel
)
fac_func = getFactorType(fct)
varOrder = getVariableOrder(fct)
varOrderIdxs = getindex.(Ref(varIntLabel), varOrder)
M = getManifold(getFactorType(fct))
dims = manifold_dimension(M)
meas, iΣ = getFactorMeasurementParametric(fct)
sqrt_iΣ = convert(SMatrix{dims, dims}, sqrt(iΣ))
cache = preambleCache(fg, getVariable.(fg, varOrder), getFactorType(fct))
return CalcFactorResidual(
fct.label,
getFactorMechanics(fac_func),
tuple(varOrder...),
tuple(varOrderIdxs...),
meas,
sqrt_iΣ,
cache,
)
end
"""
CalcFactorResidualAP
Create an `ArrayPartition` of `CalcFactorResidual`s.
"""
function CalcFactorResidualAP(
fg::GraphsDFG,
factorLabels::Vector{Symbol},
varIntLabel::OrderedDict{Symbol, Int64}
)
factypes, typedict, alltypes = getFactorTypesCount(getFactor.(fg, factorLabels))
# skip non-numeric prior (MetaPrior)
#TODO test... remove MetaPrior{T} something like this
metaPriorKeys = filter(k->contains(string(k), "MetaPrior"), collect(keys(alltypes)))
delete!.(Ref(alltypes), metaPriorKeys)
parts = map(values(alltypes)) do labels
map(getFactor.(fg, labels)) do fct
CalcFactorResidual(fg, fct, varIntLabel)
end
end
parts_tuple = (parts...,)
return ArrayPartition{CalcFactorResidual, typeof(parts_tuple)}(parts_tuple)
end
function (cfm::CalcFactorResidual)(p::Vector)
meas = cfm.meas
points = map(idx->p[idx], cfm.varOrderIdxs)
return cfm.sqrt_iΣ * cfm(meas, points...)
end
function (cfm::CalcFactorResidual)(p::ArrayPartition)
points = map(idx->p.x[idx], cfm.varOrderIdxs)
return cfm.sqrt_iΣ * cfm(cfm.meas, points...)
end
# cost function f: M->ℝᵈ for Riemannian Levenberg-Marquardt
struct CostFres_cond!{PT, CFT}
points::PT
costfuns::ArrayPartition{CalcFactorResidual, CFT}
varLabels::Vector{Symbol}
end
function (costf::CostFres_cond!)(M::AbstractManifold, x::Vector, p::AbstractVector)
costf.points[1:length(p)] .= p
st = 1
for cfm_part in costf.costfuns.x
st = calcFactorResVec!(x, cfm_part, costf.points, st)
end
return x
end
struct CostFres!{CFT}
# points::PT #TODO RENAME - don't update this in functor, seperator static points only!
costfuns::ArrayPartition{CalcFactorResidual, CFT}
varLabels::Vector{Symbol} # vector for performance above ArrayPartition{Symbol}?
# varPoints::VPT
# sepLabels::Vector{Symbol}
# sepPoints::SPT
# facLabels::Vector{Symbol}
# add return_ranges to allow MultiThreaded
end
function calcFactorResVec!(
x::Vector{T},
cfm_part::Vector{<:CalcFactorResidual{FT, N, D}},
p::AbstractArray{T},
st::Int
) where {T, FT, N, D}
for cfm in cfm_part
x[st:st + D - 1] = cfm(p) #NOTE looks like do not broadcast here
st += D
end
return st
end
function calcFactorResVec_threaded!(x::Vector{T}, cfm_part::Vector{<:CalcFactorResidual}, p::AbstractArray{T}, st::Int) where T
l = getDimension(cfm_part[1]) # all should be the same
N = length(cfm_part)
chunkies = Iterators.partition(1:N, N ÷ Threads.nthreads())
Threads.@threads for chunki in collect(chunkies)
for i in chunki
r = range(st + l*(i - 1); length = l)
cfm = cfm_part[i]
x[r] = cfm(p) #NOTE looks like do not broadcast here
end
end
return st + l*N
end
function (costf::CostFres!{CFT})(M::AbstractManifold, x::Vector{T}, p::AbstractVector{T}) where {CFT,T}
st = 1
for cfm_part in costf.costfuns.x
# if length(cfm_part) > Threads.nthreads() * 10
# st = calcFactorResVec_threaded!(x, cfm_part, p, st)
# else
st = calcFactorResVec!(x, cfm_part, p, st)
# end
end
return x
end
## --------------------------------------------------------------------------------------------------------------
## jacobian of function for Riemannian Levenberg-Marquardt
## --------------------------------------------------------------------------------------------------------------
struct JacF_RLM!{CF, T, JC}
costF!::CF
X0::Vector{Float64}
X::T
q::T
res::Vector{Float64}
Jcache::JC
end
# function JacF_RLM!(M, costF!; basis_domain::AbstractBasis = DefaultOrthonormalBasis())
function JacF_RLM!(M, costF!, p, fg=nothing;
all_points=p,
basis_domain::AbstractBasis = DefaultOrthogonalBasis(),
is_sparse=!isnothing(fg)
)
res = reduce(vcat, map(f -> f(all_points), Vector(costF!.costfuns)))
X0 = zeros(manifold_dimension(M))
X = get_vector(M, p, X0, basis_domain)
q = exp(M, p, X)
if is_sparse
factLabels = collect(getproperty.(costF!.costfuns, :faclbl))
sparsity = eltype(res).(getSparsityPattern(fg, costF!.varLabels, factLabels))
colorvec = matrix_colors(sparsity)
else
sparsity = nothing
colorvec = 1:length(X0)
end
cache = FiniteDiff.JacobianCache(X0, res; colorvec, sparsity)
return JacF_RLM!(costF!, X0, X, q, res, cache)
end
# TODO addd M to JacF_RLM! and test this ipo closure
# function (jacF!::JacF_RLM!)(res, Xc)
# X = jacF!.X
# q = jacF!.q
# get_vector!(M, X, p, Xc, basis_domain)
# exp!(M, q, p, X)
# return jacF!.costF!(M, res, q)
# end
function (jacF!::JacF_RLM!)(
M::AbstractManifold,
J,
p::T;
# basis_domain::AbstractBasis = DefaultOrthonormalBasis(),
basis_domain::AbstractBasis = DefaultOrthogonalBasis(),
) where T
X0 = jacF!.X0
X = jacF!.X
q = jacF!.q
cache = jacF!.Jcache
fill!(X0, 0)
# TODO make sure closure performs (let, ::, or (jacF!::JacF_RLM!)(res, Xc))
function costf!(res, Xc)
get_vector!(M, X, p, Xc, basis_domain)
exp!(M, q, p, X)
jacF!.costF!(M, res, q)
end
FiniteDiff.finite_difference_jacobian!(
J,
costf!,
X0,
cache;
)
return J
end
# ϵ = getPointIdentity(M)
# function jaccost(res, Xc)
# exp!(M, q, ϵ, get_vector!(M, X, p, Xc, basis_domain))
# compose!(M, q, p, q)
# jacF!.costF!(M, res, q)
# end
# ManifoldDiff._jacobian!(
# J,
# (Xc)->jacF!.costF!(M, jacF!.res, exp!(M, q, p, get_vector!(M, X, p, Xc, basis_domain))),
# X0,
# ManifoldDiff.default_differential_backend()
# )
struct FactorGradient{A <: AbstractMatrix}
manifold::AbstractManifold
JacF!::JacF_RLM!
J::A
end
# TODO this function is not the sparsity pattern yet, it just fills in all entries from the biadjacency matrix
# TODO allow getting sparcity pattern for a subfg
# OLD 0.424040 seconds (940.11 k allocations: 45.512 MiB)
# NEW 0.001552 seconds (2.04 k allocations: 1.816 MiB)
function getSparsityPattern(fg, varLabels, factLabels)
biadj = getBiadjacencyMatrix(fg; varLabels, factLabels)
vdims = getDimension.(getVariable.(fg, biadj.varLabels))
fdims = getDimension.(getFactor.(fg, biadj.facLabels))
c_end = cumsum(vdims)
r_end = cumsum(fdims)
C_range = range.(c_end - vdims .+1, c_end)
R_range = range.(r_end - fdims .+1, r_end)
ROWS, COLS, _ = findnz(biadj.B)
iter = reduce(vcat, map(zip(ROWS, COLS)) do (R,C)
vec(CartesianIndices((R_range[R], C_range[C])))
end)
# vec(CartesianIndices((R_range[2], C_range[1])))
return sparse(getindex.(iter,1), getindex.(iter,2), ones(Bool, length(iter)))
end
# TODO only calculate marginal covariances
function covarianceFiniteDiff(M, jacF!::JacF_RLM!, p0)
# Jcache
X0 = fill!(deepcopy(jacF!.X0), 0)
function costf(Xc)
let res = jacF!.res, X = jacF!.X, q = jacF!.q, p0=p0
get_vector!(M, X, p0, Xc, DefaultOrthogonalBasis())
exp!(M, q, p0, X)
1/2*norm(jacF!.costF!(M, res, q))^2
end
end
H = FiniteDiff.finite_difference_hessian(costf, X0)
# inv(H)
Σ = try
Matrix(H) \ Matrix{eltype(H)}(I, size(H)...)
catch ex #TODO only catch correct exception and try with pinv as fallback in certain cases.
@warn "Hessian inverse failed" ex
# Σ = pinv(H)
nothing
end
return Σ
end
function qr_linear_subsolver!(sk, JJ, grad_f_c)
sk .= qr(JJ) \ grad_f_c
return sk
end
function solve_RLM(
fg,
varlabels = ls(fg),
faclabels = lsf(fg);
is_sparse = true,
finiteDiffCovariance = false,
solveKey::Symbol = :parametric,
linear_subsolver! = qr_linear_subsolver!,
kwargs...
)
# get the manifold and variable types
vars = getVariable.(fg, varlabels)
M, varTypes, vartypeslist = buildGraphSolveManifold(vars)
varIntLabel, varlabelsAP = getVarIntLabelMap(vartypeslist)
#Can use varIntLabel (because its an OrderedDict), but varLabelsAP makes the ArrayPartition.
p0 = map(varlabelsAP) do label
getVal(fg, label; solveKey)[1]
end
# create an ArrayPartition{CalcFactorResidual} for faclabels
calcfacs = CalcFactorResidualAP(fg, faclabels, varIntLabel)
#cost and jacobian functions
# cost function f: M->ℝᵈ for Riemannian Levenberg-Marquardt
costF! = CostFres!(calcfacs, collect(varlabelsAP))
# jacobian of function for Riemannian Levenberg-Marquardt
jacF! = JacF_RLM!(M, costF!, p0, fg; is_sparse)
num_components = length(jacF!.res)
initial_residual_values = zeros(num_components)
# initial_jacobian_f not type stable, but function barrier so should be ok.
initial_jacobian_f = is_sparse ?
jacF!.Jcache.sparsity :
zeros(num_components, manifold_dimension(M))
lm_r = Manopt.LevenbergMarquardt!(
M,
costF!,
jacF!,
p0,
num_components;
evaluation=InplaceEvaluation(),
jacobian_tangent_basis = DefaultOrthogonalBasis(),
initial_residual_values,
initial_jacobian_f,
linear_subsolver!,
kwargs...
)
if length(initial_residual_values) < 1000
if finiteDiffCovariance
# TODO this seems to be correct, but way to slow
Σ = covarianceFiniteDiff(M, jacF!, lm_r)
else
# TODO make sure J initial_jacobian_f is updated, otherwise recalc jacF!(M, J, lm_r) # lm_r === p0
J = initial_jacobian_f
H = J'J # approx
Σ = H \ Matrix{eltype(H)}(I, size(H)...)
# Σ = pinv(H)
end
else
@warn "Not estimating a Dense Covariance $(size(initial_jacobian_f))"
Σ = nothing
end
return M, varlabelsAP, lm_r, Σ
end
# nlso = NonlinearLeastSquaresObjective(
# costF!,
# jacF!,
# num_components;
# evaluation = InplaceEvaluation(),
# jacobian_tangent_basis = DefaultOrthogonalBasis(),
# )
# @debug "starting solver"
# lm_r = LevenbergMarquardt!(
# M, nlso, p0;
# evaluation = InplaceEvaluation(),
# jacobian_tangent_basis = DefaultOrthogonalBasis(),
# initial_residual_values,
# initial_jacobian_f,
# kwargs...
# )
function solve_RLM_conditional(
fg,
frontals::Vector{Symbol} = ls(fg),
separators::Vector{Symbol} = setdiff(ls(fg), frontals);
is_sparse=false,
finiteDiffCovariance=true,
solveKey::Symbol = :parametric,
kwargs...
)
is_sparse && error("Sparse solve_RLM_conditional not supported yet")
# get the subgraph formed by all frontals, separators and fully connected factors
varlabels = union(frontals, separators)
faclabels = sortDFG(setdiff(getNeighborhood(fg, varlabels, 1), varlabels))
filter!(faclabels) do fl
return issubset(getVariableOrder(fg, fl), varlabels)
end
frontal_vars = getVariable.(fg, frontals)
separator_vars = getVariable.(fg, separators)
# so the subgraph consists of varlabels(frontals + separators) and faclabels
_, _, frontal_vartypeslist = getVariableTypesCount(getVariable.(fg,frontals))
frontal_varIntLabel, frontal_varlabelsAP = getVarIntLabelMap(frontal_vartypeslist)
if isempty(separators)
separator_vartypeslist = OrderedDict{DataType, Vector{Symbol}}()
separator_varlabelsAP = ArrayPartition{Symbol,Tuple}(())
else
_, _, separator_vartypeslist = getVariableTypesCount(getVariable.(fg,separators))
seperator_varIntLabel, separator_varlabelsAP = getVarIntLabelMap(separator_vartypeslist)
end
all_varlabelsAP = ArrayPartition((frontal_varlabelsAP.x..., separator_varlabelsAP.x...))
all_points = map(all_varlabelsAP) do label
getVal(fg, label; solveKey)[1]
end
p0 = ArrayPartition(all_points.x[1:length(frontal_varlabelsAP.x)])
all_varIntLabel = OrderedDict{Symbol,Int}(
map(enumerate(all_varlabelsAP)) do (i,l)
l=>i
end
)
# varIntLabel_frontals = filter(p->first(p) in frontals, varIntLabel)
# varIntLabel_separators = filter(p->first(p) in separators, varIntLabel)
calcfacs = CalcFactorResidualAP(fg, faclabels, all_varIntLabel)
# get the manifold and variable types
M, varTypes, vartypeslist = buildGraphSolveManifold(frontal_vars)
#cost and jacobian functions
# cost function f: M->ℝᵈ for Riemannian Levenberg-Marquardt
costF! = CostFres_cond!(all_points, calcfacs, Vector{Symbol}(collect(all_varlabelsAP)))
# jacobian of function for Riemannian Levenberg-Marquardt
jacF! = JacF_RLM!(M, costF!, p0, fg; all_points, is_sparse)
num_components = length(jacF!.res)
initial_residual_values = zeros(num_components)
initial_jacobian_f = is_sparse ?
jacF!.Jcache.sparsity :
zeros(num_components, manifold_dimension(M))
lm_r = LevenbergMarquardt(
M,
costF!,
jacF!,
p0,
num_components;
evaluation=InplaceEvaluation(),
initial_residual_values,
initial_jacobian_f,
kwargs...
)
if finiteDiffCovariance
Σ = covarianceFiniteDiff(M, jacF!, lm_r)
else
J = initial_jacobian_f
Σ = pinv(J'J)
end
return M, all_varlabelsAP, lm_r, Σ
end
#HEX solve
# sparse J 0.025235 seconds (133.65 k allocations: 9.964 MiB
# new1 0.013486 seconds (36.16 k allocations: 2.593 MiB)
# new2 0.010764 seconds (34.61 k allocations: 3.111 MiB)
# dense J 0.022079 seconds (283.54 k allocations: 18.146 MiB)
function autoinitParametric!(
fg,
varorderIds = getInitOrderParametric(fg);
reinit = false,
kwargs...
)
init_labels = @showprogress map(varorderIds) do vIdx
autoinitParametric!(fg, vIdx; reinit, kwargs...)
end
filter!(!isnothing, init_labels)
return init_labels
end
function autoinitParametric!(dfg::AbstractDFG, initme::Symbol; kwargs...)
return autoinitParametric!(dfg, getVariable(dfg, initme); kwargs...)
end
function autoinitParametric!(
dfg::AbstractDFG,
xi::DFGVariable;
solveKey = :parametric,
reinit::Bool = false,
perturb_point::Bool=false,
kwargs...,
)
#
initme = getLabel(xi)
vnd = getVariableState(xi, solveKey)
# don't initialize a variable more than once
if reinit || !isInitialized(xi, solveKey)
# frontals - initme
# separators - inifrom
initfrom = ls2(dfg, initme)
filter!(initfrom) do vl
return isInitialized(dfg, vl, solveKey)
end
# nothing to initialize if no initialized neighbors or priors
if isempty(initfrom) && !any(isPrior.(dfg, listNeighbors(dfg, initme)))
return false
end
vnd::VariableNodeData = getVariableState(xi, solveKey)
if perturb_point
_M = getManifold(xi)
p = vnd.val[1]
vnd.val[1] = exp(
_M,
p,
get_vector(
_M,
p,
randn(manifold_dimension(_M))*10^-6,
DefaultOrthogonalBasis()
)
)
end
M, vartypeslist, lm_r, Σ = solve_RLM_conditional(dfg, [initme], initfrom; solveKey, kwargs...)
val = lm_r[1]
vnd.val[1] = val
!isnothing(Σ) && (vnd.bw .= Σ)
# updateSolverDataParametric!(vnd, val, Σ)
vnd.initialized = true
#fill in ppe as mean
Xc::Vector{Float64} = collect(getCoordinates(getVariableType(xi), val))
ppe = MeanMaxPPE(solveKey, Xc, Xc, Xc)
getPPEDict(xi)[solveKey] = ppe
result = true
else
result = false
end
return result#isInitialized(xi, solveKey)
end
"""
$SIGNATURES
Batch parametric graph solve using Riemannian Levenberg Marquardt.
"""
solveGraphParametric(args...; kwargs...) = solve_RLM(args...; kwargs...)
function DFG.solveGraphParametric!(
fg::AbstractDFG,
args...;
init::Bool = false,
solveKey::Symbol = :parametric,
is_sparse = true,
# debug, stopping_criterion, damping_term_min=1e-2,
# expect_zero_residual=true,
kwargs...
)
# make sure variables has solverData, see #1637
makeSolverData!(fg; solveKey)
if !(:parametric in fg.solverParams.algorithms)
addParametricSolver!(fg; init = init)
elseif init
error("TODO: not implemented")
end
M, v, r, Σ = solve_RLM(fg, args...; is_sparse, kwargs...)
updateParametricSolution!(fg, M, v, r, Σ)
return M, v, r, Σ
end
## Check when time and delete if it can't be improved, curretnly ArrayPartition works best
#=
using FunctionWrappers: FunctionWrapper
# call with
calcfacs = CalcFactorResidualWrapper(fg, faclabels, varIntLabel, all_points)
costF! = CostF_RLM_WRAP2!(all_points, calcfacs, map(cfm->size(cfm.obj.x.iΣ,1), calcfacs))
function CalcFactorResidualWrapper(fg, factorLabels::Vector{Symbol}, varIntLabel::OrderedDict{Symbol, Int64}, points::ArrayPartition)
factypes, typedict, alltypes = getFactorTypesCount(getFactor.(fg, factorLabels))
# skip non-numeric prior (MetaPrior)
#TODO test... remove MetaPrior{T} something like this
metaPriorKeys = filter(k->contains(string(k), "MetaPrior"), collect(keys(alltypes)))
delete!.(Ref(alltypes), metaPriorKeys)
calcfacs = map(factorLabels) do labels
fct = getFactor(fg, labels)
# moet ek 'n view in p0 in maak wat jy net p0 update en CFM view automaties, toets dit...
cfm = IIF.CalcFactorResidual(fg, fct, varIntLabel, points)
# return FunctionWrapper{Vector{Float64}, Tuple{typeof(points)}}(cfm)
return FunctionWrapper{Vector{Float64}, Tuple{}}(cfm)
end
return calcfacs
end
struct CostF_RLM_WRAP2!{PT, CFW}
points::PT
costfuns::Vector{CFW}
retdims::Vector{Int}
end
function (cost::CostF_RLM_WRAP2!)(M::AbstractManifold, x::Vector{T}, p::AbstractVector{T}) where T
# x .= reduce(vcat, map(f -> f(p), cost.costfuns))
# x .= reduce(vcat, map(f -> f(), cost.costfuns))
st = 1
for (d, f) in zip(cost.retdims, cost.costfuns)
x[st:st + d - 1] .= f(p)
# x[st:st + d - 1] .= f()
# fx = f.obj.x
# x[st:st + d - 1] = fx.sqrt_iΣ * fx(fx.meas, fx.points...)
st += d
end
return x
end
=#