Skip to content

Commit 56f2c7f

Browse files
committed
add GFND.inflation, and cleanup
1 parent 1043258 commit 56f2c7f

File tree

4 files changed

+34
-37
lines changed

4 files changed

+34
-37
lines changed

src/entities/DFGFactor.jl

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
# TODO consider changing this to AbstractFactor
66
abstract type AbstractFactor end
7-
const FunctorInferenceType = AbstractFactor
87
abstract type AbstractPackedFactor end
9-
const PackedInferenceType = AbstractPackedFactor
8+
9+
const FunctorInferenceType = AbstractFactor # will eventually deprecate
10+
const PackedInferenceType = AbstractPackedFactor # will eventually deprecate
1011

1112
abstract type AbstractPrior <: AbstractFactor end
1213
abstract type AbstractRelative <: AbstractFactor end
@@ -15,8 +16,8 @@ abstract type AbstractRelativeMinimize <: AbstractRelative end
1516

1617
# NOTE DF, Convolution is IIF idea, but DFG should know about "FactorOperationalMemory"
1718
# DF, IIF.CommonConvWrapper <: FactorOperationalMemory #
18-
# TODO resolve whether `<: Function` is really needed here
19-
abstract type FactorOperationalMemory <: Function end
19+
# NOTE was `<: Function` as unnecessary
20+
abstract type FactorOperationalMemory end # <: Function
2021
# TODO to be removed from DFG,
2122
# we can add to IIF or have IIF.CommonConvWrapper <: FactorOperationalMemory directly
2223
# abstract type ConvolutionObject <: FactorOperationalMemory end
@@ -46,36 +47,40 @@ mutable struct GenericFunctionNodeData{T<:Union{PackedInferenceType, FunctorInfe
4647
certainhypo::Vector{Int}
4748
nullhypo::Float64
4849
solveInProgress::Int
49-
50+
inflation::Float64
51+
# inner constructor needed for dual use
52+
# GenericFunctionNodeData{T}(x1::Bool,x2::Bool,x3,x4::T,args...) where T = new{T}(x1,x2,x3,x4,args...)
5053
# TODO deprecate all these inner constructors at end of DFG v0.9.x (was added for GFND.nullhypo::Float64 breaking change)
51-
GenericFunctionNodeData{T}(el,po,ed,fn,mu::Vector{<:Real},ce::Vector{Int},so::Int) where T = new{T}(el,po,ed,fn,mu,ce,0.0,so)
52-
GenericFunctionNodeData{T}(el,po,ed,fn,mu::Vector{<:Real},ce::Vector{Int},nu::Real,so::Int) where T = new{T}(el,po,ed,fn,mu,ce,nu,so)
54+
# GenericFunctionNodeData{T}(el,po,ed,fn,mu::Vector{<:Real},ce::Vector{Int},so::Int) where T =
55+
# new{T}(el,po,ed,fn,mu,ce,0.0,so)
56+
# GenericFunctionNodeData{T}(el,po,ed,fn,mu::Vector{<:Real},ce::Vector{Int},nu::Real,so::Int,infl::Real) where T = new{T}(el,po,ed,fn,mu,ce,nu,so,infl)
5357
end
5458

5559
## Constructors
5660

57-
GenericFunctionNodeData{T}() where T =
58-
GenericFunctionNodeData{T}(false, false, Int[], T(), Float64[], Int[], 0, 0)
59-
60-
function GenericFunctionNodeData(eliminated::Bool,
61-
potentialused::Bool,
62-
edgeIDs::Vector{Int},
63-
fnc::T,
64-
multihypo::Vector{<:Real}=Float64[],
65-
certainhypo::Vector{Int}=Int[],
66-
nullhypo::Real=0,
67-
solveInP::Int=0) where T
68-
return GenericFunctionNodeData{T}(eliminated, potentialused, edgeIDs, fnc, multihypo, certainhypo, nullhypo, solveInP)
61+
# GenericFunctionNodeData{T}() where T =
62+
# GenericFunctionNodeData{T}(false, false, Int[], T(), Float64[], Int[], 0, 0)
63+
64+
function GenericFunctionNodeData( eliminated::Bool,
65+
potentialused::Bool,
66+
edgeIDs::Vector{Int},
67+
fnc::T,
68+
multihypo::Vector{<:Real}=Float64[],
69+
certainhypo::Vector{Int}=Int[],
70+
nullhypo::Real=0,
71+
solveInP::Int=0,
72+
inflation::Real=0.0 ) where T
73+
return GenericFunctionNodeData(eliminated, potentialused, edgeIDs, fnc, multihypo, certainhypo, nullhypo, solveInP, inflation)
6974
end
7075

7176

7277
##------------------------------------------------------------------------------
7378
## PackedFunctionNodeData and FunctionNodeData
7479

75-
const PackedFunctionNodeData{T} = GenericFunctionNodeData{T} where T <: PackedInferenceType
80+
const PackedFunctionNodeData{T} = GenericFunctionNodeData{T} where T <: AbstractPackedFactor
7681
PackedFunctionNodeData(args...) = PackedFunctionNodeData{typeof(args[4])}(args...)
7782

78-
const FunctionNodeData{T} = GenericFunctionNodeData{T} where T <: Union{FunctorInferenceType, FactorOperationalMemory}
83+
const FunctionNodeData{T} = GenericFunctionNodeData{T} where T <: Union{AbstractFactor, FactorOperationalMemory}
7984
FunctionNodeData(args...) = FunctionNodeData{typeof(args[4])}(args...)
8085

8186

src/services/CompareUtils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function compareAll(Al::T,
130130
return true
131131
end
132132

133-
function compareAll(Al::T, Bl::T; show::Bool=true, skip::Vector{Symbol}=Symbol[])::Bool where T
133+
function compareAll(Al::T, Bl::T; show::Bool=true, skip::Vector{Symbol}=Symbol[]) where T
134134
@debug "Comparing types $T:"
135135
# @debug " Al = $Al"
136136
# @debug " Bl = $Bl"

src/services/DFGFactor.jl

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ Return reference to the user factor in `<:AbstractDFG` identified by `::Symbol`.
1818
"""
1919
getFactorFunction(fcd::GenericFunctionNodeData) = fcd.fnc.usrfnc!
2020
getFactorFunction(fc::DFGFactor) = getFactorFunction(getSolverData(fc))
21-
function getFactorFunction(dfg::G, fsym::Symbol) where G <: AbstractDFG
22-
getFactorFunction(getFactor(dfg, fsym))
23-
end
21+
getFactorFunction(dfg::AbstractDFG, fsym::Symbol) = getFactorFunction(getFactor(dfg, fsym))
2422

2523
"""
2624
$SIGNATURES
@@ -32,9 +30,8 @@ Notes
3230
"""
3331
getFactorType(data::GenericFunctionNodeData) = data.fnc.usrfnc!
3432
getFactorType(fct::DFGFactor) = getFactorType(getSolverData(fct))
35-
function getFactorType(dfg::G, lbl::Symbol) where G <: AbstractDFG
36-
getFactorType(getFactor(dfg, lbl))
37-
end
33+
getFactorType(dfg::AbstractDFG, lbl::Symbol) = getFactorType(getFactor(dfg, lbl))
34+
3835

3936
##==============================================================================
4037
## Factors
@@ -68,14 +65,8 @@ end
6865
# getTimestamp
6966

7067
setTimestamp(f::AbstractDFGFactor, ts::DateTime, timezone=localzone()) = setTimestamp(f, ZonedDateTime(ts, timezone))
71-
72-
function setTimestamp(f::DFGFactor, ts::ZonedDateTime)
73-
return DFGFactor(f.label, ts, f.nstime, f.tags, f.solverData, f.solvable, getfield(f,:_variableOrderSymbols))
74-
end
75-
76-
function setTimestamp(f::DFGFactorSummary, ts::ZonedDateTime)
77-
return DFGFactorSummary(f.label, ts, f.tags, f._variableOrderSymbols)
78-
end
68+
setTimestamp(f::DFGFactor, ts::ZonedDateTime) = DFGFactor(f.label, ts, f.nstime, f.tags, f.solverData, f.solvable, getfield(f,:_variableOrderSymbols))
69+
setTimestamp(f::DFGFactorSummary, ts::ZonedDateTime) = DFGFactorSummary(f.label, ts, f.tags, f._variableOrderSymbols)
7970

8071

8172
##------------------------------------------------------------------------------
@@ -105,7 +96,7 @@ $SIGNATURES
10596
Get the variable ordering for this factor.
10697
Should be equivalent to getNeighbors unless something was deleted in the graph.
10798
"""
108-
getVariableOrder(fct::DFGFactor)::Vector{Symbol} = fct._variableOrderSymbols
99+
getVariableOrder(fct::DFGFactor) = fct._variableOrderSymbols::Vector{Symbol}
109100
getVariableOrder(dfg::AbstractDFG, fct::Symbol) = getVariableOrder(getFactor(dfg, fct))
110101

111102
##------------------------------------------------------------------------------

src/services/Serialization.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any})::DFGFactor where G
307307
@debug "DECODING factor type = '$(datatype)' for factor '$label'"
308308
packtype = getTypeFromSerializationModule(dfg, Symbol("Packed"*datatype))
309309

310+
# FIXME type instability from nothing to T
310311
packed = nothing
311312
fullFactorData = nothing
312313
try

0 commit comments

Comments
 (0)