Optimal control of linear discrete macroeconomic systems