[ML] Make applyKnownSolution a template.

This is not changing any of the algorithms, just moving around.
WIP