TSP Art Single-Line Portraits by Receipt
A likeness-first workflow for TSP portraits: convert tone to cities, optimize one closed tour, measure crossing and fidelity, then proof the physical line.
TSP art single-line portraits encode a face twice: point density carries tone and feature placement, while a traveling-salesman tour turns those points into one closed stroke. A shorter route can improve local continuity, but no solver can restore a likeness that the sampling stage discarded.
Treat stippling and routing as separate systems with separate controls, then reunite them in the physical proof. The workflow distinguishes a traveling salesman portrait, density-weighted stippling, continuous line drawing, and a deterministic 2-opt tour. The receipt preserves that separation when the plotted result is reviewed.
TSP art single-line portraits begin with point density
Convert the source to a controlled grayscale field, normalize crop and contrast, and protect the silhouette, eyes, nose, mouth, and major shadow masses. Dark regions receive more cities; light regions receive fewer. This is a halftoning decision before it is an optimization problem. Keep a uniform-random point control and a density-only stipple preview. If the preview does not read as the subject, routing is premature.
The paper on Continuous Line Drawings via the Traveling Salesman Problem describes constructing TSP instances from target pictures. TSP art single-line portraits inherit a useful constraint from continuous drawing: once the line begins, it visits every city and returns without a pen lift. The target is not literal pixel reproduction; local line concentration persuades the eye to recover tone.
Choose a deterministic sampler and seed. Rejection sampling is simple but can clump. Error diffusion and weighted stippling distribute tone more evenly. Voronoi stippling density offers a method for measuring and refining point placement. Cap minimum distance in highlights and feature zones so the solver does not create accidental dark knots. Store the point set as the primary portrait asset; it is the evidence of what information the route was given.
- tone field
- stipple cities
- TSP tour
- single line
Compare three sampling intentions before solving
Build contour, tonal, and sparse variants at a matched crop. Contour emphasizes high-gradient edges and recognizable features. Tonal distributes cities according to darkness and carries volume. Sparse uses fewer points with protected landmarks and tests how much identity survives. TSP art single-line portraits become art-directed when these variants predict different readings rather than merely different runtimes.
Measure city count, minimum and median distance, density error by tonal bucket, feature-zone coverage, and silhouette leakage. View the points at final size and from several distances. A contour sampler may describe eyes beautifully but flatten cheeks; a tonal sampler may model light while softening identity. A hybrid can reserve a bounded percentage for landmarks and sample the remainder from tone, but publish that split.
The TSP Art paper discusses city-distribution strategies for more attractive continuous-line images. Treat its methods as the bridge between halftoning and route design. Seeded randomness in generative art keeps the comparison fair. Run all three samplers from one source receipt, then select based on likeness and tonal behavior before examining the optimized tour. Otherwise the solver's elegant line can bias the sampling decision.
Optimize route length without confusing the objective
A Euclidean TSP tour visits every city once and returns to the start with minimal or near-minimal length. Short routes tend to connect nearby points, which keeps dense regions dark and avoids unnecessary leaps. TSP art single-line portraits rarely need a proof of global optimality to function, but they need the solver, settings, initial tour, stopping condition, and achieved length recorded.
Start with a deterministic nearest-neighbor or ordered seed, then apply 2-opt to reverse segments when that shortens the closed tour. A crossing in a Euclidean tour is usually removable by an improving exchange, so visible crossings are both an optimization clue and an ink-density problem. Compare length and crossing count after each stage. Keep the same point set; changing cities during route tuning destroys attribution.
The Concorde TSP solver is a well-established system for symmetric TSP instances. Large final pieces can use Concorde or another named solver, while a small 2-opt implementation remains a transparent fixture. TSP art single-line portraits should state whether the published tour is optimal, best known, or heuristic. Visual success does not require overstating the optimization result, and a globally shorter tour is not guaranteed to improve every facial feature.
| Condition | Tour effect | Portrait effect |
|---|---|---|
| Crossing remains | Avoidable extra length | Dark accidental knot |
| 2-opt removes crossing | Shorter local route | Cleaner tonal neighborhood |
| Too few cities | Fast sparse tour | Identity disappears |
| Too many cities | Expensive optimization | Ink fills highlights |
Test crossing removal and likeness separately
The runnable invariant is route integrity: every valid point index appears exactly once, the cycle closes, 2-opt never increases length, inputs remain unchanged, and repeated runs agree. Test a four-point crossing where the improvement is obvious. Add fewer-than-four and empty fallbacks, malformed routes, a city-count performance ceiling, and a semantic description. The artifact below exercises contour, tonal, and sparse variants without pretending their tiny coordinates form a portrait.
Likeness needs different evidence. Compare the stipple preview, initial tour, improved tour, and source at matched size. Use landmark error, silhouette overlap, tonal-bin error, and blinded recognition where appropriate. TSP art single-line portraits can lose identity through a good optimization if the single stroke places a high-contrast chord across a light feature. Add a route-fidelity review for eyes, mouth, and outer contour, but do not hard-code so many forced edges that the work ceases to be a TSP tour.
The distinction protects claims. 2-opt proves a local route improvement; recognition testing evaluates portrait communication. Record both. A failed likeness is repaired by point placement or explicitly constrained optimization, not by running the same unconstrained solver longer. TSP art single-line portraits are strongest when optimization supports the perceptual encoding rather than being displayed as mathematical prestige.
Runnable artifact: The fixture gives TSP art single-line portraits 11 assertions across three point-set variants, route shortening, uniqueness, repeatability, sparse and empty fallback, malformed input, a performance cap, SVG fallback, and accessible description.
Save this as tsp-portrait-two-opt.mjs and run node tsp-portrait-two-opt.mjs. Expected final line: PASS: 11 TSP portrait assertions.
import assert from "node:assert/strict";
const variants = Object.freeze({ contour: Object.freeze([[0,0],[2,0],[2,2],[0,2]]), tonal: Object.freeze([[0,0],[1,0],[2,1],[1,2],[0,1]]), sparse: Object.freeze([[0,0],[3,0],[1.5,2]]) });
const distance = (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1]);
export const tourLength = (points, route) => route.length < 2 ? 0 : route.reduce((sum, city, i) => sum + distance(points[city], points[route[(i + 1) % route.length]]), 0);
export function twoOpt(points, initialRoute, maxPoints = 2000) {
if (points.length > maxPoints) throw new RangeError("point_budget_exceeded");
if (new Set(initialRoute).size !== initialRoute.length || initialRoute.some((city) => city < 0 || city >= points.length)) throw new Error("invalid_route");
if (points.length < 4) return Object.freeze([...initialRoute]);
let route = [...initialRoute], improved = true;
while (improved) { improved = false;
for (let i = 1; i < route.length - 1 && !improved; i += 1) for (let k = i + 1; k < route.length && !improved; k += 1) {
const before = tourLength(points, route); const candidate = [...route.slice(0, i), ...route.slice(i, k + 1).reverse(), ...route.slice(k + 1)];
if (tourLength(points, candidate) + 1e-12 < before) { route = candidate; improved = true; }
}
} return Object.freeze(route);
}
export const portraitMode = ({ canvasAvailable, reducedMotion }) => !canvasAvailable ? "svg-polyline" : reducedMotion ? "static-canvas" : "animated-draw";
export const portraitDescription = (cities) => "Single closed line through " + cities + " portrait points";
const crossing = [[0,0],[2,2],[0,2],[2,0]], initial = [0,1,2,3];
let assertions = 0; const check = (fn) => { fn(); assertions += 1; };
check(() => assert.ok(tourLength(crossing, twoOpt(crossing, initial)) < tourLength(crossing, initial)));
check(() => assert.equal(new Set(twoOpt(crossing, initial)).size, crossing.length));
check(() => assert.deepEqual(twoOpt(crossing, initial), twoOpt(crossing, initial)));
check(() => assert.ok(tourLength(variants.contour, twoOpt(variants.contour, [0,2,1,3])) > 0));
check(() => assert.ok(tourLength(variants.tonal, twoOpt(variants.tonal, [0,2,4,1,3])) > 0));
check(() => assert.deepEqual(twoOpt(variants.sparse, [0,1,2]), [0,1,2]));
check(() => assert.deepEqual(twoOpt([], []), []));
check(() => assert.throws(() => twoOpt([[0,0],[1,1]], [0,0]), /invalid_route/));
check(() => assert.throws(() => twoOpt(Array(2001).fill([0,0]), []), /point_budget_exceeded/));
check(() => assert.equal(portraitMode({ canvasAvailable: false, reducedMotion: false }), "svg-polyline"));
check(() => assert.match(portraitDescription(100), /100 portrait points/));
assert.equal(Object.keys(variants).length, 3); assert.equal(assertions, 11); console.log("PASS: 11 TSP portrait assertions");
Proof the tour as one physical stroke
Choose page, crop, line width, pen or print process, direction, start point, and seam. Although the tour is cyclic, the physical drawing has a beginning and end; place that seam where startup ink or closure overlap will not damage a feature. TSP art single-line portraits need a final-size proof because thousands of locally close segments can merge into solid black under ink gain.
Inspect crossings, minimum gaps, acute turns, long bridges, and dwell-prone clusters. Simplification is risky because removing a city changes both optimization and tone. If smoothing, bound deviation and preserve city visits, then compare route length and feature fidelity. Bézier plotter curvature covers motion-aware smoothing, while pen-plotter hatching provides material calibration. A shortest vector tour can still ask a real pen to reverse too sharply.
Accessibility should name the portrayed subject when permission and context allow, explain that one closed line carries tone through density, and provide the source context outside decorative SVG. Reduced motion gets the complete static line instead of a draw-on animation. If canvas fails, render an SVG polyline or verified raster. Cap point count and solver time by output tier. A fallback may use the sparse purposeful variant; it should not quietly sample another face.
- 1Sample
Place cities from bounded tonal density. Protect eyes and silhouette.
- 2Solve
Run deterministic heuristic and record length. Compare three purposeful samplers.
- 3Proof
Inspect crossings, stroke gain, closure, and fallback. Cap city count.
- 4Draw
Choose start, paper, pen, and route direction. Keep semantic portrait text.
Release the portrait with point and tour receipts
Store source rights and crop, grayscale transform, feature masks, sampler, seed, city count, point hash, solver and version, initial route, heuristic settings, stopping criterion, tour length, crossing count, route hash, smoothing, stroke, page, material, start seam, and accessibility text. Include contour, tonal, and sparse previews. TSP art single-line portraits are reproducible only when point generation and route generation can be rerun independently.
Reject a piece whose stipple does not preserve identity, whose route omits or duplicates cities, whose crossings create accidental knots, whose line weight collapses highlights, or whose fallback changes the selected variant. Compare recognition at thumbnail and print distance. Keep a no-route stipple control and an initial-route control so the contribution of optimization remains visible.
The finished work should read first as a portrait, then reveal itself as one improbable continuous journey. The mathematics supplies a disciplined constraint; the city distribution carries perception; the physical line supplies character. That balance is the reason to make TSP art single-line portraits rather than trace a photograph with an arbitrary squiggle. A defensible edition can show exactly where likeness entered, exactly what the solver improved, and exactly how the line survived contact with paper.