-
-
Notifications
You must be signed in to change notification settings - Fork 401
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
Add VariableInSetRef and has_variable_in_set #3955
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3955 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 43 43
Lines 6054 6085 +31
=========================================
+ Hits 6054 6085 +31 ☔ View full report in Codecov by Sentry. |
@@ -1308,6 +1308,40 @@ julia> x = @variable(model, [1:3], set = SecondOrderCone()) | |||
You cannot delete the constraint associated with a variable constrained on | |||
creation. | |||
|
|||
To check if a variable was constrained on creation, use [`has_variable_in_set`](@ref), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To check if a variable was constrained on creation, use [`has_variable_in_set`](@ref), | |
To check if a variable was constrained on creation, use [`is_variable_in_set`](@ref), |
model = owner_model(x) | ||
ci = get(model.variable_in_set_ref, x, nothing) | ||
if ci === nothing | ||
error("VariableInSetRef does not exist for $x") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error("VariableInSetRef does not exist for $x") | |
error("`VariableInSetRef` does not exist for `$x`") |
if ci !== nothing # ci === nothing if variable.set isa MOI.Reals | ||
model.variable_in_set_ref[ret] = ci | ||
if variable.shape != ScalarShape() && variable.shape != VectorShape() | ||
model.shapes[ci] = variable.shape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's nice that the shape can work as well
Closes #3951