Least-cost planning