Solow
An economy whose capital per worker approaches its steady state through saving and depreciation.
- Name:
solow - Field:
economics/macroeconomics - Formalism: ordinary differential equations
- References: Solow 1956
Factory
@register_model(
field='economics/macroeconomics',
tags=('growth', 'ode'),
references=('Solow 1956',),
defaults={'until': 200.0, 'dt': 1.0},
)
def solow(k: float = 1.0, *, s: float = 0.2, alpha: float = 0.3, delta: float = 0.05) -> System:
"""Return an economy whose capital per worker approaches its steady state through saving and depreciation.
Args:
k:
The initial capital per worker.
s:
The saving rate.
alpha:
The capital share of output.
delta:
The depreciation rate.
Returns:
system:
The model, with the economy `economy`.
Examples:
>>> from skcomplex.models.economics.macroeconomics import solow
>>> solow(s=0.3).interactions[0].s
0.3
"""
return System(
elements=[EconomyElement('economy', k=k)],
interactions=[SolowGrowthInteraction('growth', target='economy', s=s, alpha=alpha, delta=delta)],
)
Components
class EconomyElement(Element):
"""Economy described by its capital per worker.
Args:
label:
The label of the economy.
visual:
How the element is drawn, or `None` for `default_visual_`.
k:
The initial capital per worker.
Examples:
>>> from skcomplex.models.economics.macroeconomics import EconomyElement
>>> EconomyElement('country', k=1.0).k
1.0
"""
def __init__(
self,
label: str,
visual: VisualSpec | None = None,
*,
k: Annotated[float, StateSpec(domain=RealSet.closed_open(0, oo))] = 1.0,
) -> None:
super().__init__(label, visual=visual)
self.k = k
class SolowGrowthInteraction(RateInteraction):
"""Solow growth of the capital per worker `k` of a target, `dk/dt = s * k**alpha - delta * k`.
A rate interaction on the state `k` whose rate is the saving of a Cobb-Douglas output minus depreciation.
Args:
label:
The label of the interaction.
target:
The path of the economy.
s:
The saving rate.
alpha:
The output elasticity of capital.
delta:
The depreciation rate.
Examples:
>>> from skcomplex.models.economics.macroeconomics import SolowGrowthInteraction
>>> SolowGrowthInteraction('solow', target='country', s=0.3).s
0.3
"""
def __init__(
self,
label: str,
*,
target: Annotated[str, RoleSpec()],
s: Annotated[float, ParameterSpec(domain=RealSet.closed_open(0, oo))] = 0.2,
alpha: Annotated[float, ParameterSpec(domain=RealSet.open(0, oo))] = 0.3,
delta: Annotated[float, ParameterSpec(domain=RealSet.open(0, oo))] = 0.05,
) -> None:
super().__init__(label, target=target, state='k')
self.s = s
self.alpha = alpha
self.delta = delta
def _get_rate(self, namespace: SimpleNamespace) -> Expression:
"""Return the rate `s * k**alpha - delta * k`.
Args:
namespace:
The namespace of the symbols the rate can use, with the namespace of the target.
Returns:
rate:
The rate of the capital per worker.
"""
k = namespace.target.k
rate: Expression = namespace.s * k**namespace.alpha - namespace.delta * k
return rate
Equations
economy.k: diff(k_economy(t), t) == s_growth*k_economy(t)^alpha_growth - delta_growth*k_economy(t)