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

Add VariableInSetRef and has_variable_in_set #3955

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

odow
Copy link
Member

@odow odow commented Feb 28, 2025

Closes #3951

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (5587a72) to head (f4d2ebc).

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.
📢 Have feedback on the report? Share it here.

@@ -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),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Constraint associated with a variable set
2 participants