A fast algorithm for near cost optimal line plans