Perfect foresight

Consider a series for the exogenous process \((m_t)_{0 \leq t \leq T}\). The perfect foresight problem consists in finding the path of optimal controls \((x_t)_{0 \leq t \leq T}\) and corresponding states \((s_t)_{0 \leq t \leq T}\) such that:

\(s_t = g\left(m_{t-1}, s_{t-1}, x_{t-1}, \epsilon_t \right)\)

\(0 = E_t \left( f\left(m_{t}, s_{t}, x_{t}, m_{t+1}, s_{t+1}, x_{t+1}\right) \right) \ \perp \ \underline{u} <= x_t <= \overline{u}\)

Special conditions apply for the initial state and controls. Initial state \(s_0\) is given exogenously. Final states and controls are determined by assuming the exogenous process satisfies \(m_t=m_T\) for all \(t\leq T\) and optimality conditions are satisfied in the last period:

\(f(m_T, s_T, x_T, m_T,s_T, x_T) \perp \underline{u} <= x_T <= \overline{u}\).

We assume that \(\underline{u}\) and \(\overline{u}\) are constants. This is not a big restriction since the model can always be reformulated in order to meet that constraint, by adding more equations.

The stacked system of equations satisfied by the solution is:

   
\(s_0 = s_0\) \(f(s_0, x_0, s_1, x_1) \perp \underline{u} <= x_0 <= \overline{u}\)
\(s_1 = g(s_0, x_0, \epsilon_1)\) \(f(s_1, x_1, s_2, x_2) \perp \underline{u} <= x_1 <= \overline{u}\)
   
\(s_T = g(s_{T-1}, x_{T-1}, \epsilon_T)\) \(f(s_T, x_T, s_T, x_T) \perp \underline{u} <= x_T <= \overline{u}\)

The system is solved using a nonlinear solver.

Note

TODO: explain the subtle timing convention converning the exogenous shock.

dolo.algos.perfect_foresight.deterministic_solve(model, shocks=None, s1=None, T=100, ignore_constraints=False, maxit=100, initial_guess=None, verbose=True, solver='ncpsolve', tol=1e-06)

Computes a perfect foresight simulation using a stacked-time algorithm.

The initial state is specified either by providing a series of exogenous shocks and assuming the model is initially in equilibrium with the first value of the shock, or by specifying an initial value for the states.

Parameters:
model : Model

Model to be solved

shocks : array-like, dict, or pandas.DataFrame

A specification of the shocks to the model. Can be any of the following (note by “declaration order” below we mean the order of model.symbols[“shocks”]):

  • A 1d numpy array-like specifying a time series for a single shock, or all shocks stacked into a single array.
  • A 2d numpy array where each column specifies the time series for one of the shocks in declaration order. This must be an N by number of shocks 2d array.
  • A dict where keys are strings found in model.symbols[“shocks”] and values are a time series of values for that shock. For model shocks that do not appear in this dict, the shock is set to the calibrated value. Note that this interface is the most flexible as it allows the user to pass values for only a subset of the model shocks and it allows the passed time series to be of different lengths.
  • A DataFrame where columns map shock names into time series. The same assumptions and behavior that are used in the dict case apply here

If nothing is given here, shocks is set equal to the calibrated values found in model.calibration[“shocks”] for all periods.

If the length of any time-series in shocks is less than T (see below) it is assumed that that particular shock will remain at the final given value for the duration of the simulaiton.

s1 : ndarray or dict

a vector with the value of initial states

T : int

horizon for the perfect foresight simulation

maxit : int

maximum number of iteration for the nonlinear solver

verbose : boolean

if True, the solver displays iterations

tol : float

stopping criterium for the nonlinear solver

ignore_constraints : bool

if True, complementarity constraints are ignored.

Returns:
pandas dataframe

a dataframe with T+1 observations of the model variables along the simulation (states, controls, auxiliaries). The first observation is the steady-state corresponding to the first value of the shocks. The simulation should return to a steady-state corresponding to the last value of the exogenous shocks.