Skip to content

Commit

Permalink
fix lag error due to subscripts change
Browse files Browse the repository at this point in the history
  • Loading branch information
thorek1 committed Mar 18, 2024
1 parent 3d75e67 commit e2c1eb0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
28 changes: 14 additions & 14 deletions src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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] :
Expand Down

0 comments on commit e2c1eb0

Please sign in to comment.