Remove obsolete Julia stuff

time-shift
Sébastien Villemot 2020-01-31 22:50:55 +01:00
parent 9bcdfee490
commit 05e43a5025
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
8 changed files with 1 additions and 614 deletions

View File

@ -34,9 +34,7 @@ all-local: preprocessor/src/dynare_m$(EXEEXT)
ARCH="32"; \
fi; \
mkdir -p $(abs_srcdir)/matlab/preprocessor$$ARCH && \
$(LN_S) -f $(abs_builddir)/preprocessor/src/dynare_m$(EXEEXT) $(abs_srcdir)/matlab/preprocessor$$ARCH && \
mkdir -p $(abs_srcdir)/julia/preprocessor$$ARCH && \
$(LN_S) -f $(abs_builddir)/preprocessor/src/dynare_m$(EXEEXT) $(abs_srcdir)/julia/preprocessor$$ARCH
$(LN_S) -f $(abs_builddir)/preprocessor/src/dynare_m$(EXEEXT) $(abs_srcdir)/matlab/preprocessor$$ARCH
dist-hook:
rm -rf `find $(distdir)/matlab $(distdir)/examples -name *~`

View File

@ -1,57 +0,0 @@
module Dynare
##
# Copyright © 2015-2016 Dynare Team
#
# This file is part of Dynare.
#
# Dynare is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Dynare is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
##
export @compile, @dynare
function compile(modfile)
# Add cd to path if not already there
if isempty(findin([pwd()], LOAD_PATH))
unshift!(LOAD_PATH, pwd())
end
# Process modfile
println(string("Using ", Sys.WORD_SIZE, "-bit preprocessor"))
preprocessor = string(dirname(@__FILE__()), "/preprocessor", Sys.WORD_SIZE, "/dynare_m")
run(`$preprocessor $modfile language=julia output=dynamic`)
end
macro dynare(modfiles...)
ex = Expr(:toplevel)
if length(modfiles)>1
for modfile in modfiles
eval(:(compile($modfile)))
basename = split(modfile, ".mod"; keep=false)
push!(ex.args, Expr(:import, Symbol(basename[1])))
end
else
eval(:(compile($modfiles)))
basename = split(modfiles[1], ".mod"; keep=false)
push!(ex.args, Expr(:importall, Symbol(basename[1])))
end
return ex
end
macro compile(modfiles...)
for modfile in modfiles
eval(:(compile($modfile)))
end
end
end

View File

@ -1,197 +0,0 @@
module DynareModel
##
# Copyright © 2015-2018 Dynare Team
#
# This file is part of Dynare.
#
# Dynare is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Dynare is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
##
export Model, Endo, Exo, ExoDet, Param, dynare_model
abstract type Atom end
immutable Endo <: Atom
name::String
tex_name::String
long_name::String
end
immutable Exo <: Atom
name::String
tex_name::String
long_name::String
end
immutable ExoDet <: Atom
name::String
tex_name::String
long_name::String
end
immutable Param <: Atom
name::String
tex_name::String
long_name::String
end
immutable AuxVars
endo_index::Int
var_type::Int
orig_index::Int
orig_lead_lag::Int
eq_nbr::Int
orig_expr::String
end
immutable PredVars
index::Int
end
immutable ObsVars
index::Int
end
immutable DetShocks
exo_det::Int
exo_id::Int
multiplicative::Bool
periods::Vector{Int}
value::Float64
end
immutable EquationTag
eq_nbr::Int
name::String
value::String
end
type Model
fname::String
dname::String
dynare_version::String
endo::Vector{Endo}
exo::Vector{Exo}
exo_det::Vector{ExoDet}
param::Vector{Param}
aux_vars::Vector{AuxVars}
pred_vars::Vector{Int}
obs_vars::Vector{Int}
state_var::Vector{Int}
orig_endo_nbr::Int
orig_eq_nbr::Int
eq_nbr::Int
ramsey_eq_nbr::Int
det_shocks::Vector{DetShocks}
nstatic::Int
nfwrd::Int
npred::Int
nboth::Int
nsfwrd::Int
nspred::Int
ndynamic::Int
maximum_lag::Int
maximum_lead::Int
maximum_endo_lag::Int
maximum_endo_lead::Int
maximum_exo_lag::Int
maximum_exo_lead::Int
orig_maximum_lag::Int
orig_maximum_lead::Int
orig_maximum_endo_lag::Int
orig_maximum_endo_lead::Int
orig_maximum_exo_lag::Int
orig_maximum_exo_lead::Int
orig_maximum_exo_det_lag::Int
orig_maximum_exo_det_lead::Int
lead_lag_incidence::Matrix{Int}
nnzderivatives::Vector{Int}
analytical_steady_state::Bool
user_written_analytical_steady_state::Bool
static_and_dynamic_models_differ::Bool
equation_tags::Vector{String}
exo_names_orig_ord::Vector{Int}
sigma_e::Matrix{Float64}
correlation_matrix::Matrix{Float64}
h::Matrix{Float64}
correlation_matrix_me::Matrix{Float64}
sigma_e_is_diagonal::Bool
params::Vector{Float64}
static::Function
static_params_derivs::Function
dynamic::Function
dynamic_params_derivs::Function
steady_state::Function
end
function dynare_model()
return Model("", # fname
"", # dname
"", # dynare_version
Vector{Endo}(), # endo
Vector{Exo}(), # exo
Vector{ExoDet}(), # exo_det
Vector{Param}(), # param
Vector{AuxVars}(), # aux_vars
Vector{Int}(), # pred_vars
Vector{Int}(), # obs_vars
Vector{Int}(), # state_var
0, # orig_endo_nbr
0, # orig_eq_nbr
0, # eq_nbr
0, # ramsey_eq_nbr
Vector{DetShocks}(), # det_shocks
0, # nstatic
0, # nfwrd
0, # npred
0, # nboth
0, # nsfwrd
0, # nspred
0, # ndynamic
0, # maximum_lag
0, # maximum_lead
0, # maximum_endo_lag
0, # maximum_endo_lead
0, # maximum_exo_lag
0, # maximum_exo_lead
0, # orig_maximum_lag
0, # orig_maximum_lead
0, # orig_maximum_endo_lag
0, # orig_maximum_endo_lead
0, # orig_maximum_exo_lag
0, # orig_maximum_exo_lead
0, # orig_maximum_exo_det_lag
0, # orig_maximum_exo_det_lead
Matrix{Int}(0,0), # lead_lag_incidence
zeros(Int64,3), # nnzderivatives
false, # analytical_steady_state
false, # user_written_analytical_steady_state
false, # static_and_dynamic_models_differ
Vector{String}(), # equation_tags
Vector{Int}(), # exo_names_orig_ord
Matrix{Float64}(0,0), # sigma_e (Cov matrix of the structural innovations)
Matrix{Float64}(0,0), # correlation_matrix (Corr matrix of the structural innovations)
Matrix{Float64}(0,0), # h (Cov matrix of the measurement errors)
Matrix{Float64}(0,0), # correlation_matrix_me (Cov matrix of the measurement errors)
true, # sigma_e_is_diagonal
Vector{Float64}(), # params
function()end, # static
function()end, # static_params_derivs
function()end, # dynamic
function()end, # dynamic_params_derivs
function()end # steady_state
)
end
end

View File

@ -1,51 +0,0 @@
module DynareOptions
##
# Copyright © 2015 Dynare Team
#
# This file is part of Dynare.
#
# Dynare is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Dynare is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
##
export Options, dynare_options
type PFMSolver
maxit::Int
periods::Int
tolx::Float64
tolf::Float64
end
function pfmsolver_set_defaults()
return PFMSolver(500, # maxit (Maximum number of iterations in Newton algorithm)
400, # periods (Number of periods to return to the steady state)
1e-6, # tolx (Tolerance criterion on the paths for the endogenous variables)
1e-6 # tolf (Tolerance criterion on the stacked non linear equations)
)
end
type Options
dynare_version::String
linear::Bool
pfmsolver::PFMSolver
end
function dynare_options()
return Options("", # dynare_version
false, # linear
pfmsolver_set_defaults() # pfmsolver
)
end
end

View File

@ -1,36 +0,0 @@
module DynareOutput
##
# Copyright © 2015-2018 Dynare Team
#
# This file is part of Dynare.
#
# Dynare is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Dynare is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
##
export Ouput, dynare_output
type Output
dynare_version::String
steady_state::Vector{Float64}
exo_steady_state::Vector{Float64}
end
function dynare_output()
return Output("", # dynare_version
Vector{Float64}(), # steady_state
Vector{Float64}() # exo_steady_state
)
end
end

View File

@ -1,134 +0,0 @@
module PerfectForesightModelSolver
##
# Copyright © 2016 Dynare Team
#
# This file is part of Dynare.
#
# Dynare is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Dynare is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
##
import DynareModel.Model
import DynareOutput.Output
import DynareOptions.Options
export simulate_perfect_foresight_model!
function simulate_perfect_foresight_model!(endogenousvariables::Matrix{Float64}, exogenousvariables::Matrix{Float64}, steadystate::Vector{Float64}, model::Model, options::Options)
lead_lag_incidence = model.lead_lag_incidence
nyp = countnz(lead_lag_incidence[1,:])
ny0 = countnz(lead_lag_incidence[2,:])
nyf = countnz(lead_lag_incidence[3,:])
ny = length(model.endo)
nd = nyp+ny0+nyf
periods = options.pfmsolver.periods
params = model.params
tmp = lead_lag_incidence[2:3,:]'
i_cols_A1 = find(tmp)
i_cols_1 = tmp[i_cols_A1]
tmp = lead_lag_incidence[1:2,:]'
i_cols_AT = find(tmp)
i_cols_T = tmp[i_cols_AT]
tmp = lead_lag_incidence[2,:]'
i_cols_A0 = find(tmp)
i_cols_0 = tmp[i_cols_A0]
i_cols_j = collect(1:nd)
i_upd = ny+collect(1:periods*ny)
Y = vec(endogenousvariables)
z = Y[find(lead_lag_incidence')]
jacobian = zeros(Float64, ny, length(z)+length(model.exo))
residuals = zeros(Float64, ny)
println("\nMODEL SIMULATION:\n")
rd = zeros(Float64, periods*ny)
iA = zeros(Int64, periods*model.nnzderivatives[1])
jA = zeros(Int64, periods*model.nnzderivatives[1])
vA = zeros(Float64, periods*model.nnzderivatives[1])
convergence = false
iteration = 0
while !convergence
iteration += 1
i_rows = collect(1:ny)
i_cols_A = find(lead_lag_incidence')
i_cols = i_cols_A
m = 0
for it = 2:(periods+1)
model.dynamic(Y[i_cols], exogenousvariables, params, steadystate, it, residuals, jacobian)
if it==(periods+1) & it==2
(r, c, v) = findnz(jacobian[:,i_cols_0])
k = collect(1:length(v))+m
iA[k] = i_rows[r]
jA[k] = i_cols_A0[c]
vA[k] = v
elseif it==(periods+1)
(r, c, v) = findnz(jacobian[:,i_cols_T])
k = collect(1:length(v))+m
iA[k] = i_rows[r]
jA[k] = i_cols_A[i_cols_T[c]]
vA[k] = v
elseif it==2
(r, c, v) = findnz(jacobian[:,i_cols_1])
k = collect(1:length(v))+m
iA[k] = i_rows[r]
jA[k] = i_cols_A1[c]
vA[k] = v
else
(r, c, v) = findnz(jacobian[:,i_cols_j])
k = collect(1:length(v))+m
iA[k] = i_rows[r]
jA[k] = i_cols_A[c]
vA[k] = v
end
m += length(v)
rd[i_rows] = residuals
i_rows += ny
i_cols += ny
if it>2
i_cols_A += ny
end
end
err = maximum(abs.(rd))
println("Iter. ", iteration, "\t err. ", round(err, 12))
if err<options.pfmsolver.tolf
iteration -= 1
convergence = true
end
A = sparse(iA[1:m], jA[1:m], vA[1:m])
dy = -A\rd
Y[i_upd] += dy
if maximum(abs.(dy))<options.pfmsolver.tolx
convergence = true
end
end
if convergence
println("\nPFM solver converged in ", iteration, " iterations!\n")
endogenousvariables = reshape(Y, ny, periods+2)
end
end
end

View File

@ -1,100 +0,0 @@
module SteadyState
##
# Copyright © 2016 Dynare Team
#
# This file is part of Dynare.
#
# Dynare is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Dynare is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
##
using NLsolve
import DynareModel.Model
import DynareOutput.Output
export steady, steady!
export steady_state, steady_state!
function steady(model::Model, oo::Output)
if model.analytical_steady_state || model.user_written_analytical_steady_state
steadystate = zeros(length(model.endo))
model.steady_state(steadystate, oo.exo_steady_state, model.params)
return steadystate
else
error("You have to provide a closed form solution for the steady state, or declare a guess\nfor the steady state as a third input argument.")
end
end
function steady!(model::Model, oo::Output)
if model.analytical_steady_state || model.user_written_analytical_steady_state
model.steady_state(oo.steady_state, oo.exo_steady_state, model.params)
return
else
error("You have to provide a closed form solution for the steady state, or declare a guess\nfor the steady state as a third input argument.")
end
end
function steady(model::Model, oo::Output, yinit::Vector{Float64})
f!(fval::Vector{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fval)
j!(fjac::Matrix{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fjac)
fj!(fval::Vector{Float64}, fjac::Matrix{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fval, fjac)
r = nlsolve(f!, j!, fj!, yinit, show_trace=false)
if converged(r)
return r.zero
else
return fill(NaN, length(yinit))
end
end
function steady!(model::Model, oo::Output, yinit::Vector{Float64})
f!(fval::Vector{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fval)
j!(fjac::Matrix{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fjac)
fj!(fval::Vector{Float64}, fjac::Matrix{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fval, fjac)
r = nlsolve(f!, j!, fj!, yinit, show_trace=false)
if converged(r)
oo.steady_state = r.zero
else
oo.steady_state = fill(NaN, length(yinit))
end
end
function steady_state(model::Model, oo::Output)
ys = steady(model, oo)
display_steady_state(model, oo, ys)
end
function steady_state!(model::Model, oo::Output)
steady!(model, oo)
display_steady_state(model, oo, oo.steady_state)
end
function display_steady_state(model::Model, oo::Output, ys::Vector{Float64})
println("\n\nSTEADY STATE:\n")
for i = 1:length(model.endo)
println(string(model.endo[i].name, " = ", ys[i]))
end
end
function issteadystate(model::Model, oo::Output, ys::Vector{Float64})
residuals = zeros(Float64, length(ys))
compute_static_model_residuals!(model, oo, ys, residuals)
return maximum(abs(residuals))<1e-6
end
function compute_static_model_residuals!(model::Model, oo::Output, ys::Vector{Float64}, residuals::Vector{Float64})
model.static(ys, oo.exo_steady_state, model.params, residuals)
end
end

View File

@ -1,36 +0,0 @@
module Utils
##
# Copyright © 2015 Dynare Team
#
# This file is part of Dynare.
#
# Dynare is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Dynare is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
##
export get_power_deriv
function get_power_deriv(x::Float64, p::Real, k::Int)
if abs(x)<1e-12 && p>0 && k>p && typeof(p)==Int
dxp = .0
else
dxp = x^(p-k)
for i = 0:k-1
dxp *= p
p -= 1
end
end
return dxp
end
end