borglab / borglab/SwiftFusion

map/reduce algorithms for heterogeneous arrays

Open
#114 2 comments 0 reactions 1 assignee Claimed by @dabrahams View on GitHub
Dominant language
Swift
Stars
118
Forks
14
PR merge metrics
No merged PRs in 30d

Description

We already have multiple algorithms defined on arrays of factors and arrays of variable values that may be implementable in terms of map or reduce algorithms:
* [`errorVectors(at x: VariableAssignments)`](https://github.com/borglab/SwiftFusion/blob/37139c5baa12656dd4440696985d4d591ac6e36f/Sources/SwiftFusion/Inference/FactorGraph.swift#L82) is almost `factors.map { $0.errorVector(at: x) }`.
* [`linearized(at x: VariableAssignments)`](https://github.com/borglab/SwiftFusion/blob/37139c5baa12656dd4440696985d4d591ac6e36f/Sources/SwiftFusion/Inference/FactorGraph.swift#L103) is almost `factors.map { $0.linearized(at: x) }`.
* [`addScalarJacobians(_ lambda: Double)`](https://github.com/borglab/SwiftFusion/blob/37139c5baa12656dd4440696985d4d591ac6e36f/Sources/SwiftFusion/Inference/GaussianFactorGraph.swift#L52) is almost `factors += zeroValues.map { _: T in ScalarJacobianFactor(lambda) }`.

We probably want to write more such algorithms in the future.

It is currently very tedious and boilerplatey to implement these algorithms. You have to implement the algorithm on the `ArrayStorage`, then you have to add a method to the appropriate dispatch classes, and finally you need to write a method on the heterogeneous collection that invokes the algorithm on all its homogeneous collections.

It would probably be easier to implement these algorithms if we could write them in terms of generic "map" or "reduce" algorithms on the heterogeneous collections.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.