Skip to main content

Colony — combinatorial optimization with a quality certificate

Buy a good route and a proof of how good it is. Colony solves the Euclidean travelling-salesman problem and returns a tour together with an admissible lower bound and the optimality gap — so an agent always knows how far from optimal it could be.

tests coverage protocol license

Landing: oracles.modelmarket.dev · Ecosystem: ecosystem.modelmarket.dev · Oracle family: oracles

Colony is a member of the oracle family built on oracle-core: each oracle exposes priced, signed capabilities over the AIMarket v2 protocol. Where Chronos sells time you can verify, Colony sells optimization you can trust — every answer ships with a certificate of quality.

How it works

flowchart TD
    A[Agent] -- "points, iterations" --> I["/ai-market/v2/invoke<br/>colony.optimize@v1"]
    I --> NN[Nearest-neighbour<br/>construction]
    NN --> TO[2-opt local search<br/>untangle / shorten]
    NN --> LB[Lower bound<br/>cheapest incident edges / 2]
    TO --> R[tour + length]
    LB --> R
    R --> G[gap = length - bound / bound]
    G --> E[Signed envelope<br/>receipt + provenance]
    E --> A

    subgraph family [oracle-core family]
        I
        E
    end

The optimum lies in [lower_bound, length], so the returned tour is provably at most gap fraction longer than the best possible route. No trust in the oracle required — the agent can recompute the bound itself.

The math (short version)

  1. Nearest-neighbour greedily hops to the closest unvisited city, then closes the loop — a sane O(n²) starting tour.
  2. 2-opt repeatedly reverses a tour segment whenever that removes a crossing and shortens the tour. It only ever accepts strictly-improving moves, so its result is never longer than the nearest-neighbour tour.
  3. Lower bound = ½·Σᵢ (cheapest edge incident to node i). Every tour uses exactly two edges per node, each ≥ that node's minimum edge, so this is a genuine admissible lower bound on the optimum. Hence length ≥ lower_bound always.

gap = (length − lower_bound) / lower_bound is the certificate.

Degenerate bound. If coincident input points drive the lower bound to 0, it certifies nothing, so gap is reported as null (unknown) rather than a spurious 0. The one exception is all-coincident points, where length is also 0: the tour is then provably optimal and gap is a genuine 0.

Capabilities

Capability What agents buy Price
colony.optimize@v1 A near-optimal tour over ≥3 2D points plus an admissible lower bound and optimality gap — a route with a quality certificate $0.005 / call

Input: { "points": [[x,y], ...] (>=3), "iterations": int = 1000 } Output: { "tour": [int], "length": float, "lower_bound": float, "gap": float | null, "n": int } (gap is null when a zero lower bound certifies nothing)

Use-cases (agent economy)

  • Delivery / logistics agent plans a multi-stop route and uses gap to decide whether the route is good enough to dispatch or worth paying for more iterations.
  • Drone / survey swarm orders waypoints to minimize flight distance under a battery budget, with a bound proving the plan is within X% of optimal.
  • PCB / fabrication agent sequences drill or pick-and-place moves to cut machine time, shipping the certificate to a downstream QA agent.
  • Marketplace meta-agent compares competing route providers objectively: the signed gap is a verifiable quality score, not a vendor claim.

Invoke it

curl -s http://localhost:9304/ai-market/v2/invoke \
  -H 'content-type: application/json' \
  -d '{
        "capability_id": "colony.optimize@v1",
        "input": { "points": [[0,0],[1,0],[1,1],[0,1]], "iterations": 1000 }
      }' | jq

Returns a signed envelope:

{
  "ok": true,
  "capability_id": "colony.optimize@v1",
  "output": { "tour": [0,1,2,3], "length": 4.0, "lower_bound": 2.0, "gap": 1.0, "n": 4 },
  "price_usd": 0.005,
  "provenance": { "source": "prod-colony", "timestamp": "...", "input_hash": "..." },
  "receipt": { "...signed Ed25519 receipt..." }
}

Run locally

# from the monorepo root
PYTHONPATH=oracles/colony .venv/bin/python -m colony.main        # serves on :9304
PYTHONPATH=oracles/colony .venv/bin/python -m pytest oracles/colony/tests -q

Visual

A live cosmic visualization lives at frontend/index.html: points scattered across a dark starfield, with the tour drawn as a glowing closed path that visibly untangles and shortens as 2-opt runs. Open the file directly in any browser — no build step, no dependencies.

Docs


MIT licensed. Part of the oracle-core family.

Metadata

Release files for aimarket-oracle-colony 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aimarket-oracle-colony 0.1.0
File Size Uploaded Provenance
aimarket_oracle_colony-0.1.0.tar.gz 9.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aimarket-oracle-colony 0.1.0
File Interpreter ABI Platform
aimarket_oracle_colony-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.1 kB

Release files / aimarket_oracle_colony-0.1.0.tar.gz

Download URL aimarket_oracle_colony-0.1.0.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f17603f2bc11fe8b474dd6f34d5b09fa218861d64c81117c91cca76a871a52b6
BLAKE2b-256 checksum
How to use checksums
6bd09367f0d396c78bab5f9ed3d9350cd0678283a23318eab40bedea373a1a96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / aimarket_oracle_colony-0.1.0-py3-none-any.whl

Download URL aimarket_oracle_colony-0.1.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e00d990a54f4bba6ad9bb520b835c25491e42795be649eaf337f564d4402d03b
BLAKE2b-256 checksum
How to use checksums
05e2dbd526fa048d9b530375410e9f19957bde351adde2cd0ff1f68583be0c8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for aimarket-oracle-colony 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page