Solve optimisation problems (#542)