@@ -504,7 +504,6 @@ function _beforeSolveCCW!(
504504 F_:: Type{<:AbstractRelative} ,
505505 ccwl:: CommonConvWrapper{F} ,
506506 variables:: AbstractVector{<:DFGVariable} ,
507- # destVarVals::AbstractVector,
508507 sfidx:: Int ,
509508 N:: Integer ;
510509 measurement = Vector {Tuple{}} (),
@@ -519,46 +518,39 @@ function _beforeSolveCCW!(
519518 end
520519
521520 # in forward solve case, important to set which variable is being solved early in this sequence
521+ # set the 'solvefor' variable index -- i.e. which connected variable of the factor is being computed in this convolution.
522522 ccwl. varidx[] = sfidx
523+ # ccwl.varidx[] = findfirst(==(solvefor), getLabel.(variables))
524+
525+ # splice, type stable
526+ # make deepcopy of destination variable since multiple approxConv type computations should happen from different factors to the same variable
527+ tvarv = tuple (
528+ map (s-> getVal (s; solveKey), variables[1 : ccwl. varidx[]- 1 ])... ,
529+ deepcopy (getVal (variables[ccwl. varidx[]]; solveKey)), # deepcopy(ccwl.varValsAll[][sfidx]),
530+ map (s-> getVal (s; solveKey), variables[ccwl. varidx[]+ 1 : end ])... ,
531+ )
532+ ccwl. varValsAll[] = tvarv
523533
524- # TBD, order of fmd ccwl cf are a little weird and should be revised.
525534 # TODO , maxlen should parrot N (barring multi-/nullhypo issues)
526- # set the 'solvefor' variable index -- i.e. which connected variable of the factor is being computed in this convolution.
527- # ccwl.varidx[] = findfirst(==(solvefor), getLabel.(variables))
528535 # everybody use maxlen number of points in belief function estimation
529536 maxlen = maximum ((N, length .(ccwl. varValsAll[])... ,))
530-
531- # splice
532- # should be type stable
533- tvarv = tuple (
534- map (s-> getVal (s; solveKey), variables[1 : sfidx- 1 ])... ,
535- deepcopy (ccwl. varValsAll[][sfidx]), # destVarVals = deepcopy(ccwl.varValsAll[][sfidx])
536- map (s-> getVal (s; solveKey), variables[sfidx+ 1 : end ])... ,
537- )
538- # not type-stable
539- # varvals = [getVal(s; solveKey) for s in variables]
540- # varvals[sfidx] = destVarVals
541- # varvals_ = [varvals[1:sfidx-1]..., destVarVals, varvals[sfidx+1:end]...]
542- # tvarv = tuple(varvals...)
543-
544537
545- # @info "TYPES" typeof(ccwl.varValsAll[]) typeof(tvarv)
546- ccwl. varValsAll[] = tvarv
547- # ccwl.varValsAll[] = map(s->getVal(s; solveKey), tuple(variables...))
548- # # PLAN B, make deep copy of ccwl.varValsAll[ccwl.varidx[]] just before the numerical solve
549-
550- # maxlen, ccwl.varidx[] = _updateParamVec(variables, solvefor, ccwl.varValsAll, N; solveKey)
551- # # TODO , ensure all values (not just multihypothesis) is correctly used from here
552- # for (i,varVal) in enumerate(_varValsAll)
553- # resize!(ccwl.varValsAll[i],length(varVal))
554- # ccwl.varValsAll[i][:] = varVal #TODO Kyk hierna: this looks like it will effectively result in vnd.val memory being overwritten
555- # end
538+ # if solving for more or less points in destination
539+ if N != length (ccwl. varValsAll[][ccwl. varidx[]])
540+ varT = getVariableType (variables[ccwl. varidx[]])
541+ # make vector right length
542+ resize! (ccwl. varValsAll[][ccwl. varidx[]], N)
543+ # define any new memory that might have been allocated
544+ for i in 1 : N
545+ if ! isdefined (ccwl. varValsAll[][ccwl. varidx[]], i)
546+ ccwl. varValsAll[][ccwl. varidx[]][i] = getPointDefault (varT)
547+ end
548+ end
549+ end
556550
557- # TODO better consolidation still possible
558- # FIXME ON FIRE, what happens if this is a partial dimension factor? See #1246
559- # FIXME , confirm this is hypo sensitive selection from variables, better to use double indevariablesng for clarity getDimension(ccw.fullvariables[hypoidx[ccwl.varidx[]]])
560- xDim = getDimension (getVariableType (variables[ccwl. varidx[]])) # ccwl.varidx[]
561- # ccwl.xDim = xDim
551+ # FIXME , confirm what happens when this is a partial dimension factor? See #1246
552+ # indexing over all possible hypotheses
553+ xDim = getDimension (getVariableType (variables[ccwl. varidx[]]))
562554 # TODO maybe refactor different type or api call?
563555
564556 # setup the partial or complete decision variable dimensions for this ccwl object
@@ -567,7 +559,6 @@ function _beforeSolveCCW!(
567559 _setCCWDecisionDimsConv! (ccwl, xDim)
568560
569561 # FIXME do not divert Mixture for sampling
570-
571562 updateMeasurement! (ccwl, maxlen; needFreshMeasurements, measurement, _allowThreads= true )
572563
573564 # used in ccw functor for AbstractRelativeMinimize
@@ -584,7 +575,6 @@ function _beforeSolveCCW!(
584575 F_:: Type{<:AbstractPrior} ,
585576 ccwl:: CommonConvWrapper{F} ,
586577 variables:: AbstractVector{<:DFGVariable} ,
587- # destVarVals::AbstractVector,
588578 sfidx:: Int ,
589579 N:: Integer ;
590580 measurement = Vector {Tuple{}} (),
@@ -594,12 +584,7 @@ function _beforeSolveCCW!(
594584 # FIXME , NEEDS TO BE CLEANED UP AND WORK ON MANIFOLDS PROPER
595585
596586 ccwl. varidx[] = sfidx
597- # fnc = ccwl.usrfnc!
598- # sfidx = findfirst(getLabel.(variables) .== solvefor)
599587 @assert ccwl. varidx[] == 1 " Solving on Prior with CCW should have sfidx=1, priors are unary factors."
600- # @assert sfidx == 1 "Solving on Prior with CCW should have sfidx=1, priors are unary factors."
601- # ccwl.varidx[] = sfidx
602- # sfidx = 1 # why hardcoded to 1, maybe for only the AbstractPrior case here
603588
604589 # setup the partial or complete decision variable dimensions for this ccwl object
605590 # NOTE perhaps deconv has changed the decision variable list, so placed here during consolidation phase
0 commit comments