Skip to content

Commit 50bad37

Browse files
authored
Merge branch 'master' into feature/177_sentinels
2 parents fd4b92d + a824889 commit 50bad37

File tree

17 files changed

+237
-245
lines changed

17 files changed

+237
-245
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ jobs:
2222
include:
2323
- julia: 1.2
2424
env: IIF_TEST=true
25+
if: NOT branch =~ ^release.*$
2526
- stage: "Documentation"
2627
julia: 1.0
2728
os: linux
2829
script:
29-
- julia -e 'import Pkg; Pkg.add("Documenter"); Pkg.add("Neo4j"); Pkg.add("GraphPlot")'
30-
- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd()));
31-
Pkg.instantiate()'
30+
- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
3231
- julia --project=docs/ docs/make.jl
3332
after_success: skip
33+
fast_finish: true
3434

3535
notifications:
3636
email: false
3737

3838
matrix:
3939
allow_failures:
4040
- julia: nightly
41-
- env: IIF_TEST=true
41+
# - env: IIF_TEST=true
4242

4343
# Set the password for Neo4j to neo4j:test
4444
before_script:

docs/Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3-
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
43

54
[compat]
6-
Documenter = "~0.21"
5+
Documenter = "0.23"

docs/make.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Documenter
2-
using DataFrames
32
using DistributedFactorGraphs
43

54
makedocs(

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ function getVariable(dfg::CloudGraphsDFG, variableId::Int64)::DFGVariable
186186
# props["label"] = Symbol(variable.label)
187187
timestamp = DateTime(props["timestamp"])
188188
tags = JSON2.read(props["tags"], Vector{Symbol})
189-
estimateDict = JSON2.read(props["estimateDict"], Dict{Symbol, Dict{Symbol, VariableEstimate}})
189+
#TODO this will work for some time, but unpacking in an <: AbstractPointParametricEst would be lekker.
190+
estimateDict = JSON2.read(props["estimateDict"], Dict{Symbol, MeanMaxPPE})
190191
smallData = nothing
191192
smallData = JSON2.read(props["smallData"], Dict{String, String})
192193

src/DistributedFactorGraphs.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ include("entities/AbstractDFGSummary.jl")
1818

1919
export AbstractDFG
2020
export AbstractParams, NoSolverParams
21-
export DFGNode, DFGVariable, DFGFactor
21+
export DFGNode, DFGVariable, DFGFactor, AbstractDFGVariable, AbstractDFGFactor
2222
export InferenceType, PackedInferenceType, FunctorInferenceType, InferenceVariable, ConvolutionObject
2323
export FunctorSingleton, FunctorPairwise, FunctorPairwiseMinimize
2424
export label, timestamp, tags, estimates, estimate, data, softtype, solverData, getData, solverDataDict, setSolverData, internalId, smallData, bigData
2525
export DFGVariableSummary, DFGFactorSummary, AbstractDFGSummary
2626

27+
#Skeleton types
28+
export SkeletonDFGVariable, SkeletonDFGFactor
29+
2730
#graph small data
2831
export getUserData, setUserData, getRobotData, setRobotData, getSessionData, setSessionData
2932
export pushUserData!, pushRobotData!, pushSessionData!, popUserData!, popRobotData!, popSessionData!
@@ -33,13 +36,16 @@ export hasFactor, hasVariable, isInitialized, getFactorFunction, isVariable, isF
3336
export mergeUpdateVariableSolverData!, mergeUpdateGraphSolverData!
3437

3538
# Solver (IIF) Exports
36-
export VariableNodeData, PackedVariableNodeData, VariableEstimate
39+
export VariableNodeData, PackedVariableNodeData
3740
export GenericFunctionNodeData#, FunctionNodeData
3841
export getSerializationModule, setSerializationModule!
3942
export pack, unpack
4043
# Resolve with above
4144
export packVariable, unpackVariable, packFactor, unpackFactor
4245

46+
#PPE exports
47+
export MeanMaxPPE
48+
4349
#Interfaces
4450
export getAdjacencyMatrixSparse
4551

src/FileDFG/services/FileDFG.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function saveDFG(dfg::G, folder::String) where G <: AbstractDFG
3030
end
3131
end
3232

33-
function loadDFG(folder::String, iifModule, dfgLoadInto::G=GraphsDFG{NoSolverParams}()) where G <: AbstractDFG
33+
function loadDFG(folder::String, iifModule, dfgLoadInto::G) where G <: AbstractDFG
3434
variables = DFGVariable[]
3535
factors = DFGFactor[]
3636
varFolder = "$folder/variables"
@@ -70,9 +70,8 @@ function loadDFG(folder::String, iifModule, dfgLoadInto::G=GraphsDFG{NoSolverPar
7070

7171
# PATCH - To update the fncargvID for factors, it's being cleared somewhere in rebuildFactorMetadata.
7272
# TEMPORARY
73-
# TODO: Remove
73+
# TODO: Remove in future
7474
map(f->solverData(f).fncargvID = f._variableOrderSymbols, getFactors(dfgLoadInto))
7575

76-
7776
return dfgLoadInto
7877
end

src/LightDFG/services/LightDFG.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ function addFactor!(dfg::LightDFG{<:AbstractParams, V, F}, variables::Vector{V},
8888

8989
variableLabels = map(v->v.label, variables)
9090

91-
factor._variableOrderSymbols = copy(variableLabels)
92-
91+
resize!(factor._variableOrderSymbols, length(variableLabels))
92+
factor._variableOrderSymbols .= variableLabels
93+
# factor._variableOrderSymbols = copy(variableLabels)
9394

9495
return FactorGraphs.addFactor!(dfg.g, variableLabels, factor)
9596
end
@@ -104,12 +105,23 @@ function addFactor!(dfg::LightDFG{<:AbstractParams, <:AbstractDFGVariable, F}, v
104105
error("Factor '$(factor.label)' already exists in the factor graph")
105106
end
106107

107-
factor._variableOrderSymbols = variableLabels
108+
resize!(factor._variableOrderSymbols, length(variableLabels))
109+
factor._variableOrderSymbols .= variableLabels
110+
# factor._variableOrderSymbols = copy(variableLabels)
108111

109112
return FactorGraphs.addFactor!(dfg.g, variableLabels, factor)
110113
end
111114

112115

116+
function addFactor!(dfg::LightDFG{<:AbstractParams, <:AbstractDFGVariable, F}, factor::F)::Bool where F <: AbstractDFGFactor
117+
#TODO should this be an error
118+
if haskey(dfg.g.factors, factor.label)
119+
error("Factor '$(factor.label)' already exists in the factor graph")
120+
end
121+
122+
return FactorGraphs.addFactor!(dfg.g, variableLabels, factor)
123+
end
124+
113125
"""
114126
$(SIGNATURES)
115127
Get a DFGVariable from a DFG using its label.

src/entities/DFGFactor.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,19 @@ label(f::DFGFactorSummary) = f.label
103103
data(f::DFGFactorSummary) = f.data
104104
tags(f::DFGFactorSummary) = f.tags
105105
internalId(f::DFGFactorSummary) = f._internalId
106+
107+
108+
# SKELETON DFG
109+
"""
110+
$(TYPEDEF)
111+
Skeleton variable with essentials.
112+
"""
113+
struct SkeletonDFGVariable <: AbstractDFGVariable
114+
label::Symbol
115+
tags::Vector{Symbol}
116+
end
117+
118+
SkeletonDFGVariable(label::Symbol) = SkeletonDFGVariable(label, Symbol[])
119+
120+
label(v::SkeletonDFGVariable) = v.label
121+
tags(v::SkeletonDFGVariable) = v.tags

src/entities/DFGVariable.jl

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,28 @@ mutable struct PackedVariableNodeData
6363
x15::Bool ) = new(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15)
6464
end
6565

66-
67-
abstract type AbstractVariableEstimate end
66+
# AbstractPointParametricEst interface
67+
abstract type AbstractPointParametricEst end
6868
"""
6969
$TYPEDEF
7070
71-
Data container to store Parameteric Point Estimate (PPE) from a variety of types.
72-
73-
Notes
74-
- `ppeType` is something like `:max/:mean/:modefit` etc.
75-
- `solveKey` is from super-solve concept, starting with `:default`,
76-
- `estimate` is the actual numerical estimate value,
77-
- Additional information such as how the data is represented (ie softtype) is stored alongside this data container in the `DFGVariableSummary` container.
71+
Data container to store Parameteric Point Estimate (PPE) for mean and max.
7872
"""
79-
struct VariableEstimate <: AbstractVariableEstimate
80-
solverKey::Symbol
81-
ppeType::Symbol
82-
estimate::Vector{Float64}
83-
lastUpdatedTimestamp::DateTime
73+
struct MeanMaxPPE <: AbstractPointParametricEst
74+
solverKey::Symbol #repeated because of Sam's request
75+
max::Vector{Float64}
76+
mean::Vector{Float64}
77+
lastUpdatedTimestamp::DateTime
8478
end
85-
VariableEstimate(solverKey::Symbol, type::Symbol, estimate::Vector{Float64}) = VariableEstimate(solverKey, type, estimate, now())
79+
MeanMaxPPE(solverKey::Symbol,max::Vector{Float64},mean::Vector{Float64}) = MeanMaxPPE(solverKey, max, mean, now())
80+
81+
getMaxPPE(est::AbstractPointParametricEst) = est.max
82+
getMeanPPE(est::AbstractPointParametricEst) = est.mean
83+
getLastUpdatedTimestamp(est::AbstractPointParametricEst) = est.lastUpdatedTimestamp
84+
85+
86+
VariableEstimate(params...) = errror("VariableEstimate is depreciated, please use MeanMaxPPE")
87+
8688

8789
"""
8890
$(TYPEDEF)
@@ -93,7 +95,7 @@ mutable struct DFGVariable <: AbstractDFGVariable
9395
label::Symbol
9496
timestamp::DateTime
9597
tags::Vector{Symbol}
96-
estimateDict::Dict{Symbol, Dict{Symbol, <: AbstractVariableEstimate}}
98+
estimateDict::Dict{Symbol, <: AbstractPointParametricEst}
9799
solverDataDict::Dict{Symbol, VariableNodeData}
98100
smallData::Dict{String, String}
99101
bigData::Dict{Symbol, AbstractBigDataEntry}
@@ -107,10 +109,10 @@ end
107109
DFGVariable constructors.
108110
"""
109111
DFGVariable(label::Symbol, _internalId::Int64) =
110-
DFGVariable(label, now(), Symbol[], Dict{Symbol, Dict{Symbol, VariableEstimate}}(), Dict{Symbol, VariableNodeData}(:default => VariableNodeData()), Dict{String, String}(), Dict{Symbol,AbstractBigDataEntry}(), 0, 0, _internalId)
112+
DFGVariable(label, now(), Symbol[], Dict{Symbol, MeanMaxPPE}(), Dict{Symbol, VariableNodeData}(:default => VariableNodeData()), Dict{String, String}(), Dict{Symbol,AbstractBigDataEntry}(), 0, 0, _internalId)
111113

112114
DFGVariable(label::Symbol) =
113-
DFGVariable(label, now(), Symbol[], Dict{Symbol, VariableEstimate}(), Dict{Symbol, VariableNodeData}(:default => VariableNodeData()), Dict{String, String}(), Dict{Symbol,AbstractBigDataEntry}(), 0, 0, 0)
115+
DFGVariable(label, now(), Symbol[], Dict{Symbol, MeanMaxPPE}(), Dict{Symbol, VariableNodeData}(:default => VariableNodeData()), Dict{String, String}(), Dict{Symbol,AbstractBigDataEntry}(), 0, 0, 0)
114116

115117
# Accessors
116118
label(v::DFGVariable) = v.label
@@ -138,12 +140,7 @@ solverData(v::DFGVariable, key::Symbol=:default) = haskey(v.solverDataDict, key)
138140
Retrieve data structure stored in a variable.
139141
"""
140142
function getData(v::DFGVariable; solveKey::Symbol=:default)::VariableNodeData
141-
#FIXME but back in later, it just slows everything down
142-
if !(@isdefined getDataWarnOnce)
143-
@warn "getData is deprecated, please use solverData(), future warnings in getData is suppressed"
144-
global getDataWarnOnce = true
145-
end
146-
# @warn "getData is deprecated, please use solverData()"
143+
@warn "getData is deprecated, please use solverData()"
147144
return v.solverDataDict[solveKey]
148145
end
149146
"""
@@ -166,7 +163,7 @@ mutable struct DFGVariableSummary <: AbstractDFGVariable
166163
label::Symbol
167164
timestamp::DateTime
168165
tags::Vector{Symbol}
169-
estimateDict::Dict{Symbol, Dict{Symbol, <:AbstractVariableEstimate}}
166+
estimateDict::Dict{Symbol, <:AbstractPointParametricEst}
170167
softtypename::Symbol
171168
_internalId::Int64
172169
end
@@ -177,3 +174,22 @@ estimates(v::DFGVariableSummary) = v.estimateDict
177174
estimate(v::DFGVariableSummary, key::Symbol=:default) = haskey(v.estimateDict, key) ? v.estimateDict[key] : nothing
178175
softtype(v::DFGVariableSummary)::Symbol = v.softtypename
179176
internalId(v::DFGVariableSummary) = v._internalId
177+
178+
179+
180+
# SKELETON DFG
181+
"""
182+
$(TYPEDEF)
183+
Skeleton factor with essentials.
184+
"""
185+
struct SkeletonDFGFactor <: AbstractDFGFactor
186+
label::Symbol
187+
tags::Vector{Symbol}
188+
_variableOrderSymbols::Vector{Symbol}
189+
end
190+
191+
#NOTE I feel like a want to force a variableOrderSymbols
192+
SkeletonDFGFactor(label::Symbol, variableOrderSymbols::Vector{Symbol} = Symbol[]) = SkeletonDFGFactor(label, Symbol[], variableOrderSymbols)
193+
194+
label(f::SkeletonDFGFactor) = f.label
195+
tags(f::SkeletonDFGFactor) = f.tags

src/services/DFGVariable.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ function unpackVariable(dfg::G, packedProps::Dict{String, Any})::DFGVariable whe
1717
label = Symbol(packedProps["label"])
1818
timestamp = DateTime(packedProps["timestamp"])
1919
tags = JSON2.read(packedProps["tags"], Vector{Symbol})
20-
estimateDict = JSON2.read(packedProps["estimateDict"], Dict{Symbol, Dict{Symbol, VariableEstimate}})
20+
#TODO this will work for some time, but unpacking in an <: AbstractPointParametricEst would be lekker.
21+
estimateDict = JSON2.read(packedProps["estimateDict"], Dict{Symbol, MeanMaxPPE})
2122
smallData = nothing
2223
smallData = JSON2.read(packedProps["smallData"], Dict{String, String})
2324

@@ -112,15 +113,15 @@ function ==(a::VariableNodeData,b::VariableNodeData, nt::Symbol=:var)
112113
end
113114

114115
"""
115-
$(SIGNATURES)
116-
Equality check for VariableEstimate.
116+
==(x::T, y::T) where T <: AbstractPointParametricEst
117+
Equality check for AbstractPointParametricEst.
117118
"""
118-
function ==(a::VariableEstimate, b::VariableEstimate)::Bool
119-
a.solverKey != b.solverKey && @debug("solverKey are not equal")==nothing && return false
120-
a.ppeType != b.ppeType && @debug("ppeType is not equal")==nothing && return false
121-
a.estimate != b.estimate && @debug("estimate are not equal")==nothing && return false
122-
a.lastUpdatedTimestamp != b.lastUpdatedTimestamp && @debug("lastUpdatedTimestamp is not equal")==nothing && return false
123-
return true
119+
@generated function ==(x::T, y::T) where T <: AbstractPointParametricEst
120+
mapreduce(n -> :(x.$n == y.$n), (a,b)->:($a && $b), fieldnames(x))
121+
end
122+
123+
@generated function Base.:(==)(x::T, y::T) where T <: Union{DFGFactorSummary, DFGVariableSummary, SkeletonDFGVariable, SkeletonDFGFactor}
124+
mapreduce(n -> :(x.$n == y.$n), (a,b)->:($a && $b), fieldnames(x))
124125
end
125126

126127
"""

0 commit comments

Comments
 (0)