Algorithm Search⌘K

Algorithmadvanced

Ando's circumcenter algorithm

Also called Ando-Oasa-Suzuki-Yamashita algorithm.

Each robot moves toward the center of the smallest circle around the robots it sees, only as far as keeps every link, so a connected group converges to one point.

Time
O(k (r + m)) expected totalO(r + m) expected per_round
Space
O(r) extra
Where
k = the number of rounds; m = the number of pairs of robots that see each other; r = the number of robots
Properties
deterministiconlinenot randomized
Origin
Hideki Ando, Yoshinobu Oasa, Ichiro Suzuki, Masafumi Yamashita, 1999

Ando's circumcenter algorithm solves rendezvous for robots that see only the robots within a fixed distance VV, have no memory, no identifiers, no common compass and no communication. In each round a robot looks at the robots it sees, computes the center of their smallest enclosing circle, and moves toward that center. It stops early if it would otherwise move out of the disk of radius V/2V/2 around the midpoint between itself and any robot it sees. The two robots of a pair use the same disk, so every pair that sees each other at the start still sees each other after every round, and a group whose visibility graph is connected stays connected. Ando, Oasa, Suzuki and Yamashita proved in 1999 that the robots converge to one point.

In plain words

Some small robots stand in a field. Each robot sees only the robots near it. The robots must all come to the same place, but they have no map, no radio and no memory.

Each robot draws the smallest circle around itself and the robots it sees, and walks toward the middle of that circle. This pulls the outer robots in and leaves robots in the middle where they are.

There is one danger. If a robot walks too far, it can lose sight of a friend, and then the group can split. So each robot also draws, for each friend it sees, a small safe circle halfway between the two of them. It walks only as far as it stays inside every safe circle. The friend uses the same circle, so the two can never get too far apart. Step by step the group shrinks to one point.

The problem

The model. There are rr point robots in the plane at positions p1,…,prp_1, \dots, p_r, and a visibility radius V>0V > 0. Robot ii sees robot jj when ∥pi−pj∥≤V\lVert p_i - p_j \rVert \le V; the pairs that see each other are the mm edges of the visibility graph, a disk graph like the random geometric graph. Robots work in rounds of look, compute and move. In the synchronous model all robots are active in every round. In the semi-synchronous model of Ando et al. an arbitrary subset is active in each round, every robot is active in infinitely many rounds, and the active robots look at the same moment and reach their targets before the next round. The robots are oblivious: the target depends only on the positions seen in the current round.

Input. The positions p1,…,prp_1, \dots, p_r, the radius VV, and the number KK of rounds.

Output. The positions after KK rounds. The goal is that the positions converge to one point when the visibility graph at the start is connected.

How it differs from close pages. The Laplacian consensus protocol also brings robots together, but it assumes a fixed graph. When the graph comes from distances, its averaging step can break links and split the group. The circumcenter step keeps every link, which is the connectivity maintenance property, without any extra term in the control.

The algorithm

  1. ANDO(p, V, K)
  2. 1for k = 1 to K do
  3. 2choose the active robots A ▷ all robots in the synchronous model
  4. 3for each i ∈ A, in parallel: S_i ← { j : ‖p_i - p_j‖ ≤ V } ▷ i ∈ S_i
  5. 4c ← center of the smallest enclosing circle of { p_j : j ∈ S_i }
  6. 5t ← 1
  7. 6for each j ∈ S_i with j ≠ i do
  8. 7m ← (p_i + p_j) / 2
  9. 8t ← min(t, largest s ∈ [0, 1] with ‖p_i + s (c - p_i) - m‖ ≤ V/2)
  10. 9p_i' ← p_i + t (c - p_i)
  11. 10all active robots move to p_i' at the same time; return p

Line L4 uses Welzl's randomized incremental method, which takes expected linear time in the number of points; see minimum enclosing circle. Line L8 solves a quadratic equation in ss. Since ∥pi−m∥=∥pi−pj∥/2≤V/2\lVert p_i - m \rVert = \lVert p_i - p_j \rVert / 2 \le V/2, the value s=0s = 0 is always allowed, so the robot never has to move backward. Robots that are not active keep their positions. Each robot uses only relative positions, so the rule does not need a common frame or a common unit of direction.

Example

Four robots on a line. Let V=1V = 1 and the robots stand at 0,1,2,30, 1, 2, 3 on a line. Robot 1 sees only robot 2, so its circle has the center 0.50.5, the midpoint of the two. The middle robots see both of their neighbors and stay. No safe disk cuts a step in this example.

round robot 1 robot 2 robot 3 robot 4
0 0 1 2 3
1 0.5 1 2 2.5
2 0.75 1.25 1.75 2.25
3 1.25 1.5 1.5 1.75
4 1.5 1.5 1.5 1.5

In round 3 all robots see each other except the two end robots, which are 1.5 apart. In round 4 every robot sees every other one, and all robots go to the center 1.51.5.

Five robots in the plane. Let V=1V = 1 and the robots stand at (0,0)(0, 0), (0.9,0)(0.9, 0), (1.7,0.4)(1.7, 0.4), (1.2,1.2)(1.2, 1.2) and (0.2,0.9)(0.2, 0.9). The visibility graph is the path 5−1−2−3−45 - 1 - 2 - 3 - 4 with lengths 0.9220.922, 0.90.9, 0.89440.8944 and 0.94340.9434, and the diameter is 1.74641.7464.

round robot 1 robot 2 robot 3 robot 4 robot 5 diameter edges
0 (0, 0) (0.9, 0) (1.7, 0.4) (1.2, 1.2) (0.2, 0.9) 1.7464 4
1 (0.45, 0.3722) (0.85, 0.2) (1.1071, 0.5857) (1.45, 0.8) (0.1, 0.45) 1.3946 7
2 (0.6036, 0.5179) (0.775, 0.625) (0.95, 0.5861) (1.15, 0.5) (0.475, 0.325) 0.6973 10
3 (0.8125, 0.4125) (0.8125, 0.4125) (0.8125, 0.4125) (0.8125, 0.4125) (0.8125, 0.4125) 0 10

The graph gains edges in every round and loses none. After round 2 all robots see each other, so in round 3 they all compute the same circle and move to its center (0.8125,0.4125)(0.8125, 0.4125).

A safe disk that cuts the step. Let V=1V = 1, robot 1 at (0,0)(0, 0), and three robots at (−0.97,0.21)(-0.97, 0.21), (0.17,−0.71)(0.17, -0.71) and (0.94,0.32)(0.94, 0.32), at distances 0.99250.9925, 0.73010.7301 and 0.9930.993. The smallest enclosing circle of the four has the center (−0.013,0.2296)(-0.013, 0.2296) and the radius 0.95720.9572. The safe disk of robot (0.17,−0.71)(0.17, -0.71) has the center (0.085,−0.355)(0.085, -0.355) and the radius 0.50.5, and the center of the circle is outside it. Line L8 gives t≈0.594t \approx 0.594, so robot 1 moves only to about (−0.0077,0.1363)(-0.0077, 0.1363), on the border of that disk.

Correctness

The proof shows four facts. First, the step of line L8 is well defined, because each safe disk contains the start point of the robot. Second, every pair that sees each other before a round sees each other after it: both robots end in the same disk of radius V/2V/2, and robots that do not move are in it already. Third, the center of a smallest enclosing circle lies in the convex hull of the points, so the new positions lie in the convex hull of the old ones, and the diameter of the group and the radius of its enclosing circle never grow. Fourth, if the whole group fits in a circle of radius V/2V/2, all robots meet at its center in one synchronous round.

That the diameter goes to zero is harder. Ando et al. (1999) proved convergence to a point in the semi-synchronous model, and Cortés, Martínez and Bullo (2006) gave a proof with an invariance principle for set-valued maps, in the style of the LaSalle invariance principle, that holds in any dimension.

Proof: The circumcenter step keeps every visibility link, never leaves the convex hull of the robots, and gathers a group that sees each other in one roundfull

There are rr point robots in the plane at positions p1,…,prp_1, \dots, p_r, and a visibility radius V>0V > 0. Robot ii sees robot jj when ∥pi−pj∥≤V\lVert p_i - p_j \rVert \le V. In one round a set AA of active robots is chosen (all robots in the synchronous model, any subset in the semi-synchronous model). Every active robot computes its new position from the same snapshot, and the robots that are not active stay where they are. Line numbers refer to the pseudocode on the Ando's circumcenter algorithm page. For an active robot ii let SiS_i be the set of robots it sees (line L3, ii included), cic_i the center of the smallest enclosing circle of SiS_i (line L4), mij=(pi+pj)/2m_{ij} = (p_i + p_j)/2 and BijB_{ij} the closed disk of radius V/2V/2 around mijm_{ij} (line L7). The new position is pi′=pi+ti(ci−pi)p_i' = p_i + t_i (c_i - p_i) (line L9).

Lemma 1 (the step is well defined). For each j∈Sij \in S_i the set Tij={s∈[0,1]:pi+s(ci−pi)∈Bij}T_{ij} = \{ s \in [0, 1] : p_i + s (c_i - p_i) \in B_{ij} \} is an interval [0,τij][0, \tau_{ij}] with τij≥0\tau_{ij} \ge 0. The value tit_i after lines L5 to L8 is min⁡(1,min⁡jτij)\min(1, \min_j \tau_{ij}), and pi+ti(ci−pi)∈Bijp_i + t_i (c_i - p_i) \in B_{ij} for every j∈Sij \in S_i.

Proof. ∥pi−mij∥=∥pi−pj∥/2≤V/2\lVert p_i - m_{ij} \rVert = \lVert p_i - p_j \rVert / 2 \le V/2 because j∈Sij \in S_i, so 0∈Tij0 \in T_{ij}. The disk BijB_{ij} is convex, so the set of ss for which the point of the segment lies in it is an interval, and it contains 00, so it is [0,τij][0, \tau_{ij}]. In the implementation τij\tau_{ij} is the larger root of the quadratic ∥pi−mij+s(ci−pi)∥2=V2/4\lVert p_i - m_{ij} + s (c_i - p_i) \rVert^2 = V^2 / 4, clipped to [0,1][0, 1]. The minimum of the right ends of intervals that all start at 00 is the right end of their intersection, which proves the last claim. □\square

Lemma 2 (visibility links are kept). If ∥pi−pj∥≤V\lVert p_i - p_j \rVert \le V before a round, then ∥pi′−pj′∥≤V\lVert p_i' - p_j' \rVert \le V after the round, in the synchronous and in the semi-synchronous model.

Proof. The midpoint mij=mjim_{ij} = m_{ji} and the disk Bij=BjiB_{ij} = B_{ji} are the same for both robots. If robot ii is active, then pi′∈Bijp_i' \in B_{ij} by Lemma 1, because j∈Sij \in S_i. If it is not active, then pi′=pi∈Bijp_i' = p_i \in B_{ij}, because ∥pi−mij∥≤V/2\lVert p_i - m_{ij} \rVert \le V/2. The same holds for jj. Two points of a disk of radius V/2V/2 are at distance at most VV. □\square

Lemma 3 (the center lies in the convex hull). The center cc of the smallest enclosing circle of a finite set SS lies in the convex hull conv⁡(S)\operatorname{conv}(S).

Proof. Let RR be the radius of the circle. Suppose c∉conv⁡(S)c \notin \operatorname{conv}(S) and let hh be the point of conv⁡(S)\operatorname{conv}(S) nearest to cc, so h≠ch \ne c. For every q∈conv⁡(S)q \in \operatorname{conv}(S) the angle at hh between c−hc - h and q−hq - h is at least a right angle, that is (c−h)⋅(q−h)≤0(c - h) \cdot (q - h) \le 0. Then ∥q−c∥2=∥q−h∥2+∥h−c∥2−2(q−h)⋅(c−h)≥∥q−h∥2+∥h−c∥2>∥q−h∥2\lVert q - c \rVert^2 = \lVert q - h \rVert^2 + \lVert h - c \rVert^2 - 2 (q - h) \cdot (c - h) \ge \lVert q - h \rVert^2 + \lVert h - c \rVert^2 > \lVert q - h \rVert^2. So every point of SS is strictly nearer to hh than to cc, and the circle around hh through the farthest point of SS has a radius smaller than RR and contains SS. This contradicts the choice of cc. □\square

Lemma 4 (the robots never leave the convex hull). Let H=conv⁡{p1,…,pr}H = \operatorname{conv}\{p_1, \dots, p_r\}. After a round every pi′p_i' lies in HH. So the diameter of the configuration and the radius of its smallest enclosing circle never increase.

Proof. By Lemma 3, ci∈conv⁡(Si)⊆Hc_i \in \operatorname{conv}(S_i) \subseteq H. The new position pi′=(1−ti)pi+ticip_i' = (1 - t_i) p_i + t_i c_i with ti∈[0,1]t_i \in [0, 1] is a convex combination of two points of HH, so it is in HH. Robots that are not active stay in HH. The diameter of a finite set equals the diameter of its convex hull, so the new diameter is at most the old one. The old smallest enclosing disk is convex and contains the old points, so it contains HH and every new point, and the new smallest enclosing circle has at most its radius. □\square

Lemma 5 (the target is a fixed point for gathered robots). If all robots of SiS_i are at one point, then ci=pic_i = p_i and robot ii does not move. So once all robots meet, they stay together.

Proof. The smallest enclosing circle of one point is that point with radius 00, so ci=pic_i = p_i and pi′=pip_i' = p_i for every tit_i. □\square

Theorem 1 (one round when the group is small). Let RR be the radius of the smallest enclosing circle of all rr robots, with center cc, and let 2R≤V2R \le V. Then after one synchronous round all robots are at cc.

Proof. Every two robots are at distance at most 2R≤V2R \le V, so every robot sees all robots, SiS_i is the whole set and ci=cc_i = c for every ii. Robot ii reaches cc when ti=1t_i = 1, that is, when c∈Bijc \in B_{ij} for every jj. By the parallelogram law, ∥c−mij∥2=12∥c−pi∥2+12∥c−pj∥2−14∥pi−pj∥2≤R2≤V2/4\lVert c - m_{ij} \rVert^2 = \frac12 \lVert c - p_i \rVert^2 + \frac12 \lVert c - p_j \rVert^2 - \frac14 \lVert p_i - p_j \rVert^2 \le R^2 \le V^2 / 4. So no constraint of line L8 cuts the step, and every robot moves to cc. ■\blacksquare

What is not proved here. Lemmas 2 and 4 show that the visibility graph of the initial links stays connected and that the configuration does not spread. They do not show that the diameter goes to zero. That the robots of a connected start converge to one point, in the semi-synchronous model where each robot is active infinitely often, is the theorem of Ando, Oasa, Suzuki and Yamashita (1999), and Cortés, Martínez and Bullo (2006) give a proof through an invariance principle for set-valued maps that also covers higher dimensions. The bound of Θ(r)\Theta(r) synchronous rounds on the line is from Martínez, Bullo, Cortés and Frazzoli (2007). These results, and the exact meeting in finite time that the synchronous runs of the implementation show, are not proved here.

Complexity

  • Per robot and round. If the robot knows the did_i robots it sees, line L4 takes expected O(di)O(d_i) time and lines L6 to L8 take O(di)O(d_i) time in the real RAM model. One synchronous round costs expected O(r+m)O(r + m) in total. The implementation finds the visible robots by checking all robots, which costs O(r2)O(r^2) per round.
  • Rounds. Martínez, Bullo, Cortés and Frazzoli (2007) show that the synchronous circumcenter algorithm on a line needs Θ(r)\Theta(r) rounds. The runs of the implementation on robots at unit spacing with V=1V = 1 needed 1, 2, 4, 5, 8, 9, 12, 13, 15, 16 and 19 rounds for r=2,…,12r = 2, \dots, 12, which is a measurement and not a bound.
  • Space. Each robot stores O(di)O(d_i) numbers during one round and nothing between rounds.

Properties

  • Oblivious and local. The step uses only the positions seen in the current round.
  • Keeps every link. A pair that sees each other never loses sight, in the synchronous and the semi-synchronous model.
  • Contracting. The group never leaves its convex hull, so its diameter does not grow.
  • Invariant under rigid motion and scaling. If the positions and VV are rotated, moved or scaled, the targets change in the same way, so robots need no common compass.
  • Not average preserving. The meeting point depends on the shape of the group, not on the mean of the start positions.
  • Fixed point. Robots that are all at one point stay there.

Variants and improvements

  • Any dimension. Cortés, Martínez and Bullo (2006) used the same rule in Rd\mathbb{R}^d, with the safe disks replaced by balls, and also with other proximity graphs.
  • Constraint sets. The step can be taken toward the circumcenter of the visible robots inside any convex set that keeps the links, not only the intersection of the disks around midpoints.
  • Asynchronous robots. With fully asynchronous robots, where a robot can move on old observations, the same guarantees need further assumptions, and the gathering literature of distributed computing treats this case.
  • Rendezvous with limited sensing. Lin, Morse and Anderson (2007) studied rendezvous of agents with a sensing radius, in a synchronous and an asynchronous part, with rules of the same kind; see rendezvous.

When to use it

Use it when the robots must meet, see only nearby robots, have no communication and no common frame, and must not split into groups. Use the Laplacian consensus protocol when the communication graph is fixed and does not depend on distances, or when the meeting point must be the average of the start positions.

Pitfalls

  • Skipping the safe disks. If a robot moves straight to the center of its circle, a robot at the edge of the group can lose sight of its only neighbor, and the group splits.
  • A disconnected start. Each connected group meets on its own, and the groups never join.
  • Rounding. The test ∥pi−pj∥≤V\lVert p_i - p_j \rVert \le V is at the border for pairs at distance exactly VV. Use a small tolerance in both the visibility test and line L8, or a pair at distance VV can be lost by rounding.
  • Slow on lines. On long thin groups the number of rounds grows with rr, because the end robots move only a little in each round.
  • Not the finite time gathering of distributed computing. Results there ask that robots reach the same point in finite time; the guarantee proved here is convergence.

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.

ando_circumcenter_algorithm.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/ando-circumcenter-algorithm/. The authors are listed in prov/TK3VSR.jsonl.

"""Ando's circumcenter algorithm for point robots in the plane with a visibility radius V.

In each round every active robot i looks at the robots within distance V
(itself included), computes the center c of their smallest enclosing circle,
and moves on the segment toward c as far as it can while it stays in the disk
of radius V/2 around the midpoint (p_i + p_j)/2 of every visible robot j.
Two robots that see each other then still see each other after the round.

Robots are oblivious: the step depends only on the current positions.
"""

import math
import random
from typing import Iterable, Sequence

Point = tuple[float, float]


def _circle2(a: Point, b: Point) -> tuple[float, float, float]:
    cx, cy = (a[0] + b[0]) / 2, (a[1] + b[1]) / 2
    return cx, cy, math.dist(a, b) / 2


def _circle3(a: Point, b: Point, c: Point):
    """Circumscribed circle of three points, or None if they are collinear."""
    bx, by = b[0] - a[0], b[1] - a[1]
    cx, cy = c[0] - a[0], c[1] - a[1]
    den = 2 * (bx * cy - by * cx)
    if abs(den) < 1e-18:
        return None
    b2, c2 = bx * bx + by * by, cx * cx + cy * cy
    ux = (cy * b2 - by * c2) / den
    uy = (bx * c2 - cx * b2) / den
    return a[0] + ux, a[1] + uy, math.hypot(ux, uy)


def _inside(circ, p: Point, tol: float = 1e-12) -> bool:
    return math.dist((circ[0], circ[1]), p) <= circ[2] * (1 + tol) + tol


def smallest_enclosing_circle(points: Iterable[Point], rng: random.Random | None = None):
    """Return (cx, cy, radius) of the smallest circle that contains all points.

    Randomized incremental algorithm (Welzl's method written as three nested
    loops), expected O(n) time after a random shuffle.
    """
    pts = list(points)
    if not pts:
        raise ValueError("no points")
    (rng or random.Random(0)).shuffle(pts)
    circ = (pts[0][0], pts[0][1], 0.0)
    for i in range(1, len(pts)):
        if _inside(circ, pts[i]):
            continue
        circ = (pts[i][0], pts[i][1], 0.0)
        for j in range(i):
            if _inside(circ, pts[j]):
                continue
            circ = _circle2(pts[i], pts[j])
            for k in range(j):
                if _inside(circ, pts[k]):
                    continue
                c3 = _circle3(pts[i], pts[j], pts[k])
                if c3 is None:
                    # collinear: the circle on the two farthest points
                    trio = [pts[i], pts[j], pts[k]]
                    a, b = max(((u, v) for u in trio for v in trio), key=lambda uv: math.dist(*uv))
                    c3 = _circle2(a, b)
                circ = c3
    return circ


def _max_step(p: Point, c: Point, m: Point, half: float) -> float:
    """Largest t in [0, 1] with |p + t (c - p) - m| <= half, given |p - m| <= half."""
    dx, dy = c[0] - p[0], c[1] - p[1]
    fx, fy = p[0] - m[0], p[1] - m[1]
    a = dx * dx + dy * dy
    if a == 0:
        return 1.0
    b = 2 * (dx * fx + dy * fy)
    cc = fx * fx + fy * fy - half * half  # <= 0 up to rounding
    disc = max(0.0, b * b - 4 * a * cc)
    t = (-b + math.sqrt(disc)) / (2 * a)
    return max(0.0, min(1.0, t))


def ando_target(i: int, pos: Sequence[Point], vis: float) -> Point:
    """New position of robot i after one activation."""
    p = pos[i]
    seen = [q for q in pos if math.dist(p, q) <= vis]  # @line L3
    cx, cy, _ = smallest_enclosing_circle(seen)  # @line L4
    t = 1.0  # @line L5
    for q in seen:  # @line L6
        if q is not p:
            m = ((p[0] + q[0]) / 2, (p[1] + q[1]) / 2)  # @line L7
            t = min(t, _max_step(p, (cx, cy), m, vis / 2))  # @line L8
    return p[0] + t * (cx - p[0]), p[1] + t * (cy - p[1])  # @line L9


def ando_round(pos: Sequence[Point], vis: float, active: Iterable[int] | None = None) -> list[Point]:
    """One round: the active robots (all if None) compute from the same snapshot and move."""
    pos = [tuple(map(float, q)) for q in pos]
    act = range(len(pos)) if active is None else active  # @line L2
    new = list(pos)
    for i in act:
        new[i] = ando_target(i, pos, vis)
    return new  # @line L10


def run(pos: Sequence[Point], vis: float, rounds: int, rng: random.Random | None = None,
        p_active: float = 1.0) -> list[Point]:
    """Run several rounds. With p_active < 1 each robot is active with that probability (SSYNC)."""
    cur = [tuple(map(float, q)) for q in pos]
    for _ in range(rounds):  # @line L1
        if p_active >= 1.0:
            cur = ando_round(cur, vis)
        else:
            act = [i for i in range(len(cur)) if rng.random() < p_active]
            cur = ando_round(cur, vis, act)
    return cur


def diameter(pos: Sequence[Point]) -> float:
    return max((math.dist(a, b) for a in pos for b in pos), default=0.0)


def visibility_edges(pos: Sequence[Point], vis: float) -> set[tuple[int, int]]:
    n = len(pos)
    return {(i, j) for i in range(n) for j in range(i + 1, n) if math.dist(pos[i], pos[j]) <= vis}
test_ando_circumcenter_algorithm.py 146 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/ando-circumcenter-algorithm/. The authors are listed in prov/TK3VSR.jsonl.

import itertools
import math
import random

from ando_circumcenter_algorithm import (
    ando_round,
    ando_target,
    diameter,
    run,
    smallest_enclosing_circle,
    visibility_edges,
)


def brute_force_circle(pts):
    """Smallest circle through 2 or 3 of the points that contains all points."""
    best = None
    cands = []
    for a, b in itertools.combinations(pts, 2):
        cands.append(((a[0] + b[0]) / 2, (a[1] + b[1]) / 2, math.dist(a, b) / 2))
    for a, b, c in itertools.combinations(pts, 3):
        bx, by, cx, cy = b[0] - a[0], b[1] - a[1], c[0] - a[0], c[1] - a[1]
        den = 2 * (bx * cy - by * cx)
        if abs(den) > 1e-12:
            b2, c2 = bx * bx + by * by, cx * cx + cy * cy
            ux, uy = (cy * b2 - by * c2) / den, (bx * c2 - cx * b2) / den
            cands.append((a[0] + ux, a[1] + uy, math.hypot(ux, uy)))
    for cx, cy, rad in cands:
        if all(math.dist((cx, cy), p) <= rad + 1e-9 for p in pts):
            if best is None or rad < best[2]:
                best = (cx, cy, rad)
    return best if best is not None else (pts[0][0], pts[0][1], 0.0)


def connected(pos, vis):
    edges = visibility_edges(pos, vis)
    seen, stack = {0}, [0]
    while stack:
        i = stack.pop()
        for a, b in edges:
            for x, y in ((a, b), (b, a)):
                if x == i and y not in seen:
                    seen.add(y)
                    stack.append(y)
    return len(seen) == len(pos)


def random_connected(rng, n, vis, box):
    while True:
        pos = [(rng.uniform(0, box), rng.uniform(0, box)) for _ in range(n)]
        if connected(pos, vis):
            return pos


def test_circle_against_brute_force() -> None:
    rng = random.Random(1)
    for _ in range(300):
        n = rng.randrange(1, 9)
        pts = [(rng.uniform(-3, 3), rng.uniform(-3, 3)) for _ in range(n)]
        if rng.random() < 0.2 and n >= 3:
            pts[2] = ((pts[0][0] + pts[1][0]) / 2, (pts[0][1] + pts[1][1]) / 2)
        c = smallest_enclosing_circle(pts, random.Random(rng.randrange(1000)))
        b = brute_force_circle(pts)
        assert abs(c[2] - b[2]) < 1e-9
        assert all(math.dist(c[:2], p) <= c[2] + 1e-9 for p in pts)


def test_line_of_four_by_hand() -> None:
    pos = [(float(i), 0.0) for i in range(4)]
    want = [[0.5, 1.0, 2.0, 2.5], [0.75, 1.25, 1.75, 2.25], [1.25, 1.5, 1.5, 1.75], [1.5] * 4]
    for w in want:
        pos = ando_round(pos, 1.0)
        assert max(abs(p[0] - x) for p, x in zip(pos, w)) < 1e-12
        assert all(p[1] == 0.0 for p in pos)


def test_binding_constraint() -> None:
    pos = [(0.0, 0.0), (-0.97, 0.21), (0.17, -0.71), (0.94, 0.32)]
    cx, cy, _ = smallest_enclosing_circle(pos)
    x, y = ando_target(0, pos, 1.0)
    t = math.hypot(x, y) / math.hypot(cx, cy)
    assert 0.59 < t < 0.6
    assert abs(math.dist((x, y), (0.085, -0.355)) - 0.5) < 1e-12


def test_visibility_is_kept_and_diameter_shrinks() -> None:
    rng = random.Random(2)
    for _ in range(40):
        n = rng.randrange(2, 9)
        pos = random_connected(rng, n, 1.0, 2.5)
        for _ in range(15):
            act = None if rng.random() < 0.5 else [i for i in range(n) if rng.random() < 0.6]
            new = ando_round(pos, 1.0, act)
            for i, j in visibility_edges(pos, 1.0):
                assert math.dist(new[i], new[j]) <= 1.0 + 1e-9
            assert diameter(new) <= diameter(pos) + 1e-12
            pos = new


def test_new_points_stay_in_bounding_box() -> None:
    rng = random.Random(3)
    for _ in range(40):
        pos = random_connected(rng, 6, 1.0, 2.0)
        new = ando_round(pos, 1.0)
        for c in range(2):
            lo, hi = min(p[c] for p in pos), max(p[c] for p in pos)
            assert all(lo - 1e-12 <= p[c] <= hi + 1e-12 for p in new)


def test_synchronous_exact_rendezvous() -> None:
    rng = random.Random(4)
    for _ in range(30):
        n = rng.randrange(2, 9)
        pos = random_connected(rng, n, 1.0, 2.5)
        k = 0
        while diameter(pos) > 0 and k < 200:
            pos = ando_round(pos, 1.0)
            k += 1
        assert diameter(pos) == 0.0


def test_complete_visibility_meets_in_one_round() -> None:
    rng = random.Random(5)
    for _ in range(30):
        pos = [(rng.uniform(0, 1), rng.uniform(0, 1)) for _ in range(rng.randrange(2, 8))]
        new = ando_round(pos, 10.0)
        c = smallest_enclosing_circle(pos)
        assert all(math.dist(p, c[:2]) < 1e-12 for p in new)


def test_semi_synchronous_convergence() -> None:
    rng = random.Random(6)
    for _ in range(10):
        pos = random_connected(rng, 6, 1.0, 2.5)
        out = run(pos, 1.0, 400, rng, p_active=0.5)
        assert diameter(out) < 1e-6


def test_disconnected_groups_stay_apart() -> None:
    pos = [(0.0, 0.0), (0.5, 0.0), (5.0, 0.0), (5.4, 0.3)]
    out = run(pos, 1.0, 50)
    assert diameter(out[:2]) == 0.0 and diameter(out[2:]) == 0.0
    assert math.dist(out[0], out[2]) > 4.0

History

Ando, Oasa, Suzuki and Yamashita published the algorithm in 1999, for anonymous and oblivious robots with limited visibility in a semi-synchronous model, and proved convergence to a point. Cortés, Martínez and Bullo (2006) studied a family of circumcenter rules of this kind, proved their convergence in any dimension, and showed that they are robust. Martínez, Bullo, Cortés and Frazzoli (2007) counted the rounds in the synchronous model. The book of Bullo, Cortés and Martínez (2009) treats the algorithm in its chapter on rendezvous.

References

  1. Hideki Ando, Yoshinobu Oasa, Ichiro Suzuki and Masafumi Yamashita, Distributed memoryless point convergence algorithm for mobile robots with limited visibility, IEEE Transactions on Robotics and Automation 15(5), 1999, pages 818 to 828 (the algorithm, the disks around the midpoints, and convergence to a point)
  2. Jorge Cortes, Sonia Martinez and Francesco Bullo, Robust rendezvous for mobile autonomous agents via proximity graphs in arbitrary dimensions, IEEE Transactions on Automatic Control 51(8), 2006, pages 1289 to 1298 (circumcenter algorithms in any dimension, constraint sets that keep the links, and convergence through an invariance principle)
  3. Sonia Martinez, Francesco Bullo, Jorge Cortes and Emilio Frazzoli, On synchronous robotic networks, Part II, Time complexity of rendezvous and deployment algorithms, IEEE Transactions on Automatic Control 52(12), 2007, pages 2214 to 2226 (the number of synchronous rounds of the circumcenter algorithm)
  4. Francesco Bullo, Jorge Cortes and Sonia Martinez, Distributed Control of Robotic Networks, Princeton University Press, 2009, Chapter 4, Connectivity maintenance and rendezvous

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.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.per_round
  • a full proof of time.total
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example