Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/systems/model_parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,9 @@ function parse_model!(exprs, comps, ext, eqs, icon, vs, ps, sps, c_evts, d_evts,
elseif mname == Symbol("@defaults")
parse_system_defaults!(exprs, arg, dict)
elseif mname == Symbol("@constraints")
parse_costs!(cons, dict, body)
parse_constraints!(cons, dict, body)
elseif mname == Symbol("@costs")
parse_constraints!(costs, dict, body)
parse_costs!(costs, dict, body)
elseif mname == Symbol("@consolidate")
parse_consolidate!(body, dict)
else
Expand Down Expand Up @@ -1160,7 +1160,7 @@ function parse_constraints!(cons, dict, body)
Base.remove_linenums!(body)
for arg in body.args
push!(cons, arg)
push!(dict[:constraints], readable_code.(cons)...)
push!(dict[:constraints], readable_code(arg))
end
end

Expand All @@ -1169,7 +1169,7 @@ function parse_costs!(costs, dict, body)
Base.remove_linenums!(body)
for arg in body.args
push!(costs, arg)
push!(dict[:costs], readable_code.(costs)...)
push!(dict[:costs], readable_code(arg))
end
end

Expand Down
2 changes: 2 additions & 0 deletions test/model_parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1042,4 +1042,6 @@ end
@test isequal(constrs[1], EvalAt(0.3)(ex.x) ~ 3)
@test isequal(constrs[2], ex.y ≲ 4)
@test ModelingToolkit.get_consolidate(ex)([1, 2], [3, 4]) ≈ 8 + log(2)
@test Example.structure[:constraints] == ["(EvalAt(0.3))(x) ~ 3", "y ≲ 4"]
@test Example.structure[:costs] == ["x + y", "(EvalAt(1))(y) ^ 2"]
end
Loading