Skip to content

Commit 72ba413

Browse files
authored
Merge pull request #739 from JuliaRobotics/21Q1/feat/inflation
add GFND.inflation, and cleanup
2 parents 1043258 + 5cd5560 commit 72ba413

File tree

7 files changed

+45
-50
lines changed

7 files changed

+45
-50
lines changed

LICENSE

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2017-2020 NavAbility
1+
Copyright (c) 2017-2021 NavAbility
22

33
NOTICE: this license will be relaxed to be much more permissive soon.
44

@@ -18,13 +18,10 @@ Other general use or modification of the software beyond that of
1818
webservices or clouds (private or public) is permitted
1919
according to terms defined by Apache 2.0 or other library specifc licenses.
2020

21-
Copyright 2017-2020 NavAbility
21+
Copyright 2017-2021 NavAbility
2222

23-
Licensed under the Apache License, Version 2.0 (the "License");
23+
Licensed under a Market Limited version of the Apache License, Version 2.0 (the "License");
2424
you may not use this file except in compliance with the License.
25-
You may obtain a copy of the License at
26-
27-
http://www.apache.org/licenses/LICENSE-2.0
2825

2926
Unless required by applicable law or agreed to in writing, software
3027
distributed under the License is distributed on an "AS IS" BASIS,

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DistributedFactorGraphs"
22
uuid = "b5cc3c7e-6572-11e9-2517-99fb8daf2f04"
3-
version = "0.11.3"
3+
version = "0.12.0"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
@@ -35,7 +35,7 @@ Reexport = "0.2, 0.3, 0.4, 0.5, 1"
3535
Requires = "0.5, 0.6, 0.7, 0.8, 0.9, 0.10, 1"
3636
TimeZones = "1.3.1"
3737
Unmarshal = "0.4"
38-
julia = "1.2"
38+
julia = "1.4"
3939

4040
[extras]
4141
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"

src/entities/DFGFactor.jl

Lines changed: 25 additions & 20 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

5761
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)
62+
GenericFunctionNodeData(false, false, Int[], T())
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{T}(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

test/testBlocks.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function Base.convert(::Type{TestAbstractPrior}, d::PackedTestAbstractPrior)
5757
TestAbstractPrior()
5858
end
5959

60-
struct TestCCW{T} <: FactorOperationalMemory where {T<:FunctorInferenceType}
60+
struct TestCCW{T <: AbstractFactor} <: FactorOperationalMemory
6161
usrfnc!::T
6262
end
6363

@@ -69,7 +69,7 @@ DFG.getFactorOperationalMemoryType(par::NoSolverParams) = TestCCW
6969
DFG.rebuildFactorMetadata!(dfg::AbstractDFG{NoSolverParams}, fac::DFGFactor) = fac
7070

7171
function Base.convert(::Type{DFG.FunctionNodeData{TestCCW{F}}},
72-
d::DFG.PackedFunctionNodeData{<:PackedInferenceType}) where F<:FunctorInferenceType
72+
d::DFG.PackedFunctionNodeData{<:AbstractPackedFactor}) where {F <: DFG.AbstractFactor}
7373

7474
return DFG.FunctionNodeData(d.eliminated,
7575
d.potentialused,
@@ -78,19 +78,20 @@ function Base.convert(::Type{DFG.FunctionNodeData{TestCCW{F}}},
7878
d.multihypo,
7979
d.certainhypo,
8080
d.nullhypo,
81-
d.solveInProgress)
81+
d.solveInProgress,
82+
d.inflation)
8283
end
8384

84-
function Base.convert(::Type{DFG.PackedFunctionNodeData{P}}, d::DFG.FunctionNodeData{<:FactorOperationalMemory}) where P <: PackedInferenceType
85-
# mhstr = packmultihypo(d.fnc) # this is where certainhypo error occurs
85+
function Base.convert(::Type{DFG.PackedFunctionNodeData{P}}, d::DFG.FunctionNodeData{<:FactorOperationalMemory}) where P <: AbstractPackedFactor
8686
return DFG.PackedFunctionNodeData(d.eliminated,
8787
d.potentialused,
8888
d.edgeIDs,
8989
convert(P, d.fnc.usrfnc!),
9090
d.multihypo,
9191
d.certainhypo,
9292
d.nullhypo,
93-
d.solveInProgress)
93+
d.solveInProgress,
94+
d.inflation)
9495
end
9596

9697

0 commit comments

Comments
 (0)