Skip to content

[TESTING] improve tree testing of factors per clique #514

Open
@dehann

Description

@dehann

Tasks,

1: Include second example from #458

Example 2 from #458 (comment) should be included here:

@warn "Test for Example 2 from 458 must still be coded."

Note that Example 1 is already built just above:

@testset "Test clique factors, #458 Example 1" begin

2. Add more Factor checks to tree tests

Many tests on trees but these do not yet check which factors are in which clique (as was done in example above):

@testset "Test Caesar Ring 1D symbolic tree construction" begin

vo = [:l1, :l2, :x1, :x2, :x3]

eo = [:x1; :l3; :l1; :x5; :x2; :l2; :x4; :x3]

3. Additional consolidation of previous half-baked tests

previous Kaess test case:

# Michael reference -- x2->x1, x2->x3, x2->x4, x2->l1, x4->x3, l1->x3, l1->x4

Can readily be merged with this newer and improved testing here:
vo = [:l1, :l2, :x1, :x2, :x3]

4. Check to ensure Previous Factor and Subgraph Factors match

This "newer" factor per clique test:

C3_fg = buildCliqSubgraph(fg, tree, getCliq(tree, :x0) )
# drawGraph(C3_fg, show=true)
C3_fcts = [:x0l0f1;:x0l1f1;:x0x1f1;:x0f1]
@test intersect(ls(C3_fg), [:x0; :x1; :l0; :l1]) |> length == 4
@test intersect(lsf(C3_fg), C3_fcts) |> length == length(C3_fcts)

does not yet cover the previous main use case where factors were separately searched and described in the BayesTreeNodeData.potentials field:
fctsyms = getFactorsAmongVariablesOnly(dfg, varlist, unused=true )
# filter only factors connected to frontals (for upward)
frtfcts = union(map(x->ls(dfg, x), getCliqFrontalVarIds(cliq))...)
fctsyms = intersect(fctsyms, frtfcts)
getData(cliq).potentials = fctsyms
getData(cliq).partialpotential = Vector{Bool}(undef, length(fctsyms))
fcts = map(x->getFactor(dfg, x), fctsyms)
getData(cliq).partialpotential = map(x->isPartial(x), fcts)
for fct in fcts
solverData(fct).potentialused = true
end
@info "finding all frontals for down WIP"
ffctsyms = getCliqFactorsFromFrontals(dfg, cliq, Symbol[], inseparator=false, unused=false, solvable=solvable)
# fnsyms = getCliqVarsWithFrontalNeighbors(csmc.dfg, csmc.cliq)
getData(cliq).dwnPotentials = ffctsyms
getData(cliq).dwnPartialPotential = map(x->isPartial(getFactor(dfg,x)), ffctsyms )

Clearly some consolidation is required between new CSM code, and previous .potentials list approach -- but that can be done later after sufficient tests are in place that ensure a few test trees are being built properly. Starting with a simple tests that compares buildCliqSubgraph with existing BTND.potentials is probably easiest way to go.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions