From e2c1eb093e24d248ce26b8a477c864f2859a5f55 Mon Sep 17 00:00:00 2001 From: thorek1 Date: Mon, 18 Mar 2024 22:09:13 +0100 Subject: [PATCH] fix lag error due to subscripts change --- Project.toml | 4 +++- src/macros.jl | 28 ++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Project.toml b/Project.toml index 870cdb12..7d14cfd8 100644 --- a/Project.toml +++ b/Project.toml @@ -24,6 +24,7 @@ MatrixEquations = "99c1a7ee-ab34-5fd5-8076-27c950a045f4" NLopt = "76087f3c-5699-56af-9a33-bf431cd00edd" Optim = "429524aa-4258-5aef-a3af-852621145aeb" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" +PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d" REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" RecursiveFactorization = "f2c3362d-daeb-58d1-803e-2bc74f2840b4" @@ -73,6 +74,7 @@ NLopt = "0.6, ^1" Optim = "^1" Pigeons = "^0.2" PrecompileTools = "^1" +PythonCall = "<0.9.16" REPL = "^1" Random = "^1" RecursiveFactorization = "^0.2" @@ -83,7 +85,7 @@ SparseArrays = "^1" SpecialFunctions = "^2" SpeedMapping = "^0.3" StatsPlots = "^0.15" -Subscripts = "^0.1" +Subscripts = "0.1.3" Suppressor = "^0.2" SymPyPythonCall = "^0.2" Symbolics = "^5" diff --git a/src/macros.jl b/src/macros.jl index 042a725c..edd86355 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -175,23 +175,23 @@ macro model(𝓂,ex...) k = - x.args[2].args[3] while k < -2 # create auxilliary dynamic equations for exogenous variables with lag < -1 - if Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž") ∈ aux_vars_created + if Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž") ∈ aux_vars_created break else - push!(aux_vars_created,Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž")) + push!(aux_vars_created,Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž")) - push!(dyn_equations,Expr(:call,:-,Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž"),Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(k + 2)) * "βΎβ‚β‚‹β‚β‚Ž"))) + push!(dyn_equations,Expr(:call,:-,Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž"),Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(k + 2)) * "βΎβ‚β‚‹β‚β‚Ž"))) push!(dyn_eq_aux_ind,length(dyn_equations)) k += 1 end end - if Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž") βˆ‰ aux_vars_created && k < -1 + if Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž") βˆ‰ aux_vars_created && k < -1 - push!(aux_vars_created,Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž")) + push!(aux_vars_created,Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž")) - push!(dyn_equations,Expr(:call,:-,Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž"),Symbol(string(x.args[1]) * "β‚β‚‹β‚β‚Ž"))) + push!(dyn_equations,Expr(:call,:-,Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž"),Symbol(string(x.args[1]) * "β‚β‚‹β‚β‚Ž"))) push!(dyn_eq_aux_ind,length(dyn_equations)) end @@ -203,7 +203,7 @@ macro model(𝓂,ex...) end if - x.args[2].args[3] < -1 - Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(x.args[2].args[3] - 1)) * "βΎβ‚β‚‹β‚β‚Ž") + Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(x.args[2].args[3] - 1)) * "βΎβ‚β‚‹β‚β‚Ž") else Symbol(string(x.args[1]) * "β‚β‚‹β‚β‚Ž") end @@ -252,26 +252,26 @@ macro model(𝓂,ex...) k = x.args[2] while k < -2 - if Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž") ∈ aux_vars_created + if Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž") ∈ aux_vars_created break else - push!(aux_vars_created,Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž")) + push!(aux_vars_created,Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž")) - push!(dyn_equations,Expr(:call,:-,Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž"),Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(k + 2)) * "βΎβ‚β‚‹β‚β‚Ž"))) + push!(dyn_equations,Expr(:call,:-,Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž"),Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(k + 2)) * "βΎβ‚β‚‹β‚β‚Ž"))) push!(dyn_eq_aux_ind,length(dyn_equations)) k += 1 end end - if Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž") βˆ‰ aux_vars_created - push!(aux_vars_created,Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž")) + if Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž") βˆ‰ aux_vars_created + push!(aux_vars_created,Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž")) - push!(dyn_equations,Expr(:call,:-,Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž"),Symbol(string(x.args[1]) * "β‚β‚‹β‚β‚Ž"))) + push!(dyn_equations,Expr(:call,:-,Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(k + 1)) * "βΎβ‚β‚€β‚Ž"),Symbol(string(x.args[1]) * "β‚β‚‹β‚β‚Ž"))) push!(dyn_eq_aux_ind,length(dyn_equations)) end - Symbol(string(x.args[1]) * "ᴸ⁽⁻" * super(string(x.args[2] + 1)) * "βΎβ‚β‚‹β‚β‚Ž") + Symbol(string(x.args[1]) * "ᴸ⁽" * super(string(x.args[2] + 1)) * "βΎβ‚β‚‹β‚β‚Ž") end : x.args[1] : x.args[1] :