Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix @SDconstraint with import #1795

Merged
merged 1 commit into from Jan 20, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/macros.jl
Expand Up @@ -651,7 +651,7 @@ function parseSDconstraint(_error::Function, sense::Symbol, lhs, rhs)
_error("Invalid sense $sense in SDP constraint")
end
vectorized = false
parsecode, buildcall = parse_one_operator_constraint(_error, false, Val(:in), aff, :(PSDCone()))
parsecode, buildcall = parse_one_operator_constraint(_error, false, Val(:in), aff, :(JuMP.PSDCone()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this indicate an escaping issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the viewpoint of parse_one_perator_constraint, the last argument is the set given by the user so it should be in the user scope, not JuMP scope.

vectorized, parsecode, buildcall
end

Expand Down
2 changes: 2 additions & 0 deletions test/hygiene.jl
Expand Up @@ -27,6 +27,8 @@ JuMP.@constraints(model, begin
sum( y[j] for j=r if j == 4) <= 1
end)

JuMP.@SDconstraint(model, [x x; -x x] ⪰ 0)

JuMP.@objective(model, sense, y[4])
JuMP.@objective(model, Min, x + sum( j*y[j] for j=r ))
JuMP.@objective(model, Max, sum( y[j] for j=r if j == 4))
Expand Down