@@ -253,7 +253,7 @@ $(TYPEDFIELDS)
253253"""
254254Base. @kwdef struct FactorCompute{FT <: AbstractFactor , N} <: AbstractDFGFactor
255255 """ The ID for the factor"""
256- id:: Union{UUID, Nothing} = nothing
256+ id:: Union{UUID, Nothing} = nothing # TODO deprecate id
257257 """ Factor label, e.g. :x1f1.
258258 Accessor: [`getLabel`](@ref)"""
259259 label:: Symbol
@@ -279,55 +279,62 @@ Base.@kwdef struct FactorCompute{FT <: AbstractFactor, N} <: AbstractDFGFactor
279279 smallData:: Dict{Symbol, SmallDataTypes} = Dict {Symbol, SmallDataTypes} ()
280280
281281 # refactor fields
282+ """ Observation function or measurement for this factor.
283+ Accessors: [`getObservation`](@ref)(@ref)"""
282284 observation:: FT
285+ """ Describes the current state of the factor. Persisted in serialization.
286+ Accessors: [`getFactorState`](@ref)"""
283287 state:: FactorState
284- computeMem:: Base.RefValue{<:FactorOperationalMemory} # TODO easy of use vs. performance as container is abstract in any case.
288+ """ Temporary, non-persistent memory used internally by the solver for intermediate numerical computations and buffers.
289+ `workmem` is lazily allocated and only used during factor operations; it is not serialized or retained after solving.
290+ Accessors: [`getWorkmem`](@ref), [`setWorkmem!`](@ref)"""
291+ workmem:: Base.RefValue{<:FactorOperationalMemory} # TODO easy of use vs. performance as container is abstract in any case.
285292end
286293
287294# #------------------------------------------------------------------------------
288295# # Constructors
289296
290- # TODO consolidate constructors, currently IIF calls only
291- # DFGFactor(
292- # Symbol(namestring),
293- # varOrderLabels,
294- # solverData;
295- # tags = Set(union(tags, [:FACTOR])),
296- # solvable,
297- # timestamp = _zonedtime(timestamp),
298- # )
299-
297+ # TODO standardize new fields in kw constructors, .id
300298function FactorCompute (
301299 label:: Symbol ,
302- timestamp:: Union{DateTime, ZonedDateTime} ,
303- nstime:: Nanosecond ,
304- tags:: Set{Symbol} ,
305- solverData:: GenericFunctionNodeData ,
306- solvable:: Int ,
307- variableOrder:: Union{Vector{Symbol}, Tuple} ;
308- observation = getFactorType (solverData),
300+ variableOrder:: Union{Vector{Symbol}, Tuple} ,
301+ observation:: AbstractFactor ,
309302 state:: FactorState = FactorState (),
310- computeMem:: Base.RefValue{<:FactorOperationalMemory} = Ref {FactorOperationalMemory} (),
303+ workmem = Ref {FactorOperationalMemory} ();
304+ tags:: Set{Symbol} = Set {Symbol} (),
305+ timestamp:: Union{DateTime, ZonedDateTime} = now (localzone ()),
306+ solvable:: Int = 1 ,
307+ nstime:: Nanosecond = Nanosecond (0 ),
311308 id:: Union{UUID, Nothing} = nothing ,
312309 smallData:: Dict{Symbol, SmallDataTypes} = Dict {Symbol, SmallDataTypes} (),
310+ solverData = nothing
313311)
312+ if isnothing (solverData)
313+ refsolverData = Ref {GenericFunctionNodeData} () # TODO solverData deprecated in v0.27 WIP
314+ else
315+ Base. depwarn (
316+ " `FactorCompute` solverData is deprecated" ,
317+ :FactorCompute ,
318+ )
319+ refsolverData = Ref (solverData)
320+ end
321+
314322 return FactorCompute (
315323 id,
316324 label,
317325 tags,
318326 Tuple (variableOrder),
319327 timestamp,
320328 nstime,
321- Ref (solverData) ,
329+ refsolverData ,
322330 Ref (solvable),
323331 smallData,
324332 observation,
325333 state,
326- computeMem ,
334+ workmem ,
327335 )
328336end
329337
330- # TODO standardize new fields in kw constructors, .id
331338function FactorCompute (
332339 label:: Symbol ,
333340 variableOrder:: Union{Vector{Symbol}, Tuple} ,
@@ -339,6 +346,10 @@ function FactorCompute(
339346 id:: Union{UUID, Nothing} = nothing ,
340347 smallData:: Dict{Symbol, SmallDataTypes} = Dict {Symbol, SmallDataTypes} (),
341348)
349+ Base. depwarn (
350+ " `FactorCompute` constructor with `GenericFunctionNodeData` is deprecated. observation, state, and workmem should be provided explicitly." ,
351+ :FactorCompute ,
352+ )
342353 observation = getFactorType (solverData)
343354 state = FactorState (
344355 solverData. eliminated,
@@ -351,24 +362,24 @@ function FactorCompute(
351362 )
352363
353364 if solverData. fnc isa FactorOperationalMemory
354- computeMem = Ref (solverData. fnc)
365+ workmem = Ref (solverData. fnc)
355366 else
356- computeMem = Ref {FactorOperationalMemory} ()
367+ workmem = Ref {FactorOperationalMemory} ()
357368 end
358369
359370 return FactorCompute (
360371 label,
372+ Tuple (variableOrder),
373+ observation,
374+ state,
375+ workmem;
376+ id,
361377 timestamp,
362378 nstime,
363379 tags,
364380 solverData,
365- solvable,
366- Tuple (variableOrder);
367- observation,
368- computeMem,
369- id,
370381 smallData,
371- state ,
382+ solvable ,
372383 )
373384end
374385
0 commit comments