Optimal production flow