Radial Attention Model

import os
import numpy as np

import rad_conf
from rad import RadialAttentionModel, ParameterDependence

print("Loading input from '{}'.".format(rad_conf.RAD_DATA_DIR.split('/')[-1]))
print("Saving output in '{}'.".format(rad_conf.RAD_TEMP_DIR.split('/')[-1]))os.

model = RadialAttentionModel("msol")

rsections = [.1, .5, .7, .9]
xsections = [10.0, 20., 50.0, 100.0]

rsections_indices = model.grids["r"].lower_bound_index(rsections)
rsections_points = {}
for r_ind, r_val in enumerate(rsections_indices):
    idx = np.where(model.variables["s"].data[r_val, :] <= 0)[0][-1]
    rsections_points[r_ind] = ("$\\bar x (r_{})$".format(r_ind), (model.grids["x"].data[idx], 0))

xsections_indices = model.grids["x"].lower_bound_index(xsections)
xsections_points = {}
for x_ind, x_val in enumerate(xsections_indices):
    idx = np.where(model.variables["s"].data[:, x_val] <= 0)[0][0]
    xsections_points[x_ind] = ("$\\bar r (x_{})$".format(x_ind), (model.grids["r"].data[idx], 0))
model.save_learning_rsections()

l_rsections.png

Figure 1: Learning radius sections

model.save_cost_rsections()

c_rsections.png

Figure 2: Cost radius sections

model.variables["s"].save_figs({
    "angle": 215,
    "zlabel": "s",
    "prefix": "spol",
    "xsections": xsections,
    "xsections_points": xsections_points,
    "rsections": rsections,
    "rsections_points": rsections_points
})

spol_surf.png

Figure 3: Optimal effort control surface

spol_rsections.png

Figure 4: Optimal effort control radius sections

spol_xsections.png

Figure 5: Optimal effort control wealth sections

model.variables["q"].save_figs({
    "angle": 215,
    "zlabel": "q",
    "prefix": "qpol",
    "xsections": [1.0, 2., 4.0, 40.0],
    "rsections": [.1, .2, .5, .8]
})

qpol_surf.png

Figure 6: Optimal quantity control surface

qpol_rsections.png

Figure 7: Optimal quantity control radius sections

qpol_xsections.png

Figure 8: Optimal quantity control wealth sections

model.variables["v1"].save_figs({
    "angle": 215,
    "zlabel": "v",
    "prefix": "v"
})

v_surf.png

Figure 9: Value function surface

v_rsections.png

Figure 10: Value function radius sections

v_xsections.png

Figure 11: Value function wealth sections

model.get_radius_dynamics().save_figs({
    "angle": 215,
    "zlabel": "r'",
    "prefix": "radt"
})

radt_surf.png

Figure 12: Radius dynamics surface

radt_rsections.png

Figure 13: Radius dynamics radius sections

radt_xsections.png

Figure 14: Radius dynamics wealth sections

model.get_wealth_dynamics().save_figs({
    "angle": 215,
    "zlabel": "x'",
    "prefix": "wltt"
})

wltt_surf.png

Figure 15: Wealth dynamics surface

wltt_rsections.png

Figure 16: Wealth dynamics radius sections

wltt_xsections.png

Figure 17: Wealth dynamics wealth sections

model.save_latex_table("msol.tex")
\begin{figure}
\input{../tmp/fig/msol}
\end{figure}

parameterization.png

Figure 18: Parameterization of dependence analysis

ParameterDependence("delta").save_figs()

delta_on_spol.png

Figure 19: Dependence of effort control on δ

delta_on_qpol.png

Figure 20: Dependence of quantity control on δ

delta_on_v.png

Figure 21: Dependence of value function control on δ

ParameterDependence("alpha").save_figs()

alpha_on_spol.png

Figure 22: Dependence of effort control on α

alpha_on_qpol.png

Figure 23: Dependence of quantity control on α

alpha_on_v.png

Figure 24: Dependence of value function control on α

ParameterDependence("gamma").save_figs()

gamma_on_spol.png

Figure 25: Dependence of effort control on γ

gamma_on_qpol.png

Figure 26: Dependence of quantity control on γ

gamma_on_v.png

Figure 27: Dependence of value function control on γ

Author: Pantelis Karapanagiotis

Created: 2021-01-13 Wed 21:59

Validate