The canal climbs a hill as a staircase of flat pools. A lock is a small chamber between two pools with gates at each end. To lift a boat, the keeper lets it into the chamber at the low level, closes the gates and fills the chamber with water taken from the pool above; the boat floats up and leaves at the top. Going down, the chamber is emptied into the pool below.
So a chamber is always either low or high. If a boat arrives and the chamber is on the wrong side, the keeper must first turn it round with nobody inside (an empty turn). Every fill draws water from the pool above, and a pool may never drop below its minimum, so busy days can run the upper pools dry until water flows down from the summit feeder. There are only a few keepers, who walk the towpath between locks, and locks only work from 06:00 to 22:00.
The goal: get every boat through on time, weighting lateness by priority (a doctor's launch counts more than a holiday boat), using as little water as possible.
Worked out from the simulation of the schedule minute by minute. Click a boat to follow it in the animation.
Close a lock or hold a boat back, then re-plan. The page re-runs the scheduler (the same code as solve.js, shorter search) right here in your browser.
All data and code are inlined in this file; it works offline.