Skip to content

Commit

Permalink
flattening equations solved it. multi-country-sector model parses
Browse files Browse the repository at this point in the history
  • Loading branch information
thorek1 committed Nov 10, 2024
1 parent 4d492fd commit d041cd7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/MacroModelling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@ end

function write_out_for_loops(arg::Expr)
postwalk(x -> begin
x = unblock(x)
x = flatten(unblock(x))
x isa Expr ?
x.head == :for ?
x.args[2] isa Array ?
Expand Down Expand Up @@ -1887,11 +1887,11 @@ function write_out_for_loops(arg::Expr)
# end
# : # for loop part of equation
# begin println(x);
(replace_indices_inside_for_loop(unblock(x.args[2]),
replace_indices_inside_for_loop(unblock(x.args[2]),
Symbol(x.args[1].args[1]),
(x.args[1].args[2]),
false,
:+)) :
:+) :
# println(out);
# return out end
# :
Expand Down Expand Up @@ -1970,7 +1970,7 @@ function parse_for_loops(equations_block)

end
end
return Expr(:block,eqs...)
return Expr(:block,eqs...) |> flatten
end


Expand Down
4 changes: 2 additions & 2 deletions src/macros.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import MacroTools: unblock, postwalk, @capture
import MacroTools: unblock, postwalk, @capture, flatten

const all_available_algorithms = [:linear_time_iteration, :riccati, :first_order, :first_order_doubling, :quadratic_iteration, :binder_pesaran, :second_order, :pruned_second_order, :third_order, :pruned_third_order]

Expand Down Expand Up @@ -303,7 +303,7 @@ macro model(𝓂,ex...)
x :
x,
model_ex.args[i])
push!(ss_equations,unblock(eqs))
push!(ss_equations,flatten(unblock(eqs)))

# write down ss equations including nonnegativity auxilliary variables
# find nonegative variables, parameters, or terms
Expand Down

0 comments on commit d041cd7

Please sign in to comment.