Skip to content

Commit 838bc31

Browse files
committed
Minor reorganization + bring back 'm'.
1 parent df86efb commit 838bc31

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/main/init_parameters.jl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ Returns a `param` dict with the model parameters. These are independent of the g
99
- `alpha::Float64=0.5`: Cobb-Douglas coefficient on final good c^alpha * h^(1-alpha)
1010
- `beta::Float64=1`: Parameter governing congestion in transport cost
1111
- `gamma::Float64=1`: Elasticity of transport cost relative to infrastructure
12+
- `K::Float64=1`: Amount of concrete/asphalt (infrastructure budget)
1213
- `sigma::Float64=5`: Elasticity of substitution across goods (CES)
1314
- `rho::Float64=2`: Curvature in utility (c^alpha * h^(1-alpha))^(1-rho)/(1-rho)
1415
- `a::Float64=0.8`: Curvature of the production function L^alpha
15-
- `nu::Float64=1`: Elasticity of substitution b/w goods in transport costs if cross-good congestion
1616
- `N::Int64=1`: Number of goods traded in the economy (used for checks in `create_graph()`)
17-
- `K::Float64=1`: Amount of concrete/asphalt
1817
- `labor_mobility::Any=false`: Switch for labor mobility (true/false or 'partial')
1918
- `cross_good_congestion::Bool=false`: Switch for cross-good congestion
19+
- `nu::Float64=1`: Elasticity of substitution b/w goods in transport costs if cross-good congestion
20+
- `m::Vector{Float64}=ones(N)`: Vector of weights Nx1 in the cross congestion cost function
2021
- `annealing::Bool=true`: Switch for the use of annealing at the end of iterations (only if gamma > beta)
2122
- `verbose::Bool=true`: Switch to turn on/off text output (from Ipopt or other optimizers)
2223
- `duality::Bool=false`: Switch to turn on/off duality whenever available
@@ -38,8 +39,9 @@ Returns a `param` dict with the model parameters. These are independent of the g
3839
param = init_parameters(K = 10, labor_mobility = true)
3940
```
4041
"""
41-
function init_parameters(; alpha = 0.5, beta = 1, gamma = 1, sigma = 5, rho = 2, a = 0.8, nu = 1, K = 1,
42-
labor_mobility = false, cross_good_congestion=false, annealing=true,
42+
function init_parameters(; alpha = 0.5, beta = 1, gamma = 1, K = 1, sigma = 5, rho = 2, a = 0.8, N = 1,
43+
labor_mobility = false, cross_good_congestion=false, nu = 1, m = ones(N),
44+
annealing=true,
4345
verbose = true, duality = false, warm_start = true,
4446
kappa_min = 1e-5, min_iter = 20, max_iter = 200, tol = 1e-5, kwargs...)
4547
param = Dict()
@@ -61,6 +63,11 @@ function init_parameters(; alpha = 0.5, beta = 1, gamma = 1, sigma = 5, rho = 2,
6163
param[:rho] = rho
6264
param[:a] = a
6365
param[:nu] = nu
66+
if length(m) != N
67+
error("m must have length N = $N, but has length $(length(m))")
68+
end
69+
param[:N] = N
70+
param[:m] = m
6471
if labor_mobility === "partial" || labor_mobility === 0.5
6572
param[:mobility] = 0.5
6673
else
@@ -100,6 +107,10 @@ end
100107
# Check if the parameters are consistent with the graph structure
101108
function check_graph_param(graph, param)
102109

110+
if haskey(param, :m) && length(param[:m]) != graph[:N]
111+
@warn "m does not have the right length N = $(graph[:N])."
112+
end
113+
103114
if haskey(param, :omegaj) && !haskey(graph, :omegaj)
104115
graph[:omegaj] = param[:omegaj]
105116
end

0 commit comments

Comments
 (0)