Algorithmresearch
SE-Sync
Also called certifiably correct pose graph optimization.
Solves pose graph optimization through a semidefinite relaxation and the Riemannian staircase, and certifies a global optimum when the relaxation is tight.
- Solves
- Pose graph optimization
- Time
- O(r (n + m)) certificate · local_search_sweepO(n^3) jacobi_sweep_denseO(r^2 n + r^3) rounding
- Space
- O(r n) iterateO(n + m) sparse_q
- Where
- m = the number of edges; n = the number of poses; r = the rank of the current step of the staircase
- Model
- Real RAM
- Properties
- certifies global optimumdeterministicnot exactneeds tight relaxation
- Evidence
- Proof sketchCode in 1 languages
- Origin
- David M. Rosen, Luca Carlone, Afonso S. Bandeira, John J. Leonard, 2019
SE-Sync solves pose graph optimization and returns a proof that the answer is the global optimum when it can. Pose graph optimization is nonconvex because rotations live on the curved set , so Gauss-Newton and similar local methods can stop at a wrong local minimum and cannot tell. SE-Sync first removes the translations in closed form. What is left is a problem over the rotations alone, with . It relaxes this problem to a semidefinite program and solves the relaxation in the low rank form of Burer and Monteiro, where has only rows. A local search finds a critical point . A matrix built from and the data is the certificate: if is positive semidefinite, solves the relaxation. If not, the eigenvector of the least eigenvalue of points downhill in a space with one more row, and the search goes up one step of this "Riemannian staircase". At the end, SE-Sync rounds to rotations. The relaxation value is a lower bound, and the cost of the rounded answer is an upper bound. When the relaxation is tight, the two are equal, and the rounded answer is a certified global optimum. Rosen et al. prove that this happens when the noise is below a level that depends on the graph.
In plain words
Many poses must agree with many measurements of how they relate. A normal solver walks downhill from a guess and stops at the first low point, which may not be the lowest. SE-Sync loosens the problem so that it has no false low points, solves the loose version, and then checks a simple condition that proves the loose answer is the best one. If the check fails, the check itself shows a way down, and the search continues with one more degree of freedom. At the end, the loose answer is turned back into real rotations. If the loose problem and the real problem give the same value, the answer is proved to be the best possible. When the measurements are very noisy, the two values can differ. Then the gap still tells how far from the best the answer can be.
The problem
The input is a connected graph on poses. Each edge has a measured relative rotation , a measured relative translation , and weights . The problem is
For fixed rotations the cost is a linear least squares problem in the translations, so the translations can be eliminated. The result is over , for a symmetric positive semidefinite matrix of size . With rotation edges only, is the connection Laplacian , with blocks and . Its scalar analogue is the Laplacian matrix of the graph.
The code is the planar rotation case: and the matrix of the rotation edges. It is the core of SE-Sync without the translation step. The same steps apply to and to .
The algorithm
The relaxation replaces by with . The set of such is the Stiefel manifold . For , is a lower bound on the original problem. Burer and Monteiro showed that for large enough it equals the semidefinite program with and .
SE-SYNC(Q, initial rotations R⁰)- 1
r ← d; Y ← [R⁰_1 ... R⁰_n] - 2
loop - 3
Y ← a first order critical point of tr(Q YᵀY) on St(d, r)^n, by local search from Y - 4
Λ ← the block diagonal matrix with Λ_ii = Sym((Q YᵀY)_ii); S ← Q - Λ - 5
(λ, v) ← the least eigenvalue of S and a unit eigenvector - 6
if λ ≥ -ε then leave the loop - 7
r ← r + 1; Y ← a descent step from [Y; 0] along the new row vᵀ, with a line search - 8
R̂ ← ROUND(Y): the top d rows of UᵀY from the SVD of Y, sign fix, nearest rotation per block - 9
return R̂, the lower bound tr(Q YᵀY) and the upper bound tr(Q R̂ᵀR̂)
Local search (line L3). Rosen et al. use a Riemannian trust region method. The code uses block coordinate descent. With all blocks except fixed, the cost is plus a constant, with . Its minimizer over is the polar factor of . Each step can only decrease the cost. The search stops when a full sweep changes the cost by less than a relative .
The certificate (lines L4 to L6). The Riemannian gradient at is , so at a critical point . If also , then for any feasible , . So solves the semidefinite program, and is the dual solution. The code finds the least eigenvalue with the Jacobi eigenvalue algorithm on the dense . Rosen et al. use a sparse Lanczos method. The tolerance is times the largest entry of .
The staircase step (line L7). If , then the step , mapped back to by the polar factor of each block, changes the cost by . The code starts at and halves until the cost decreases.
Rounding (line L8). If has rank , the top rows of give with and . If most blocks have a negative determinant, the code changes the sign of one row. Then each block goes to the nearest rotation, and the result is multiplied by so that .
Example
A wrong critical point. Take a cycle of 9 rotations whose 9 measurements are all the identity, with weights 1. The global optimum has all rotations equal and cost 0. Start at the "twisted" state . Each edge then has the error , so the cost is . Every rotation sits halfway between its two neighbors, so the gradient is zero, and block coordinate descent does not move. A local solver stops here. The certificate does not. The eigenvalues of at this point are (twice), (four times), , and (four times each). The staircase runs as follows.
| rank | cost after the local search | least eigenvalue of | sweeps |
|---|---|---|---|
| 2 | 8.4224 | -0.4679 | 1 |
| 3 | 4.2112 | -0.4679 | 35 |
| 4 | 41 |
At rank 4 the certificate holds, and rounding gives all rotations equal with cost about 0.
A random problem. Ten rotations at random angles, a path through them plus 10 random extra edges, and Gaussian angle noise with rad on each measurement (seed 4). The start composes the measurements along a breadth-first spanning tree. It has cost 1.0634 and a largest angle error of 0.264 rad. The truth has cost 0.6213. After 14 sweeps the certificate holds at rank 2 with . The lower bound and the upper bound are both 0.248577, so the answer is a certified global optimum. Its largest angle error against the truth is 0.130 rad.
More noise. On five random problems for each noise level, with 10 rotations and 10 extra edges, the relaxation was tight at rank 2 for all problems at and rad. At rad it was tight for three of the five. The other two stopped at rank 4 with gaps of 0.875 and 3.42 between the upper and the lower bound. At and rad, some problems again had gaps. One problem at went up to rank 3 and was still tight. These are measurements on small problems, and they agree with the guarantee: below a noise level the relaxation is exact, and above it a gap can appear.
Correctness
The correctness proof shows that the cost equals , that the Riemannian gradient is , that and make optimal for the semidefinite program, and that the staircase step decreases the cost when has a negative eigenvalue. It also shows that the lower bound is at most the optimum and the upper bound at least the optimum, and that a rank certified with the right determinants rounds to a global minimizer. It does not show that the relaxation is tight; that is the theorem of Rosen et al. for small noise. The tests check the trace form, exact recovery without noise, the certificate and a zero gap at low noise, the first order condition, a brute force search over three rotations, and the twisted cycle.
Proof: The SE-Sync certificate proves optimality for the semidefinite relaxation, the staircase step descends, and a tight relaxation gives a global optimumfull
Setting. The unknowns are , written as . Each edge has a measurement and a weight . The cost is . The connection Laplacian has the diagonal blocks and, for each edge, and . In SE-Sync for poses, the translations are removed in closed form, and the rotations face a problem of the same form, , with a different symmetric matrix . Claims 2 to 5 use only that is symmetric, so they hold for too.
The problems are:
- (P) over ;
- (SDP) over symmetric with for each ;
- (BM) over with and .
For in (BM), let be block diagonal with , where , and let .
Assumptions. (A1) Exact arithmetic. In the code, "zero" and "positive semidefinite" are checked with small tolerances.
Claim 1 (the cost). for .
Proof. For one edge, . The trace form collects from the diagonal blocks, and from the two off-diagonal blocks. Since is orthogonal, , and the two sums agree term by term.
Claim 2 (the chain of bounds). , and for every in (BM).
Proof. For or for any feasible , is positive semidefinite and , so it is feasible for (SDP), with the same cost.
Claim 3 (the gradient). The Riemannian gradient of at is . So is a first order critical point if and only if .
Proof. The Euclidean gradient of is , and its block is . The tangent space of at is , and the projection onto it is . Here , which is the transpose of , so . The projected block is .
Claim 4 (the certificate). If and , then solves (SDP), and .
Proof. Let and . For any feasible , since is block diagonal with symmetric blocks and , . So , because the trace of the product of two positive semidefinite matrices is nonnegative. At , , so , the smallest value. This is weak duality with the dual variable of the constraints .
Claim 5 (the staircase step). Let be in (BM) with , and let be a unit vector with . Let (BM), , and the blockwise polar factor of . Then , so a small enough step decreases the cost.
Proof. has the same cost as and lies in (BM). Each block is nonzero only in the new row, where is zero, so and is tangent. Let be the two entries of for block , and block diagonal with . Then , so the polar factor is with . With ,
is block diagonal and symmetric, so the middle trace is . Hence . The line search halves until the cost decreases, which happens after finitely many halvings.
Claim 6 (rounding and global optimality). Let satisfy the conditions of Claim 4. If has rank 2, let , where holds the two top left singular vectors of . Then and every is in . If, after the sign fix of the code, every , then is a global minimizer of (P) and . In all cases, for the rounded .
Proof. The columns of lie in the span of , so and . Then . Changing the sign of the second row of multiplies every by and does not change . If all determinants are 1, then is feasible for (P), and by Claims 1, 2 and 4, . The last statement follows from Claims 2 and 4 and the feasibility of . The projection of each block onto and the multiplication by keep feasible and, for the second, do not change .
What this does not show. It does not show that the relaxation is tight. Rosen et al. prove that it is tight when the noise is below a level that depends on the graph; above that level, the rank of the certified can exceed 2, and the gap only bounds the suboptimality of . It does not show that the local search reaches a critical point; block coordinate descent decreases at every step, and the code checks the gradient and the eigenvalue with tolerances. It does not bound the rank at which the staircase stops; Boumal, Voroninski and Bandeira give such a bound for generic problems, and the code stops at a fixed largest rank.
Complexity
Let be the number of poses, the number of edges and the current rank.
- One sweep of block coordinate descent costs : each block reads its neighbors and takes the polar factor of an matrix.
- Forming and the gradient costs with a sparse .
- The least eigenvalue costs per Jacobi sweep with the dense of the code. A sparse Lanczos method needs only products with , at each.
- Rounding costs .
- The number of local search iterations and of staircase steps depends on the data. In practice the staircase stops at or one step above when the noise is moderate.
Properties
- Certifiable. A tight run returns a proof of global optimality that anyone can check with one eigenvalue computation.
- Bounds. Every run returns a lower and an upper bound on the optimum.
- Exact below a noise level. Rosen et al. prove that the relaxation is exact when the noise is small enough.
- Independent of the start. The certificate does not depend on the initial guess. The start changes only the run time.
- No translations in the search. The translations are recovered in closed form after the rotations.
Variants and improvements
- Other local solvers. A Riemannian trust region method converges faster than block coordinate descent.
- Verification only. Carlone and colleagues earlier used Lagrangian duality to verify a candidate from a local solver. SE-Sync makes the same kind of check part of the solver.
- Other synchronization problems. The same relaxation and certificate work for rotation averaging in structure from motion.
- Distributed and incremental versions. Later work splits the problem across robots or keeps the certificate up to date as the graph grows.
- Robust costs. Wrong loop closures break the noise assumption. Robust versions combine certifiable relaxations with outlier models such as switchable constraints.
When to use it
Use SE-Sync when a wrong local minimum is costly and the measurements have moderate noise, for example to check a map before a long mission, or to start a local solver from a good point. For online use with frequent updates, iSAM2 is faster, and SE-Sync can check its result from time to time. With outliers in the loop closures, first remove them or use a robust method.
Pitfalls
- Outliers. A wrong loop closure is not small noise. The relaxation can then be loose, and a certified optimum of the wrong cost is still wrong.
- The tolerance on . The least eigenvalue of is zero at a solution, because the rows of are in its null space. A test against an exact zero fails because of rounding. Scale the tolerance by the size of .
- Rank above . If the staircase stops at a rank above , the rounded answer is not certified. Report the gap, not a claim of optimality.
- The gauge. The cost does not change when all rotations are multiplied by one rotation. Fix one pose, as the code does with , before comparing results.
- A disconnected graph. The cost then has more than one gauge freedom, and the spanning tree start fails.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/se-sync/. The authors are listed in prov/ZTRAGF.jsonl.
"""The SE-Sync pipeline (Rosen, Carlone, Bandeira and Leonard 2019) on small
planar rotation synchronization problems.
The unknowns are n rotations R_i in SO(2). Each edge (i, j, Rt, kappa) is a
measurement Rt of R_i^T R_j with the weight kappa > 0. The cost is
F(R) = sum over the edges of kappa || R_j - R_i Rt ||_F^2 = tr(Q R^T R),
where R = [R_1 ... R_n] is 2 x 2n and Q is the 2n x 2n connection Laplacian.
In SE-Sync the translations of a pose graph are removed in closed form, which
leaves a problem of this same form with a matrix Q that also holds the
translation terms; the code starts from Q, so it covers the rotation part.
The pipeline:
1. Relax SO(2) to the Stiefel manifold St(2, r): Y = [Y_1 ... Y_n] is
r x 2n with Y_i^T Y_i = I. min tr(Q Y^T Y) is the Burer-Monteiro form of
the semidefinite relaxation min tr(Q Z), Z >= 0, Z_ii = I.
2. Find a critical point Y by a local search (here block coordinate descent:
each Y_i has a closed form minimizer, the polar factor).
3. Certificate: Lambda_i = Sym(sum_j Q_ij Y_j^T Y_i), S = Q - Lambda.
If S is positive semidefinite, Z = Y^T Y solves the relaxation.
4. If not, the eigenvector v of the least eigenvalue of S gives a descent
direction at [Y; 0] in St(2, r + 1): go up one step of the staircase.
5. Round: take the top 2 rows of U^T Y from the SVD of Y, fix the sign of
the determinant, and project each block onto SO(2).
The lower bound tr(Q Y^T Y) and the upper bound F(R) bracket the optimum.
"""
import math
# ------------------------------------------------------------- small algebra
def rot(a):
c, s = math.cos(a), math.sin(a)
return [[c, -s], [s, c]]
def angle(r):
return math.atan2(r[1][0], r[0][0])
def matmul(a, b):
bt = list(zip(*b))
return [[sum(x * y for x, y in zip(row, col)) for col in bt] for row in a]
def transpose(a):
return [list(r) for r in zip(*a)]
def symmetric_eigen(a, tol=1e-14, max_sweeps=100):
"""Cyclic Jacobi: return (eigenvalues ascending, eigenvectors as columns)."""
n = len(a)
a = [list(r) for r in a]
v = [[1.0 if i == j else 0.0 for j in range(n)] for i in range(n)]
for _ in range(max_sweeps):
off = sum(a[i][j] ** 2 for i in range(n) for j in range(n) if i != j)
if off <= tol * tol * max(1.0, sum(a[i][i] ** 2 for i in range(n))):
break
for p in range(n - 1):
for q in range(p + 1, n):
if abs(a[p][q]) < 1e-300:
continue
th = (a[q][q] - a[p][p]) / (2.0 * a[p][q])
t = (1.0 if th >= 0 else -1.0) / (abs(th) + math.sqrt(th * th + 1.0))
c = 1.0 / math.sqrt(t * t + 1.0)
s = t * c
for k in range(n):
akp, akq = a[k][p], a[k][q]
a[k][p], a[k][q] = c * akp - s * akq, s * akp + c * akq
for k in range(n):
apk, aqk = a[p][k], a[q][k]
a[p][k], a[q][k] = c * apk - s * aqk, s * apk + c * aqk
for k in range(n):
vkp, vkq = v[k][p], v[k][q]
v[k][p], v[k][q] = c * vkp - s * vkq, s * vkp + c * vkq
idx = sorted(range(n), key=lambda i: a[i][i])
return [a[i][i] for i in idx], [[v[k][i] for i in idx] for k in range(n)]
def polar_factor(g):
"""The r x 2 matrix with orthonormal columns nearest to g: g (g^T g)^(-1/2)."""
a = sum(row[0] * row[0] for row in g)
b = sum(row[0] * row[1] for row in g)
d = sum(row[1] * row[1] for row in g)
mean, half = 0.5 * (a + d), math.hypot(0.5 * (a - d), b)
l1, l2 = mean + half, mean - half
if l2 <= 1e-24 * max(1.0, l1):
raise ValueError("the block has rank below 2")
if abs(b) > 1e-300 or abs(a - d) > 1e-300:
phi = 0.5 * math.atan2(2.0 * b, a - d)
else:
phi = 0.0
c, s = math.cos(phi), math.sin(phi)
# g^T g = V diag(l1, l2) V^T with V = [[c, -s], [s, c]]
w1, w2 = 1.0 / math.sqrt(l1), 1.0 / math.sqrt(l2)
m = [[c * c * w1 + s * s * w2, c * s * (w1 - w2)], [c * s * (w1 - w2), s * s * w1 + c * c * w2]]
return [[row[0] * m[0][0] + row[1] * m[1][0], row[0] * m[0][1] + row[1] * m[1][1]] for row in g]
# ----------------------------------------------------------- the problem
def connection_laplacian(n, edges):
q = [[0.0] * (2 * n) for _ in range(2 * n)]
for i, j, rt, kappa in edges:
for a in range(2):
q[2 * i + a][2 * i + a] += kappa
q[2 * j + a][2 * j + a] += kappa
for b in range(2):
q[2 * i + a][2 * j + b] -= kappa * rt[a][b]
q[2 * j + b][2 * i + a] -= kappa * rt[a][b]
return q
def objective(edges, rs):
"""F(R) = sum kappa || R_j - R_i Rt ||_F^2."""
tot = 0.0
for i, j, rt, kappa in edges:
p = matmul(rs[i], rt)
tot += kappa * sum((rs[j][a][b] - p[a][b]) ** 2 for a in range(2) for b in range(2))
return tot
def block(y, i):
return [[row[2 * i], row[2 * i + 1]] for row in y]
def set_block(y, i, b):
for row, br in zip(y, b):
row[2 * i], row[2 * i + 1] = br[0], br[1]
def relaxed_cost(q, y):
"""tr(Q Y^T Y)."""
yq = matmul(y, q)
return sum(yq[k][c] * y[k][c] for k in range(len(y)) for c in range(len(q)))
def neighbors(q, n):
return [[j for j in range(n) if j != i and any(q[2 * i + a][2 * j + b] != 0.0 for a in range(2) for b in range(2))] for i in range(n)]
def local_search(q, y, n, tol=1e-12, max_sweeps=20000):
"""Block coordinate descent on St(2, r)^n. Each step minimizes over one Y_i.
With the others fixed, tr(Q Y^T Y) = 2 tr(Y_i^T G_i) + const, with
G_i = sum_{j != i} Y_j Q_ji, so the minimizer is Y_i = polar(-G_i).
"""
nb = neighbors(q, n)
r = len(y)
last = relaxed_cost(q, y)
for sweep in range(max_sweeps):
for i in range(n):
g = [[0.0, 0.0] for _ in range(r)]
for j in nb[i]:
for k in range(r):
yk = y[k]
for b in range(2):
g[k][b] -= yk[2 * j] * q[2 * j][2 * i + b] + yk[2 * j + 1] * q[2 * j + 1][2 * i + b]
set_block(y, i, polar_factor(g))
cost = relaxed_cost(q, y)
if last - cost <= tol * max(1.0, abs(cost)):
return y, sweep + 1
last = cost
return y, max_sweeps
def certificate(q, y, n):
"""Return S = Q - Lambda with Lambda_i = Sym(sum_j Q_ij Y_j^T Y_i)."""
yty = matmul(transpose(y), y)
s = [list(row) for row in q]
for i in range(n):
lam = [[0.0, 0.0], [0.0, 0.0]]
for a in range(2):
for b in range(2):
lam[a][b] = sum(q[2 * i + a][c] * yty[c][2 * i + b] for c in range(2 * n))
for a in range(2):
for b in range(2):
s[2 * i + a][2 * i + b] -= 0.5 * (lam[a][b] + lam[b][a])
return s
def riemannian_gradient_norm(q, y, n):
"""|| 2 Y S || in the Frobenius norm; zero exactly at a first order critical point."""
ys = matmul(y, certificate(q, y, n))
return 2.0 * math.sqrt(sum(x * x for row in ys for x in row))
def escape(q, y, n, v):
"""Lift Y to [Y; 0] and step along e_{r+1} v^T with a backtracking line search."""
base = [list(row) for row in y] + [[0.0] * (2 * n)]
f0 = relaxed_cost(q, base)
norm = math.sqrt(sum(x * x for x in v))
alpha = 1.0
while alpha > 1e-12:
trial = [list(row) for row in base]
trial[-1] = [alpha * x / norm for x in v]
for i in range(n):
set_block(trial, i, polar_factor(block(trial, i)))
if relaxed_cost(q, trial) < f0:
return trial
alpha *= 0.5
raise ValueError("no descent along the eigenvector")
def round_solution(y, n):
"""Top 2 rows of U^T Y, sign fix, then the nearest rotation per block."""
r = len(y)
yyt = [[sum(a * b for a, b in zip(y[i], y[j])) for j in range(r)] for i in range(r)]
_, vecs = symmetric_eigen(yyt)
top = [[vecs[k][r - 1 - c] for k in range(r)] for c in range(2)] # the two largest
rr = [[sum(top[c][k] * y[k][col] for k in range(r)) for col in range(2 * n)] for c in range(2)]
dets = [rr[0][2 * i] * rr[1][2 * i + 1] - rr[0][2 * i + 1] * rr[1][2 * i] for i in range(n)]
if sum(1 for d in dets if d < 0) > n / 2:
rr[1] = [-x for x in rr[1]]
out = []
for i in range(n):
a, b = rr[0][2 * i], rr[0][2 * i + 1]
c, d = rr[1][2 * i], rr[1][2 * i + 1]
# the nearest rotation to [[a, b], [c, d]] has the angle atan2(c - b, a + d)
out.append(rot(math.atan2(c - b, a + d)))
g = transpose(out[0])
return [matmul(g, x) for x in out]
def spanning_tree_start(n, edges):
"""Compose the measurements along a breadth-first spanning tree from rotation 0."""
adj = {i: [] for i in range(n)}
for i, j, rt, _ in edges:
adj[i].append((j, rt))
adj[j].append((i, transpose(rt)))
rs = {0: rot(0.0)}
queue = [0]
while queue:
i = queue.pop(0)
for j, rt in adj[i]:
if j not in rs:
rs[j] = matmul(rs[i], rt)
queue.append(j)
if len(rs) != n:
raise ValueError("the measurement graph is not connected")
return [rs[i] for i in range(n)]
def se_sync(n, edges, start=None, eps=1e-6, max_rank=10):
"""Return a dict with the rotations, the bounds, the final rank and the history."""
q = connection_laplacian(n, edges)
scale = max(abs(x) for row in q for x in row)
rs = start if start is not None else spanning_tree_start(n, edges)
y = [[0.0] * (2 * n) for _ in range(2)]
for i, r in enumerate(rs):
set_block(y, i, r) # @line L1
history = []
while True: # @line L2
y, sweeps = local_search(q, y, n) # @line L3
s = certificate(q, y, n) # @line L4
vals, vecs = symmetric_eigen(s) # @line L5
lam_min = vals[0]
history.append((len(y), relaxed_cost(q, y), lam_min, sweeps))
if lam_min >= -eps * scale: # @line L6
break
if len(y) >= max_rank:
raise ValueError("the staircase reached the largest rank without a certificate")
v = [vecs[k][0] for k in range(2 * n)]
y = escape(q, y, n, v) # @line L7
lower = relaxed_cost(q, y)
rounded = round_solution(y, n) # @line L8
upper = objective(edges, rounded) # @line L9
return {
"rotations": rounded,
"lower": lower,
"upper": upper,
"rank": len(y),
"lam_min": lam_min,
"history": history,
}
test_se_sync.py 155 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/se-sync/. The authors are listed in prov/ZTRAGF.jsonl.
import math
import random
from se_sync import (
angle,
certificate,
connection_laplacian,
local_search,
matmul,
objective,
relaxed_cost,
riemannian_gradient_norm,
rot,
se_sync,
set_block,
symmetric_eigen,
transpose,
)
def wrap(a):
return (a + math.pi) % (2.0 * math.pi) - math.pi
def random_problem(seed, n, extra, sigma):
"""Random rotations, a spanning path plus extra edges, angle noise sigma (rad)."""
rng = random.Random(seed)
truth = [0.0] + [rng.uniform(-math.pi, math.pi) for _ in range(n - 1)]
pairs = [(i, i + 1) for i in range(n - 1)]
while len(pairs) < n - 1 + extra:
i, j = sorted(rng.sample(range(n), 2))
if (i, j) not in pairs:
pairs.append((i, j))
edges = [(i, j, rot(truth[j] - truth[i] + rng.gauss(0.0, sigma)), 1.0) for i, j in pairs]
return truth, edges
def angles(rs):
return [angle(r) for r in rs]
def test_cost_is_the_trace_form():
_, edges = random_problem(1, 6, 5, 0.3)
rng = random.Random(2)
rs = [rot(rng.uniform(-3, 3)) for _ in range(6)]
y = [[0.0] * 12 for _ in range(2)]
for i, r in enumerate(rs):
set_block(y, i, r)
q = connection_laplacian(6, edges)
assert abs(objective(edges, rs) - relaxed_cost(q, y)) < 1e-9
def test_noise_free_problem_is_solved_exactly_and_certified():
truth, edges = random_problem(3, 8, 8, 0.0)
out = se_sync(8, edges)
assert out["upper"] < 1e-10 and abs(out["lower"]) < 1e-10
for a, b in zip(angles(out["rotations"]), truth):
assert abs(wrap(a - b)) < 1e-6
def test_low_noise_certifies_a_global_optimum():
truth, edges = random_problem(4, 10, 10, 0.1)
out = se_sync(10, edges)
assert out["lam_min"] >= -1e-6 * 4
# tight relaxation: the rounded solution attains the lower bound
assert out["upper"] - out["lower"] < 1e-6 * max(1.0, out["upper"])
assert max(abs(wrap(a - b)) for a, b in zip(angles(out["rotations"]), truth)) < 0.3
def test_certificate_vanishes_on_the_solution():
_, edges = random_problem(5, 7, 6, 0.2)
q = connection_laplacian(7, edges)
y = [[0.0] * 14 for _ in range(2)]
for i in range(7):
set_block(y, i, rot(0.0))
y, _ = local_search(q, y, 7)
s = certificate(q, y, 7)
# first order condition: Y S = 0, so S has the rows of Y in its null space
ys = matmul(y, s)
assert max(abs(x) for row in ys for x in row) < 1e-5
assert riemannian_gradient_norm(q, y, 7) < 1e-4
def test_brute_force_on_three_rotations():
for seed in range(3):
truth, edges = random_problem(10 + seed, 3, 1, 0.8)
edges = [(i, j, r, w) for (i, j, r, _), w in zip(edges, (1.0, 2.0, 0.5))]
out = se_sync(3, edges)
# grid over the two free angles, then a local refinement
best = (float("inf"), 0.0, 0.0)
steps = 72
for a in range(steps):
for b in range(steps):
t1, t2 = 2 * math.pi * a / steps, 2 * math.pi * b / steps
f = objective(edges, [rot(0.0), rot(t1), rot(t2)])
if f < best[0]:
best = (f, t1, t2)
f, t1, t2 = best
h = 2 * math.pi / steps
while h > 1e-9:
moved = False
for d1, d2 in ((h, 0), (-h, 0), (0, h), (0, -h)):
g = objective(edges, [rot(0.0), rot(t1 + d1), rot(t2 + d2)])
if g < f:
f, t1, t2, moved = g, t1 + d1, t2 + d2, True
if not moved:
h /= 2
assert out["lower"] <= f + 1e-9
assert abs(out["upper"] - f) < 1e-7
def twisted_cycle(n, k):
"""A noise-free cycle of n identity measurements, started at the winding k state."""
edges = [(i, (i + 1) % n, rot(0.0), 1.0) for i in range(n)]
start = [rot(2.0 * math.pi * k * i / n) for i in range(n)]
return edges, start
def test_twisted_cycle_is_a_critical_point_that_the_certificate_rejects():
n = 9
edges, start = twisted_cycle(n, 1)
q = connection_laplacian(n, edges)
y = [[0.0] * (2 * n) for _ in range(2)]
for i, r in enumerate(start):
set_block(y, i, r)
# every rotation is balanced between its two neighbors
assert riemannian_gradient_norm(q, y, n) < 1e-9
# the local search cannot leave it in rank 2
y2, _ = local_search(q, [list(row) for row in y], n)
assert abs(relaxed_cost(q, y2) - relaxed_cost(q, y)) < 1e-9
vals, _ = symmetric_eigen(certificate(q, y, n))
assert vals[0] < -0.1
# the staircase escapes and finds the global optimum, cost 0
out = se_sync(n, edges, start=start)
assert out["rank"] >= 3
assert out["upper"] < 1e-8
assert out["history"][0][2] < -0.1
def test_eigen_solver_matches_a_known_matrix():
rng = random.Random(7)
a = [[rng.uniform(-1, 1) for _ in range(6)] for _ in range(6)]
s = [[a[i][j] + a[j][i] for j in range(6)] for i in range(6)]
vals, vecs = symmetric_eigen(s)
for k, lam in enumerate(vals):
v = [vecs[i][k] for i in range(6)]
sv = [sum(s[i][j] * v[j] for j in range(6)) for i in range(6)]
assert max(abs(x - lam * y) for x, y in zip(sv, v)) < 1e-10
assert vals == sorted(vals)
vt = transpose(vecs)
eye = matmul(vt, vecs)
assert max(abs(eye[i][j] - (1.0 if i == j else 0.0)) for i in range(6) for j in range(6)) < 1e-10
History
Synchronization problems over rotations were studied in computer vision and in signal processing before SLAM. Carlone, Rosen, Calafiore, Leonard and Dellaert used Lagrangian duality in 2015 to verify the optimality of a pose graph solution from a local solver. Rosen, Carlone, Bandeira and Leonard presented SE-Sync in 2016 and published the journal version in 2019. It joins the semidefinite relaxation, the low rank method of Burer and Monteiro (2003), and the Riemannian staircase of Boumal. Later certifiable methods extend the idea to landmarks, to robust costs and to distributed solvers.
References
- David M. Rosen, Luca Carlone, Afonso S. Bandeira and John J. Leonard, SE-Sync: a certifiably correct algorithm for synchronization over the special Euclidean group, International Journal of Robotics Research 38(2-3), 2019, pages 95 to 125, the semidefinite relaxation of pose graph optimization, the closed form elimination of the translations, the exact recovery guarantee for small noise (Proposition 2), the Riemannian staircase, the optimality certificate and the rounding procedure
- Samuel Burer and Renato D. C. Monteiro, A nonlinear programming algorithm for solving semidefinite programs via low-rank factorization, Mathematical Programming 95(2), 2003, pages 329 to 357, the low rank factorization Z = Y^T Y of the semidefinite variable
- Cesar Cadena, Luca Carlone, Henry Carrillo, Yasir Latif, Davide Scaramuzza, Jose Neira, Ian Reid and John J. Leonard, Past, present, and future of simultaneous localization and mapping: toward the robust-perception age, IEEE Transactions on Robotics 32(6), 2016, pages 1309 to 1332, the discussion of global optimality and certifiable back ends
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag ZTRAGF Edit this page History Report an error Markdown