Adaptive algorithms to optimise production