Right, I've implemented a first cut version of an optimisation routine in PHP. It handles optimising salt additions for the stable, linearly calculated ions (Ca, Cl, Mg, etc). There are a couple of limitations:
Doesn't handle alkalinity - this doesn't seem to be a linear approximation. I'd...