swarmkit-sailing
Sailing-route PSO physics layer built on top of the
swarmkit particle-swarm library.
What this crate provides
- Spherical-Earth coordinates and bearing math.
LatLon,LonLatBbox,Segment,TangentMetres,Wind. Haversine distance, signed lon delta, tangent-frame ↔(Δlon, Δlat)conversions. - Boat physics. A
Sailboattrait modelling fuel consumption and segment travel time as a function of (origin, destination, departure time, MCR throttle); aBoatimpl with polar-curve and fuel-rate parameters.WindSourceandLandmassSourcetraits for pluggable environment. - PSO movers.
SphericalPSOMoverdoes tangent-frame velocity updates so the swarm explores in real ground metres rather than raw(Δlon, Δlat)(which compresses east-west motion at high latitudes). PlusCauchyKickMover/ShapeKickMoverfor the diversity-preserving path-level kicks. - Init strategies.
PathInitseeds the outer swarm across a configurable mixture of shape families (sin-k1, sin-k2, anchor, gaussian, …) over multiple baselines (straight line, north-biased polyline, south-biased polyline) so the search starts with both shape and topology diversity. - Per-segment cache.
SegmentRangeTablesprecomputes a 2D (departure-time × MCR) travel-time grid per segment so the inner time-PSO replaces wind integrations with O(1) interpolated lookups. - Top-level entry points.
searchchains all of the above, dispatched byTopology(GBest,Niched,Ring,VonNeumann).reoptimize_timesruns only the inner time-PSO over a fixedxypath, returning aPath<N>with updated departure times — used by the GUI's after-drag re-fit and any "freeze the route, retime the legs" workflow.
Use this directly only if
…you're integrating sailing-route PSO into something other than
bywind. For the common case —
load a wind map, run a search, get a route — reach for bywind
instead; it composes this crate's primitives behind a higher-level
API and provides the GRIB2 / wind_codec / landmass plumbing.
Install
[]
= "0.1"
Features
probe-stats— atomic counters inside the segment-range cache for diagnostics (how often does a query fall outside the tabulated range?). Off by default; adds atomic traffic on the query hot path.profile-timers— sub-stageInstant::nowcounters around the hot paths (mover, boundary, fitness, segment-cache build). Used bybywind/profiling/. Off by default.
License
Dual-licensed under either of
- Apache License, Version 2.0 (
LICENSE-APACHE) - MIT license (
LICENSE-MIT)
at your option.