Skip to content

Commit

Permalink
Observed variables using Julia as target language were not being gene…
Browse files Browse the repository at this point in the history
…rated in the right order. Fixed.
  • Loading branch information
AleMorales committed Mar 2, 2015
1 parent 6387a05 commit 00d80df
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/codegeneration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ end
# Create the function in Julia on the Equations section of the model Dict
function create_observed_julia(model::OdeSorted, observed, name)
code = ""
c = 1
names_forcings = collect(keys(model.Forcings))
for level in 1:length(model.SortedEquations)
for (lhs, rhs) in model.SortedEquations[level]
Expand All @@ -160,9 +159,9 @@ function create_observed_julia(model::OdeSorted, observed, name)
code *= "@inbounds const " * string(rhs.Expr) * "\n"
end
elseif in(lhs, observed)
code *= "@inbounds const $lhs = " * string(rhs.Expr) * "\n"
code *= " obs[$c] = $lhs\n"
c += 1
c = findin(observed, [lhs])
code *= "const $lhs = " * string(rhs.Expr) * "\n"
code *= "@inbounds obs[$c] = $lhs\n"
else
code *= lhs * " = " * string(rhs.Expr) * "\n"
end
Expand Down

0 comments on commit 00d80df

Please sign in to comment.