Hi all,
Announcing Armington.jl, a small package for building and evaluating arbitrarily-nested CES aggregators, trees where each internal node combines its children with a constant elasticity of substitution. See Constant elasticity of substitution - Wikipedia.
Design goals:
- Zero allocations on evaluation. Tree topology is encoded in the type parameters, so the recursion unrolls at compile time via tuple peeling.
- AD-friendly.
T<:Realthroughout, soForwardDiffduals pass through cleanly.
Quick example:
using Armington
# Two-level Armington: domestic vs. imports (US, EU)
imports = CESNode(4.0, (0.6, 0.4), (CESLeaf(:US), CESLeaf(:EU)); name=:imports)
tree = CESNode(1.5, (0.7, 0.3), (CESLeaf(:dom), imports); name=:total)
leaf_names(tree) # [:dom, :US, :EU]
aggregate(tree, [10, 5, 8]) # CES composite quantity
show_tree(tree) # print nesting structure
total: CESNode(σ=1.5, α=(0.7, 0.3))
└ dom
└ imports: CESNode(σ=4.0, α=(0.6, 0.4))
└ US
└ EU
Repo: GitHub - molivov/Armington.jl: Constant Elasticity of Substitution aggregators in Julia · GitHub
Feedback is welcome.
Cheers