1"""Economy -> game mapping: steady-state identities, zero-AI limit, household linearisation, compute market."""2import numpy as np34from age.equilibrium import lq_map as m5from age.equilibrium.lq_game import LQParams, wedge678def test_steady_state_resource_constraint_and_zero_ai():9 p = m.EconParams()10 ss = m.steady_state(p)11 assert ss['iota'] == 0.0 and ss['pQ'] == 0.0 and ss['share_L'] == 1 - p.alpha12 # resource constraint C + I + IQ + energy = Y13 assert np.isclose(ss['C'] + ss['I'] + ss['IQ'], ss['Y'])14 # factor payments exhaust output15 assert np.isclose(ss['RK'] * ss['K'] + ss['w'] * ss['L'] + ss['pQ'] * ss['QP'], ss['Y'])16 assert np.isclose(ss['R'], 1 / p.beta)171819def test_brock_mirman_closed_form():20 """delta=1, gamma=1 (log) zero-AI: K = alpha*beta*Y in steady state."""21 p = m.EconParams(delta=1.0, gamma=1.0)22 ss = m.steady_state(p)23 assert np.isclose(ss['K'], p.alpha * p.beta * ss['Y'], rtol=1e-10)242526def test_linearised_household_mpc_and_news():27 p = m.EconParams()28 ss = m.steady_state(p)29 lin = m.linearized_household(p, ss, T=300)30 # with beta R = 1 the MPC out of a windfall is the annuity value r/R-ish: between 0.02 and 0.0631 assert 0.02 < lin['MPC'] < 0.0632 assert lin['Uxx_level'] < 033 # savings mapping: negligible stake (documented negative result)34 assert abs(lin['kappa0']) < 0.0135 # GE path returns to a stationary level36 assert abs(lin['a_ge'][-1] - lin['a_ge'][-2]) < 1e-8373839def test_portfolio_mapping_and_benchmark_efficiency():40 p = m.EconParams()41 ss = m.steady_state(p)42 pf = m.portfolio_lq_params(p, ss)43 assert pf['alpha'] < 0 and pf['kappa0'] > 044 for D in (0.0, 0.3, 0.9):45 assert abs(wedge(pf['lqp'], D)) < 1e-646 # separate investors and workers -> positive wedge (over-delegation), Proposition 4(a)47 pf2 = m.portfolio_lq_params(p, ss, investors_earn_wages=False)48 assert wedge(pf2['lqp'], 0.5) > 0495051def test_compute_market_short_run_prop5():52 p = m.EconParams(qbar=0.05) # inference-heavy delegation53 ss = m.steady_state(p, KQ=0.3)54 pf = m.portfolio_lq_params(p, ss)55 base = m.compute_market_short_run(p, ss, pf['lqp'], pf, KQ=0.3)56 assert np.isclose(base['QP'] + p.qbar * base['D'], 0.3)57 # better model -> more delegation -> higher compute price, less automation, higher labour share58 p2 = m.EconParams(qbar=0.05, sig_A_R=0.02)59 pf2 = m.portfolio_lq_params(p2, ss)60 better = m.compute_market_short_run(p2, ss, pf2['lqp'], pf2, KQ=0.3)61 assert better['D'] > base['D']62 assert better['pQ'] > base['pQ']63 assert better['iota'] < base['iota']64 assert better['share_L'] > base['share_L']656667def test_no_private_gain_no_delegation():68 p = m.EconParams(sig_A_R=0.10, sig_H_R=0.10)69 ss = m.steady_state(p, KQ=0.3)70 pf = m.portfolio_lq_params(p, ss)71 assert m.delegation_share(p, ss, pf['lqp'], pf, pQ=0.5) == 0.072