Separate optimization problem from algorithm in the least squares package