-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to reflect change in NLboxsolve.jl
- Loading branch information
Showing
4 changed files
with
262 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "SolveDSGE" | ||
uuid = "00bf1f32-23ad-54cc-bf6e-3216db8a43a2" | ||
authors = ["Richard Dennis <[email protected]>"] | ||
version = "0.5.4" | ||
version = "0.5.5" | ||
|
||
[deps] | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
nx = 2 | ||
|
||
ny = 5 | ||
|
||
ns = 1 | ||
|
||
nv = 7 | ||
|
||
ne = 7 | ||
|
||
jumps_to_approximate = [2] | ||
|
||
eqns_to_approximate = [6] | ||
|
||
variables = OrderedDict("l" => 1, "k" => 2, "c" => 3, "muc" => 4, "lm" => 5, "rbar" => 6, "wbar" => 7) | ||
|
||
function nlsolve_static_equations(f::Array{T,1},x::Array{T,1},p::Array{T1,1}) where {T<:Number,T1<:Real} | ||
|
||
f[1] = x[1] - ((0.60)*x[1] + (0.20)*sqrt(1.0-(0.60)^2)*0.0) | ||
f[2] = x[6] - ((0.36)*((p[1])/(1.0))^((0.36)-1.0) - (0.08)) | ||
f[3] = x[7] - ((1.0-(0.36))*((p[1])/(1.0))^((0.36))) | ||
f[4] = x[5]*(x[2]-(0.00)) - (0.0) | ||
f[5] = x[3]^(-(1.00)) - (x[4]) | ||
f[6] = x[4] - (x[5] + (0.96)*(1.0+x[6])*x[4]) | ||
f[7] = x[3] + x[2] - (x[7]*(1.0)*exp(x[1]) + (1.0+x[6])*x[2]) | ||
|
||
end | ||
|
||
function static_equations(x::Array{T,1},p::Array{T1,1}) where {T<:Number,T1<:Real} | ||
|
||
f = Array{T,1}(undef,length(x)) | ||
|
||
f[1] = x[1] - ((0.60)*x[1] + (0.20)*sqrt(1.0-(0.60)^2)*0.0) | ||
f[2] = x[6] - ((0.36)*((p[1])/(1.0))^((0.36)-1.0) - (0.08)) | ||
f[3] = x[7] - ((1.0-(0.36))*((p[1])/(1.0))^((0.36))) | ||
f[4] = x[5]*(x[2]-(0.00)) - (0.0) | ||
f[5] = x[3]^(-(1.00)) - (x[4]) | ||
f[6] = x[4] - (x[5] + (0.96)*(1.0+x[6])*x[4]) | ||
f[7] = x[3] + x[2] - (x[7]*(1.0)*exp(x[1]) + (1.0+x[6])*x[2]) | ||
|
||
return f | ||
|
||
end | ||
|
||
function dynamic_equations(x::Array{T,1},p::Array{T1,1}) where {T<:Number,T1<:Real} | ||
|
||
f = Array{T,1}(undef,7) | ||
|
||
f[1] = x[8] - ((0.60)*x[1] + (0.20)*sqrt(1.0-(0.60)^2)*x[15]) | ||
f[2] = x[6] - ((0.36)*((p[1])/(1.0))^((0.36)-1.0) - (0.08)) | ||
f[3] = x[7] - ((1.0-(0.36))*((p[1])/(1.0))^((0.36))) | ||
f[4] = x[5]*(x[2]-(0.00)) - (0.0) | ||
f[5] = x[3]^(-(1.00)) - (x[4]) | ||
f[6] = x[4] - (x[5] + (0.96)*(1.0+x[6])*x[11]) | ||
f[7] = x[3] + x[9] - (x[7]*(1.0)*exp(x[1]) + (1.0+x[6])*x[2]) | ||
|
||
return f | ||
|
||
end | ||
|
||
function dynamic_eqn_1(x::Array{T,1},p::Array{T1,1}) where {T<:Number,T1<:Real} | ||
|
||
f = x[8] - ((0.60)*x[1] + (0.20)*sqrt(1.0-(0.60)^2)*x[15]) | ||
|
||
return f | ||
|
||
end | ||
|
||
function dynamic_eqn_2(x::Array{T,1},p::Array{T1,1}) where {T<:Number,T1<:Real} | ||
|
||
f = x[6] - ((0.36)*((p[1])/(1.0))^((0.36)-1.0) - (0.08)) | ||
|
||
return f | ||
|
||
end | ||
|
||
function dynamic_eqn_3(x::Array{T,1},p::Array{T1,1}) where {T<:Number,T1<:Real} | ||
|
||
f = x[7] - ((1.0-(0.36))*((p[1])/(1.0))^((0.36))) | ||
|
||
return f | ||
|
||
end | ||
|
||
function dynamic_eqn_4(x::Array{T,1},p::Array{T1,1}) where {T<:Number,T1<:Real} | ||
|
||
f = x[5]*(x[2]-(0.00)) - (0.0) | ||
|
||
return f | ||
|
||
end | ||
|
||
function dynamic_eqn_5(x::Array{T,1},p::Array{T1,1}) where {T<:Number,T1<:Real} | ||
|
||
f = x[3]^(-(1.00)) - (x[4]) | ||
|
||
return f | ||
|
||
end | ||
|
||
function dynamic_eqn_6(x::Array{T,1},p::Array{T1,1}) where {T<:Number,T1<:Real} | ||
|
||
f = x[4] - (x[5] + (0.96)*(1.0+x[6])*x[11]) | ||
|
||
return f | ||
|
||
end | ||
|
||
function dynamic_eqn_7(x::Array{T,1},p::Array{T1,1}) where {T<:Number,T1<:Real} | ||
|
||
f = x[3] + x[9] - (x[7]*(1.0)*exp(x[1]) + (1.0+x[6])*x[2]) | ||
|
||
return f | ||
|
||
end | ||
|
||
individual_equations = Array{Function}(undef,7) | ||
individual_equations[1] = dynamic_eqn_1 | ||
individual_equations[2] = dynamic_eqn_2 | ||
individual_equations[3] = dynamic_eqn_3 | ||
individual_equations[4] = dynamic_eqn_4 | ||
individual_equations[5] = dynamic_eqn_5 | ||
individual_equations[6] = dynamic_eqn_6 | ||
individual_equations[7] = dynamic_eqn_7 | ||
|
||
function closure_chebyshev_equations(state,scaled_weights,order,domain,p) | ||
|
||
function chebyshev_equations(f::Array{T,1},x::Array{T,1}) where {T<:Number} | ||
|
||
approx2 = chebyshev_evaluate(scaled_weights[1],x[5+1:end],order,domain) | ||
|
||
#f = Array{T,1}(undef,7) | ||
|
||
f[1] = x[6] - ((0.60)*state[1] + (0.20)*sqrt(1.0-(0.60)^2)*0.0) | ||
f[2] = x[4] - ((0.36)*((p[1])/(1.0))^((0.36)-1.0) - (0.08)) | ||
f[3] = x[5] - ((1.0-(0.36))*((p[1])/(1.0))^((0.36))) | ||
f[4] = x[3]*(state[2]-(0.00)) - (0.0) | ||
f[5] = x[1]^(-(1.00)) - (x[2]) | ||
f[6] = x[2] - (x[3] + (0.96)*(1.0+x[4])*approx2) | ||
f[7] = x[1] + x[7] - (x[5]*(1.0)*exp(state[1]) + (1.0+x[4])*state[2]) | ||
|
||
#return f | ||
|
||
end | ||
|
||
return chebyshev_equations | ||
|
||
end | ||
|
||
function closure_smolyak_equations(state,scaled_weights,order,domain,p) | ||
|
||
function smolyak_equations(f::Array{T,1},x::Array{T,1}) where {T<:Number} | ||
|
||
poly = smolyak_polynomial(x[5+1:end],order,domain) | ||
approx2 = smolyak_evaluate(scaled_weights[1],poly) | ||
|
||
#f = Array{T,1}(undef,7) | ||
|
||
f[1] = x[6] - ((0.60)*state[1] + (0.20)*sqrt(1.0-(0.60)^2)*0.0) | ||
f[2] = x[4] - ((0.36)*((p[1])/(1.0))^((0.36)-1.0) - (0.08)) | ||
f[3] = x[5] - ((1.0-(0.36))*((p[1])/(1.0))^((0.36))) | ||
f[4] = x[3]*(state[2]-(0.00)) - (0.0) | ||
f[5] = x[1]^(-(1.00)) - (x[2]) | ||
f[6] = x[2] - (x[3] + (0.96)*(1.0+x[4])*approx2) | ||
f[7] = x[1] + x[7] - (x[5]*(1.0)*exp(state[1]) + (1.0+x[4])*state[2]) | ||
|
||
#return f | ||
|
||
end | ||
|
||
return smolyak_equations | ||
|
||
end | ||
|
||
function closure_hcross_equations(state,scaled_weights,order,domain,p) | ||
|
||
function hcross_equations(f::Array{T,1},x::Array{T,1}) where {T<:Number} | ||
|
||
poly = hyperbolic_cross_polynomial(x[5+1:end],order,domain) | ||
approx2 = hyperbolic_cross_evaluate(scaled_weights[1],poly) | ||
|
||
#f = Array{T,1}(undef,7) | ||
|
||
f[1] = x[6] - ((0.60)*state[1] + (0.20)*sqrt(1.0-(0.60)^2)*0.0) | ||
f[2] = x[4] - ((0.36)*((p[1])/(1.0))^((0.36)-1.0) - (0.08)) | ||
f[3] = x[5] - ((1.0-(0.36))*((p[1])/(1.0))^((0.36))) | ||
f[4] = x[3]*(state[2]-(0.00)) - (0.0) | ||
f[5] = x[1]^(-(1.00)) - (x[2]) | ||
f[6] = x[2] - (x[3] + (0.96)*(1.0+x[4])*approx2) | ||
f[7] = x[1] + x[7] - (x[5]*(1.0)*exp(state[1]) + (1.0+x[4])*state[2]) | ||
|
||
#return f | ||
|
||
end | ||
|
||
return hcross_equations | ||
|
||
end | ||
|
||
function closure_piecewise_equations(variables,grid,state,integrals,p) | ||
|
||
function piecewise_equations(f::Array{T,1},x::Array{T,1}) where {T<:Number} | ||
|
||
approx2 = piecewise_linear_evaluate(variables[2],grid,x[5+1:end],integrals) | ||
|
||
#f = Array{T,1}(undef,7) | ||
|
||
f[1] = x[6] - ((0.60)*state[1] + (0.20)*sqrt(1.0-(0.60)^2)*0.0) | ||
f[2] = x[4] - ((0.36)*((p[1])/(1.0))^((0.36)-1.0) - (0.08)) | ||
f[3] = x[5] - ((1.0-(0.36))*((p[1])/(1.0))^((0.36))) | ||
f[4] = x[3]*(state[2]-(0.00)) - (0.0) | ||
f[5] = x[1]^(-(1.00)) - (x[2]) | ||
f[6] = x[2] - (x[3] + (0.96)*(1.0+x[4])*approx2) | ||
f[7] = x[1] + x[7] - (x[5]*(1.0)*exp(state[1]) + (1.0+x[4])*state[2]) | ||
|
||
#return f | ||
|
||
end | ||
|
||
return piecewise_equations | ||
|
||
end | ||
|
||
unassigned_parameters = ["kbar"] | ||
|
||
solvers = "Projection" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.