SPB Git

spb/wp24_uqo

Public
2.7 KB · 59 lines python
1"""Illustration of Propositions 2-5 (limit economy with one scarce complement): price of compute, wages and2factor shares as the compute endowment grows, for sigma in {0.5, 1, 1.5}; plus the energy-bounded case.3Output: results/figures/fig02_regimes.{pdf,png}, results/data/regime_map.csv"""4import os5import sys67import numpy as np8import pandas as pd910sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))11from agi_ge.ces import rho_of_sigma  # noqa: E40212from agi_ge.tasks import Technology  # noqa: E4021314ROOT = os.path.join(os.path.dirname(__file__), "..")15NU = [0.3, 0.25, 0.25, 0.2]16SKILL = [0, 0, 1, 1]17ALPHA = np.array([1.0, 2.0, 4.0, 8.0])18H = [0.6, 0.4]19S = 1.0          # the scarce complement (enters as K_N with nu_N = 0.4)20Qg = np.logspace(-1, 6, 100)21rows = []22for sigma in (0.5, 1.0, 1.5):23    tech = Technology(nu=np.array(NU), gamma=np.zeros(4), skill=np.array(SKILL), rho_B=-1.0,24                      nu_N=0.4, rho_N=rho_of_sigma(sigma), nu_T=0.0, nu_E=0.0, rho_T=0.0)25    x0 = None26    for Q in Qg:27        s = tech.solve(Q, H, KN=S, T=0.0, EY=0.0, Z=1.0, alpha=ALPHA, x0=x0)28        x0 = s["x"]29        wb = float(np.sum(s["w"] * np.array(H)))30        rows.append(dict(sigma=sigma, Q=Q, Y=s["Y"], A=s["A"], wL=s["w"][0], wH=s["w"][1],31                         labor_share=wb / s["Y"], compute_share=s["A"] * Q / s["Y"], S_share=s["RN"] * S / s["Y"]))32df = pd.DataFrame(rows)33df.to_csv(os.path.join(ROOT, "results", "data", "regime_map.csv"), index=False)3435import matplotlib36matplotlib.use("Agg")37import matplotlib.pyplot as plt38plt.rcParams.update({"font.size": 9, "axes.spines.top": False, "axes.spines.right": False})39cols = {0.5: "#c0392b", 1.0: "#7f8c8d", 1.5: "#1f3b73"}40fig, ax = plt.subplots(1, 4, figsize=(10.5, 2.9))41for sigma, d in df.groupby("sigma"):42    lab = rf"$\sigma={sigma}$"43    ax[0].plot(d.Q, d.Y, color=cols[sigma], label=lab)44    ax[1].plot(d.Q, d.A, color=cols[sigma], label=lab)45    ax[2].plot(d.Q, d.wH, color=cols[sigma], label=lab)46    ax[3].plot(d.Q, d.compute_share, color=cols[sigma], label=lab)47    ax[3].plot(d.Q, d.S_share, color=cols[sigma], ls="--")48ax[0].set_yscale("log"); ax[0].set_title("Output $Y$")49ax[1].set_yscale("log"); ax[1].set_title("Price of compute $A$")50ax[2].set_yscale("log"); ax[2].set_title("Wage $w_H = A\\cdot\\mathrm{CEU}(H)$")51ax[3].set_title("Shares: compute (solid), complement $S$ (dashed)")52for a in ax:53    a.set_xscale("log"); a.set_xlabel("compute $Q$ (complement $S$ fixed)")54ax[0].legend(frameon=False, fontsize=8)55fig.tight_layout()56for ext in ("pdf", "png"):57    fig.savefig(os.path.join(ROOT, "results", "figures", f"fig02_regimes.{ext}"), dpi=200)58print(df.groupby("sigma").tail(1)[["sigma", "Q", "Y", "A", "wH", "compute_share", "S_share", "labor_share"]].to_string())59
Files · f7215f55e72789efa8efb849ec6020a1edb0a939
Menu

Theme