This chapter describes a planning problem that generates competitive equilibrium allocations and compares two methods for solving it. The first method uses state- and date-contingent Lagrange multipliers; the second uses dynamic programming. The first method reveals a direct connection between the Lagrange multipliers and the equilibrium prices in a competitive equilibrium to be analyzed in Chapter 7. The second method provides good algorithms for calculating both the law of motion for the optimal quantities and the Lagrange multipliers. The chapter also describes a set of MATLAB programs that solve the planning problem and represent its solution in various ways. These programs are used to solve the planning problem for six sample economies formed by choosing particular examples of the ingredients from Chapter 4.