Skip to content

Commit 47ea555

Browse files
committed
Add numerical correctness tests
1 parent 5f87d45 commit 47ea555

7 files changed

Lines changed: 2116 additions & 4 deletions

File tree

docs/src/release_notes.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
---
44

5+
## Version 0.2.5 - Unreleased
6+
7+
#### Fixed
8+
9+
- Fixed Gaussian min-sum frozen variable and edge message updates so frozen
10+
outgoing quadratic messages remain unchanged until explicitly unfrozen.
11+
- Fixed inference-aware discrete factor updates so invalid initializing unary
12+
updates are rejected before mutating the graph.
13+
14+
#### Tests
15+
16+
- Added numerical correctness coverage for Gaussian schedules, damping,
17+
freeze/unfreeze message preservation, tree exactness and selected
18+
step-by-step sweeps, root refreshes, warm-start updates, dynamic stale-state
19+
rejection, residual partial updates, WLS agreement for correlated vector
20+
models, and discrete brute-force references.
21+
22+
---
23+
524
## Version 0.2.4 - 2026-06-05
625

726
#### Changed

src/inference/core.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,35 @@ function addFactor!(
10371037
)
10381038
end
10391039

1040+
function validateDiscreteInferenceFactorUpdate(
1041+
graph::DiscreteFactorGraph,
1042+
factorRef::FactorRef;
1043+
table = nothing,
1044+
initialize::Union{Nothing, Bool} = nothing
1045+
)
1046+
factorIdx = factorIndex(graph, factorRef)
1047+
current = graph.factors[factorIdx]
1048+
nextTable = table === nothing ? current.table : table
1049+
nextInitialize = initialize === nothing ? current.initialize : initialize
1050+
updated = DiscreteFactor(
1051+
current.id,
1052+
current.variables,
1053+
nextTable;
1054+
label = current.label,
1055+
initialize = nextInitialize
1056+
)
1057+
1058+
validateUpdatedFactorDimensions(current, updated)
1059+
validateFactor(updated, graph.variables, graph.referenceIndex)
1060+
validateUpdatedInitializingUnaryFactors(graph, factorIdx, updated)
1061+
1062+
if updated.initialize
1063+
initialMessageFromUnaryFactor(updated)
1064+
end
1065+
1066+
return nothing
1067+
end
1068+
10401069
function updateFactor!(
10411070
graph::DiscreteFactorGraph,
10421071
inference::DiscreteInference,

src/inference/discreteMinSum.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,12 @@ function updateFactor!(
595595
initialize::Union{Nothing, Bool} = nothing
596596
)
597597
assertDiscreteMinSumInferenceMatchesGraph(graph, inference)
598+
validateDiscreteInferenceFactorUpdate(
599+
graph,
600+
factorRef;
601+
table = table,
602+
initialize = initialize
603+
)
598604

599605
updated = updateFactor!(
600606
graph,

src/inference/discreteSumProduct.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,12 @@ function updateFactor!(
550550
initialize::Union{Nothing, Bool} = nothing
551551
)
552552
assertDiscreteSumProductInferenceMatchesGraph(graph, inference)
553+
validateDiscreteInferenceFactorUpdate(
554+
graph,
555+
factorRef;
556+
table = table,
557+
initialize = initialize
558+
)
553559

554560
updated = updateFactor!(
555561
graph,

src/inference/gaussianMinSum.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,14 +1037,14 @@ function variableToFactorMessage!(
10371037
)
10381038
edge = graph.edges[edgeId]
10391039

1040-
fill!(output.J, 0.0)
1041-
fill!(output.h, 0.0)
1042-
output.c = 0.0
1043-
10441040
if inference.frozenEdges[edgeId] || inference.frozenVariables[edge.variableIndex]
10451041
return output
10461042
end
10471043

1044+
fill!(output.J, 0.0)
1045+
fill!(output.h, 0.0)
1046+
output.c = 0.0
1047+
10481048
for incomingEdgeId in graph.variableEdges[edge.variableIndex]
10491049
if incomingEdgeId == edgeId
10501050
continue

0 commit comments

Comments
 (0)