Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

MFAS

Created by Codex.

Find a one-dimensional ordering and outlier weights using the Minimum Feedback Arc Set (MFAS) heuristic from one-dimensional structure from motion (1DSfM).

Open In Colab

Mathematical idea

MFAS means Minimum Feedback Arc Set. For an ordering π\pi of graph vertices, an edge (i,j)(i,j) is backward when π(i)>π(j)\pi(i)>\pi(j); the weighted objective is

minπ(i,j):π(i)>π(j)wij.\min_{\pi}\sum_{(i,j):\,\pi(i)>\pi(j)} w_{ij}.

The one-dimensional structure-from-motion (1DSfM) procedure projects translation directions onto a line, uses this ordering problem to expose inconsistent edges, and repeats over projection directions for robust outlier evidence.

import gtsam
import numpy as np

from gtsam import symbol_shorthand

C = symbol_shorthand.C
K = symbol_shorthand.K
P = symbol_shorthand.P
S = symbol_shorthand.S
X = symbol_shorthand.X

Translation-averaging use

MFAS projects world-frame translation directions onto a chosen Unit3. It flips negative projected edges, computes a node ordering, and marks edges that disagree with that ordering. computeOutlierWeights() returns zero for inliers and projected magnitude for detected outliers.

KeyPairDoubleMap is the C++ map type returned through the wrappers; Python receives a normal dictionary.

noise = gtsam.noiseModel.Isotropic.Sigma(2, 0.01)
edges = [
    gtsam.BinaryMeasurementUnit3(X(0), X(1), gtsam.Unit3(np.array([1.0, 0.1, 0.0])), noise),
    gtsam.BinaryMeasurementUnit3(X(1), X(2), gtsam.Unit3(np.array([1.0, 0.0, 0.0])), noise),
    gtsam.BinaryMeasurementUnit3(X(2), X(0), gtsam.Unit3(np.array([1.0, 0.0, 0.0])), noise),
]

mfas = gtsam.MFAS(edges, gtsam.Unit3(np.array([1.0, 0.0, 0.0])))
print("1D ordering:", mfas.computeOrdering())
print("outlier weights:", mfas.computeOutlierWeights())
1D ordering: [8646911284551352321, 8646911284551352322, 8646911284551352320]
outlier weights: {(8646911284551352320, 8646911284551352321): 0.9950371902099893, (8646911284551352321, 8646911284551352322): 0.0, (8646911284551352322, 8646911284551352320): 0.0}

Practical notes

One projection direction can miss outliers nearly orthogonal to it. A robust 1DSfM pipeline repeats the test over multiple directions and combines evidence before removing translation edges.

Source

MFAS.h