Skip to content

Commit

Permalink
Merge pull request #641 from JuliaRobotics/hotfix/1Q20/specSampXi
Browse files Browse the repository at this point in the history
special sampler with full DFGVariable not VND
  • Loading branch information
dehann authored Mar 14, 2020
2 parents fb7be6d + 8f772fd commit d6ab7fb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/ApproxConv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function prepareCommonConvWrapper!(ccwl::CommonConvWrapper{T},
# get factor metadata -- TODO, populate
fmd = FactorMetadata()
# get variable node data
vnds = (x->getSolverData(x)).(Xi)
vnds = Xi # (x->getSolverData(x)).(Xi)
freshSamples!(ccwl, maxlen, fmd, vnds...)
# ccwl.measurement = getSample(ccwl.usrfnc!, maxlen) # ccwl.samplerfnc
if ccwl.specialzDim
Expand Down Expand Up @@ -256,7 +256,7 @@ function evalPotentialSpecific(Xi::Vector{DFGVariable},
nn = (N <= 0 ? size(getVal(Xi[1]),2) : N)
# ccwl.measurement = 0 < size(measurement[1],1) ? measurement : getSample(ccwl.usrfnc!, nn)
# ccwl.measurement = freshSamples(ccwl.usrfnc!, nn) # TODO make in-place
vnds = (x->getSolverData(x)).(Xi)
vnds = Xi # (x->getSolverData(x)).(Xi)
freshSamples!(ccwl, nn, FactorMetadata(), vnds...) # in-place version
if !ccwl.partial
return ccwl.measurement[1]
Expand Down Expand Up @@ -287,7 +287,7 @@ function evalPotentialSpecific(Xi::Vector{DFGVariable},
var = Statistics.var(val, dims=2) .+ 1e-3

# prep in case special samplers used
vnds = (x->getSolverData(x)).(Xi)
vnds = Xi # (x->getSolverData(x)).(Xi)
# determine amount share of null hypothesis particles
freshSamples!(ccwl, N, FactorMetadata(), vnds...)
# ccwl.measurement = getSample(ccwl.usrfnc!, N)
Expand Down Expand Up @@ -382,7 +382,7 @@ function approxConvBinary(arr::Array{Float64,2},
varidx::Int=2,
N::Int=size(arr,2),
fmd::FactorMetadata=FactorMetadata(),
vnds=VariableNodeData[] )
vnds=DFGVariable[] )
#
# N = N == 0 ? size(arr,2) : N
pts = zeros(outdims,N);
Expand Down
2 changes: 1 addition & 1 deletion src/FactorGraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ end
function calcZDim(usrfnc::T, Xi::Vector{<:DFGVariable})::Int where {T <: FunctorInferenceType}
# zdim = T != GenericMarginal ? size(getSample(usrfnc, 2)[1],1) : 0
zdim = if T != GenericMarginal
vnds = (x->getSolverData(x)).(Xi)
vnds = Xi # (x->getSolverData(x)).(Xi)
smpls = freshSamples(usrfnc, 2, FactorMetadata(), vnds...)[1]
size(smpls,1)
else
Expand Down
3 changes: 2 additions & 1 deletion src/SolverUtilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ function (ccw::CommonConvWrapper)(x::Vector{Float64})
ccw.params[ccw.varidx][ccw.cpt[Threads.threadid()].p, ccw.cpt[Threads.threadid()].particleidx] .= x #ccw.Y
end
# evaulate the user provided residual function with constructed set of parameters
@show typeof(ccw.usrfnc!)
ccw.usrfnc!(ccw.cpt[Threads.threadid()].res,
ccw.cpt[Threads.threadid()].factormetadata,
ccw.cpt[Threads.threadid()].particleidx,
Expand Down Expand Up @@ -345,13 +346,13 @@ function solveFactorMeasurements(dfg::AbstractDFG,
# varsyms = fcto._variableOrderSymbols
VV = (v->getVariable(dfg, v)).(varsyms)
vars = map(x->getPoints(getKDE(x)), VV) # varsyms
vnds = (v->getSolverData(v)).(VV)
fcttype = getFactorType(fcto)
zDim = getSolverData(fcto).fnc.zDim

N = size(vars[1])[2]
res = zeros(zDim)
ud = FactorMetadata()
vnds = VV # (v->getSolverData(v)).(VV)
meas = freshSamples(fcttype, N, ud, vnds)
# meas = getSample(fcttype, N)
meas0 = deepcopy(meas[1])
Expand Down

0 comments on commit d6ab7fb

Please sign in to comment.