Commit 6b611136 authored by MichelJuillard's avatar MichelJuillard
Browse files

Allow for precompiled model files.

Artifacts.toml must still be adapted for new version of preprocessor
parent df4a51bd
Pipeline #5199 failed with stage
in 4 minutes and 8 seconds
......@@ -682,6 +682,11 @@ git-tree-sha1 = "e36adc471280e8b346ea24c5c87ba0571204be7a"
uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
version = "1.7.2"
[[Suppressor]]
git-tree-sha1 = "a819d77f31f83e5792a76081eee1ea6342ab8787"
uuid = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
version = "0.2.0"
[[TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
......
......@@ -19,4 +19,5 @@ Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PolynomialMatrixEquations = "4f9d485d-518f-41ed-81c8-372cd804c93b"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
TimeDataFrames = "ff13af16-2f41-468a-a2e1-aff5c43aabf7"
......@@ -87,6 +87,7 @@ struct Model
dynamic!
static!
set_auxiliary_variables!
set_dynamic_auxiliary_variables!
steady_state!
end
......@@ -171,16 +172,22 @@ function Model(modfilename, endogenous_nbr, lead_lag_incidence,
findall(in(current_dynamic_indices), dynamic_indices)
exogenous_indices = (backward_number + current_number
+ forward_number .+ (1:exogenous_nbr))
dynamic! = load_dynare_function(modfilename*"Dynamic.jl")
static! = load_dynare_function(modfilename*"Static.jl")
if isfile(modfilename*"set_auxiliary_variables.jl")
dynamic! = load_dynare_function(modfilename*"Dynamic")
static! = load_dynare_function(modfilename*"Static")
if isfile(modfilename*"DynamicSetAuxiliarySeries")
set_dynamic_auxiliary_variables! =
load_dynare_function(modfilename*"DynamicSetAuxiliarySeries")
else
set_dynamic_auxiliary_variables! = Nothing
end
if isfile(modfilename*"SetAuxiliarySeries")
set_auxiliary_variables! =
load_dynare_function_1(modfilename*"_set_auxiliary_variables.jl")
load_dynare_function(modfilename*"SetAuxiliarySeries")
else
set_auxiliary_variables! = Nothing
end
if isfile(modfilename*"SteadyState2.jl")
steady_state! = load_dynare_function(modfilename*"SteadyState2.jl")
steady_state! = load_dynare_function(modfilename*"SteadyState2")
else
steady_state! = nothing
end
......@@ -206,7 +213,7 @@ function Model(modfilename, endogenous_nbr, lead_lag_incidence,
current_dynamic_indices, forward_indices_d,
backward_indices_d, current_dynamic_indices_d,
exogenous_indices, dynamic!, static!, set_auxiliary_variables!,
steady_state!)
set_dynamic_auxiliary_variables!, steady_state!)
end
struct Simulation
......
using LinearAlgebra
using Suppressor
export get_de, get_abc, inverse_order_of_dynare_decision_rule
function inverse_order_of_dynare_decision_rule(m::Model)
......@@ -27,17 +28,11 @@ function inverse_order_of_dynare_decision_rule(m::Model)
(inverse_order_var, inverse_order_states)
end
function load_dynare_function(filename::String)
file = readlines(filename)
# drop "using Utils"
file[6] = "using Dynare: get_power_deriv"
insert!(file, 7, "using StatsFuns")
return eval(Meta.parse(join(file, "\n")))
end
function load_dynare_function_1(filename::String)
file = readlines(filename)
return eval(Meta.parse(join(file, "\n")))
function load_dynare_function(modname::String)
push!(LOAD_PATH, dirname(modname))
name = basename(modname)
@suppress eval(Meta.parse("using "*name))
return(eval(Symbol(name)))
end
"""
......
......@@ -79,7 +79,7 @@ function compute_stoch_simul!(context)
results = context.results.model_results[1]
options = context.options["stoch_simul"]
work = context.work
Base.invokelatest(steady_state!, context)
compute_steady_state!(context)
endogenous = results.trends.endogenous_steady_state
exogenous = results.trends.exogenous_steady_state
fill!(exogenous, 0.0)
......
function steady_state!(context)
function compute_steady_state!(context)
model = context.models[1]
work = context.work
steadystatemodule = model.steady_state!
......@@ -8,9 +8,10 @@ function steady_state!(context)
if isnothing(steadystatemodule)
fill!(results.trends.endogenous_steady_state, 0.0)
else
steadystatemodule.steady_state!(results.trends.endogenous_steady_state,
results.trends.exogenous_steady_state,
work.params)
Base.invokelatest(steadystatemodule.steady_state!,
results.trends.endogenous_steady_state,
results.trends.exogenous_steady_state,
work.params)
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment