Two small migrants fly 6,300 km from boreal forest to the Sahel, across a sea and a desert. At every wetland they choose how fat to get before leaving. An optimiser finds the plan that minimises time (bird A) or fuel burned (bird B) and the two birds race.
Cost minimised = days + mu x (fuel burned in lean-body masses). mu = 0: pure time-minimiser; large mu: energy-minimiser.
Each button re-optimises the whole flyway many times with the current sliders and tabulates the result.
The science
Flight range. Let x = m/m0 = 1 + f be body mass in lean-mass units (f = fat fuel). Flight power grows roughly as P ∝ m1.5 and the best-range airspeed as V ∝ m0.5, so the fuel burned per kilometre is proportional to the mass carried: dx/dt = -s x1.5, V = V0 x0.5. Dividing gives the Breguet-type range equation D = (V0/s) ln(xa/xb) for departure mass xa and arrival mass xb; with a tailwind u add u T, where T = (2/s)(xb-1/2 - xa-1/2) is the flight time. With the default s = 0.9 % per hour and V0 = 12 m/s a bird that doubles its mass can fly (V0/s) ln 2 ≈ 3,300 km in still air.
Refuelling. At a stopover i the bird gains fuel at a rate ri (fraction of lean mass per day), so getting from arrival fuel a to departure fuel d takes (d - a)/ri days plus a settling time. Carrying more fuel lets the bird fly farther or skip sites, but a heavy bird burns more per kilometre and takes longer to fatten.
The optimiser. Dynamic programming over (site, arrival fuel) finds, for the cost J = days + μ × (fuel burned), the best next site (sites can be skipped) and departure load; the table is built backwards from the destination, with a fuel grid of 2 % of lean mass. For μ = 0 this is the time-minimiser of Alerstam and Lindstrom: it flies on from a good site with a high load when the next site is poor, and stops where refuelling is fast. For large μ the cost is dominated by fuel burned, so the bird flies light, makes more and shorter hops and takes longer overall. The Pareto plot shows the trade-off.
Wind. Tailwind adds to ground speed and lengthens the range for the same fuel; a headwind shortens it. A strong enough headwind makes the 2,100 km crossing impossible at any fuel load (the optimiser reports it): real migrants wait for a favourable wind.
Simplifications, stated honestly. One generic small migrant, not a real species; constant refuelling rates (no depletion or competition at the stopover); fat only (no protein or muscle changes, no water balance); constant mass-scaling exponents; no rest-flight cycles, no predation or weather risk, no orientation error; four optional stopovers at fixed places on a stylised map (distances 1,000 / 1,000 / 2,100 / 1,000 / 1,200 km). The map is schematic and not any real flyway. Default values are plausible round numbers (flight consumption of about 1 % of body mass per hour, deposition rates of 2 to 8 % of lean mass per day, airspeed 12 m/s); a human should spot-check them against species data before quoting them.
Typical values to check: small passerines burn roughly 0.5 to 1 % of body mass per hour in flapping flight; fat deposition rates of 2 to 10 % of lean mass per day are reported at good sites; fat energy density about 39 kJ/g.