@@ -42,12 +42,13 @@ function calcVariableDistanceExpectedFractional(
42
42
sfidx:: Integer ,
43
43
certainidx:: AbstractVector{<:Integer} ;
44
44
kappa:: Real = 3.0 ,
45
- readonlyVarVals = ccwl. varValsAll[][sfidx]
45
+ # readonlyVarVals = ccwl.varValsAll[][sfidx]
46
46
)
47
47
#
48
+ @assert sfidx == ccwl. varidx[] " ccwl.varidx[] is expected to be the same as sfidx"
48
49
varTypes = getVariableType .(ccwl. fullvariables)
49
50
if sfidx in certainidx
50
- msst_ = calcStdBasicSpread (varTypes[sfidx], readonlyVarVals )
51
+ msst_ = calcStdBasicSpread (varTypes[sfidx], ccwl . varValsAll[][sfidx] )
51
52
return kappa * msst_
52
53
end
53
54
# @assert !(sfidx in certainidx) "null hypo distance does not work for sfidx in certainidx"
@@ -68,7 +69,7 @@ function calcVariableDistanceExpectedFractional(
68
69
69
70
refMean = getCoordinates (
70
71
varTypes[sfidx],
71
- mean (getManifold (varTypes[sfidx]), readonlyVarVals ),
72
+ mean (getManifold (varTypes[sfidx]), ccwl . varValsAll[][sfidx] ),
72
73
)
73
74
74
75
# calc for uncertain and certain
@@ -107,7 +108,7 @@ function addEntropyOnManifold!(
107
108
# allocate to change SMatrix to MMatrix
108
109
X = allocate (get_vector (M, points[1 ], Xc, DefaultOrthogonalBasis ()))
109
110
110
- for idx = 1 : length (points)
111
+ for idx in 1 : length (points)
111
112
# build tangent coordinate random
112
113
for dim in dimIdx
113
114
if (p === :) || dim in p
@@ -145,7 +146,7 @@ function computeAcrossHypothesis!(
145
146
sfidx:: Int ,
146
147
maxlen:: Int ,
147
148
mani:: ManifoldsBase.AbstractManifold ; # maniAddOps::Tuple;
148
- destinationVarVals = deepcopy ( ccwl. varValsAll[][sfidx]),
149
+ # destinationVarVals = ccwl.varValsAll[][sfidx], # deepcopy
149
150
spreadNH:: Real = 5.0 ,
150
151
inflateCycles:: Int = 3 ,
151
152
skipSolve:: Bool = false ,
@@ -159,6 +160,7 @@ function computeAcrossHypothesis!(
159
160
activehypo = hyporecipe. activehypo
160
161
certainidx = hyporecipe. certainidx
161
162
163
+ @assert ccwl. varidx[] == sfidx " duplicate registers for solve for index should be the same in ccw.varidx"
162
164
@assert ccwl. hyporecipe. certainhypo == hyporecipe. certainidx " expected hyporecipe.certainidx to be the same as cached in ccw"
163
165
for (hypoidx, vars) in activehypo
164
166
count += 1
@@ -171,7 +173,8 @@ function computeAcrossHypothesis!(
171
173
ccwl. hyporecipe. activehypo[:] = vars
172
174
# end
173
175
174
- addEntr = view (destinationVarVals, allelements[count])
176
+ # ccwl.varValsAll[][ccwl.varidx[]] should be an alternate/duplicate memory from getVal(variable; solveKey)
177
+ addEntr = view (ccwl. varValsAll[][ccwl. varidx[]], allelements[count]) # destinationVarVals
175
178
176
179
# do proposal inflation step, see #1051
177
180
# consider duplicate convolution approximations for inflation off-zero
@@ -183,7 +186,7 @@ function computeAcrossHypothesis!(
183
186
sfidx,
184
187
certainidx;
185
188
kappa = ccwl. inflation,
186
- readonlyVarVals = destinationVarVals ,
189
+ # readonlyVarVals = ccwl.varValsAll[][ccwl.varidx[]] ,
187
190
)
188
191
addEntropyOnManifold! (
189
192
mani,
@@ -197,7 +200,7 @@ function computeAcrossHypothesis!(
197
200
if skipSolve
198
201
@warn (" skipping numerical solve operation" )
199
202
else
200
- approxConvOnElements! (destinationVarVals , ccwl, allelements[count], _slack)
203
+ approxConvOnElements! (ccwl . varValsAll[][ccwl . varidx[]] , ccwl, allelements[count], _slack)
201
204
end
202
205
end
203
206
elseif hypoidx != sfidx && hypoidx != 0
@@ -206,22 +209,22 @@ function computeAcrossHypothesis!(
206
209
# sfidx=2, hypoidx=3: 2 should take a value from 3
207
210
# sfidx=3, hypoidx=2: 3 should take a value from 2
208
211
# DEBUG sfidx=2, hypoidx=1 -- bad when do something like multihypo=[0.5;0.5] -- issue 424
209
- # destinationVarVals [:,allelements[count]] = view(ccwl.varValsAll[hypoidx],:,allelements[count])
212
+ # ccwl.varValsAll[][ccwl.varidx[]] [:,allelements[count]] = view(ccwl.varValsAll[hypoidx],:,allelements[count])
210
213
# NOTE make alternative case only operate as null hypo
211
- addEntr = view (destinationVarVals , allelements[count])
214
+ addEntr = view (ccwl . varValsAll[][ccwl . varidx[]] , allelements[count])
212
215
# dynamic estimate with user requested speadNH of how much noise to inject (inflation or nullhypo)
213
216
spreadDist =
214
- calcVariableDistanceExpectedFractional (ccwl, sfidx, certainidx; kappa = spreadNH,readonlyVarVals = destinationVarVals )
217
+ calcVariableDistanceExpectedFractional (ccwl, sfidx, certainidx; kappa = spreadNH) # ,readonlyVarVals = ccwl.varValsAll[][ccwl.varidx[]] )
215
218
addEntropyOnManifold! (mani, addEntr, 1 : getDimension (mani), spreadDist)
216
219
217
220
elseif hypoidx == 0
218
221
# basically do nothing since the factor is not active for these allelements[count]
219
222
# inject more entropy in nullhypo case
220
223
# add noise (entropy) to spread out search in convolution proposals
221
- addEntr = view (destinationVarVals , allelements[count])
224
+ addEntr = view (ccwl . varValsAll[][ccwl . varidx[]] , allelements[count])
222
225
# dynamic estimate with user requested speadNH of how much noise to inject (inflation or nullhypo)
223
226
spreadDist =
224
- calcVariableDistanceExpectedFractional (ccwl, sfidx, certainidx; kappa = spreadNH, readonlyVarVals = destinationVarVals )
227
+ calcVariableDistanceExpectedFractional (ccwl, sfidx, certainidx; kappa = spreadNH) # , readonlyVarVals = ccwl.varValsAll[][ccwl.varidx[]] )
225
228
# # make spread (1σ) equal to mean distance of other fractionals
226
229
addEntropyOnManifold! (mani, addEntr, 1 : getDimension (mani), spreadDist)
227
230
else
@@ -337,8 +340,7 @@ function evalPotentialSpecific(
337
340
# add user desired measurement values if 0 < length
338
341
# 2023Q2, ccwl.varValsAll always points at the variable.VND.val memory locations
339
342
# remember when doing approxConv to make a deepcopy of the destination memory first.
340
- destinationVarVals = deepcopy (ccwl. varValsAll[][sfidx])
341
- maxlen = _beforeSolveCCW! (ccwl, variables, destinationVarVals, sfidx, N; solveKey, needFreshMeasurements, measurement)
343
+ maxlen = _beforeSolveCCW! (ccwl, variables, sfidx, N; solveKey, needFreshMeasurements, measurement)
342
344
343
345
# Check which variables have been initialized
344
346
isinit = map (x -> isInitialized (x), variables)
@@ -367,7 +369,7 @@ function evalPotentialSpecific(
367
369
sfidx,
368
370
maxlen,
369
371
mani;
370
- destinationVarVals,
372
+ # destinationVarVals,
371
373
spreadNH,
372
374
inflateCycles,
373
375
skipSolve,
@@ -415,8 +417,7 @@ function evalPotentialSpecific(
415
417
#
416
418
417
419
# Prep computation variables
418
- destinationVarVals = deepcopy (ccwl. varValsAll[][sfidx])
419
- maxlen = _beforeSolveCCW! (ccwl, variables, destinationVarVals, sfidx, N; solveKey, needFreshMeasurements, measurement)
420
+ maxlen = _beforeSolveCCW! (ccwl, variables, sfidx, N; solveKey, needFreshMeasurements, measurement)
420
421
421
422
# # FIXME , NEEDS TO BE CLEANED UP AND WORK ON MANIFOLDS PROPER
422
423
fnc = ccwl. usrfnc!
@@ -622,7 +623,6 @@ function _evalFactorTemporary!(
622
623
solveKey:: Symbol = :default ,
623
624
newFactor:: Bool = true ,
624
625
_slack = nothing ,
625
- # FIXME ON FIRE ADD destinationVarVals,
626
626
buildgraphkw... ,
627
627
)
628
628
#
0 commit comments